Add genetic backtest to worker

This commit is contained in:
2025-11-09 03:32:08 +07:00
parent 7dba29c66f
commit 7e08e63dd1
30 changed files with 5056 additions and 232 deletions

View File

@@ -19,6 +19,7 @@ const JobsSettings: React.FC = () => {
const [workerIdFilter, setWorkerIdFilter] = useState<string>('')
const [bundleRequestIdFilter, setBundleRequestIdFilter] = useState<string>('')
const [filtersOpen, setFiltersOpen] = useState<boolean>(false)
const [showTable, setShowTable] = useState<boolean>(false)
const jobClient = new JobClient({}, apiUrl)
@@ -56,9 +57,10 @@ const JobsSettings: React.FC = () => {
bundleRequestIdFilter || null
)
},
enabled: showTable, // Only fetch when table is shown
staleTime: 10000, // 10 seconds
gcTime: 5 * 60 * 1000,
refetchInterval: 5000, // Auto-refresh every 5 seconds
refetchInterval: showTable ? 5000 : false, // Auto-refresh only when table is shown
})
const jobs = jobsData?.jobs || []
@@ -316,7 +318,50 @@ const JobsSettings: React.FC = () => {
)}
</div>
{filtersOpen && (
{/* Load Table Button */}
{!showTable && (
<div className="card bg-base-100 shadow-md mb-4">
<div className="card-body">
<div className="flex items-center justify-between">
<div>
<h3 className="card-title text-lg">Jobs List</h3>
<p className="text-sm text-base-content/70">Click the button below to load and view the jobs table</p>
</div>
<button
className="btn btn-primary"
onClick={() => setShowTable(true)}
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-5 h-5">
<path strokeLinecap="round" strokeLinejoin="round" d="M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5M9 11.25v1.5M12 9v3.75m3-3.75v3.75m-9 .75h12.75a2.25 2.25 0 002.25-2.25V6.75a2.25 2.25 0 00-2.25-2.25H6.75A2.25 2.25 0 004.5 6.75v7.5a2.25 2.25 0 002.25 2.25z" />
</svg>
Load Jobs Table
</button>
</div>
</div>
</div>
)}
{showTable && (
<>
{/* Hide Table Button */}
<div className="card bg-base-100 shadow-md mb-4">
<div className="card-body py-3">
<div className="flex items-center justify-between">
<h3 className="card-title text-lg">Jobs List</h3>
<button
className="btn btn-ghost btn-sm"
onClick={() => setShowTable(false)}
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor" className="w-5 h-5">
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
Hide Table
</button>
</div>
</div>
</div>
{filtersOpen && (
<div className="card bg-base-200 mb-4">
<div className="card-body">
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 gap-4">
@@ -416,92 +461,96 @@ const JobsSettings: React.FC = () => {
</div>
)}
{error && (
<div className="alert alert-error mb-4">
<span>Error loading jobs: {(error as any)?.message || 'Unknown error'}</span>
</div>
{error && (
<div className="alert alert-error mb-4">
<span>Error loading jobs: {(error as any)?.message || 'Unknown error'}</span>
</div>
)}
<JobsTable
jobs={jobs}
isLoading={isLoading}
currentPage={currentPage}
totalPages={totalPages}
totalCount={totalCount}
pageSize={pageSize}
sortBy={sortBy}
sortOrder={sortOrder}
onPageChange={handlePageChange}
onSortChange={handleSortChange}
/>
</>
)}
<JobsTable
jobs={jobs}
isLoading={isLoading}
currentPage={currentPage}
totalPages={totalPages}
totalCount={totalCount}
pageSize={pageSize}
sortBy={sortBy}
sortOrder={sortOrder}
onPageChange={handlePageChange}
onSortChange={handleSortChange}
/>
{/* Bottom Menu Bar */}
<BottomMenuBar>
<li>
<a
onClick={(e) => {
e.preventDefault()
setFiltersOpen(!filtersOpen)
}}
className={filtersOpen ? 'active' : ''}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
</svg>
</a>
</li>
<li>
<a
onClick={(e) => {
e.preventDefault()
refetch()
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
</a>
</li>
<li>
<a
onClick={(e) => {
e.preventDefault()
clearFilters()
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</li>
</BottomMenuBar>
{showTable && (
<BottomMenuBar>
<li>
<a
onClick={(e) => {
e.preventDefault()
setFiltersOpen(!filtersOpen)
}}
className={filtersOpen ? 'active' : ''}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
</svg>
</a>
</li>
<li>
<a
onClick={(e) => {
e.preventDefault()
refetch()
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
</a>
</li>
<li>
<a
onClick={(e) => {
e.preventDefault()
clearFilters()
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</li>
</BottomMenuBar>
)}
</div>
)
}

View File

@@ -265,7 +265,7 @@ const BundleRequestModal: React.FC<BundleRequestModalProps> = ({
const successMessage = asTemplate
? 'Template saved successfully!'
: 'Bundle backtest request created successfully!';
new Toast(successMessage, true);
new Toast(successMessage, false);
onClose();
} catch (error) {
const errorMessage = asTemplate