Update backtest bundle
This commit is contained in:
@@ -332,6 +332,7 @@ public class BacktestRepository : IBacktestRepository
|
|||||||
.Include(b => b.ErrorMessage)
|
.Include(b => b.ErrorMessage)
|
||||||
.Include(b => b.ProgressInfo)
|
.Include(b => b.ProgressInfo)
|
||||||
.Include(b => b.Name)
|
.Include(b => b.Name)
|
||||||
|
.Include(b => b.CompletedBacktests)
|
||||||
.Include(b => b.User);
|
.Include(b => b.User);
|
||||||
|
|
||||||
var filter = Builders<BundleBacktestRequestDto>.Filter.Eq(b => b.User.Name, user.Name);
|
var filter = Builders<BundleBacktestRequestDto>.Filter.Eq(b => b.User.Name, user.Name);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, {useEffect, useRef, useState} from 'react';
|
import React, {useEffect, useRef, useState} from 'react';
|
||||||
import {BundleBacktestRequest, LightBacktestResponse} from '../../generated/ManagingApiTypes';
|
import {BundleBacktestRequest, LightBacktestResponse, Ticker, Timeframe} from '../../generated/ManagingApiTypes';
|
||||||
import {BacktestClient} from '../../generated/ManagingApi';
|
import {BacktestClient} from '../../generated/ManagingApi';
|
||||||
import useApiUrlStore from '../../app/store/apiStore';
|
import useApiUrlStore from '../../app/store/apiStore';
|
||||||
import Toast from '../../components/mollecules/Toast/Toast';
|
import Toast from '../../components/mollecules/Toast/Toast';
|
||||||
@@ -31,7 +31,17 @@ const BundleRequestModal: React.FC<BundleRequestModalProps> = ({ open, onClose,
|
|||||||
const client = new BacktestClient({} as any, apiUrl);
|
const client = new BacktestClient({} as any, apiUrl);
|
||||||
const res = await client.backtest_GetBacktestsByRequestId(bundle.requestId);
|
const res = await client.backtest_GetBacktestsByRequestId(bundle.requestId);
|
||||||
if (!res) return [];
|
if (!res) return [];
|
||||||
return res.map((b: any) => ({
|
return res.map((b: any) => {
|
||||||
|
// Map enums for ticker and timeframe
|
||||||
|
if (b.config) {
|
||||||
|
if (typeof b.config.ticker === 'number') {
|
||||||
|
b.config.ticker = Ticker[b.config.ticker as keyof typeof Ticker];
|
||||||
|
}
|
||||||
|
if (typeof b.config.timeframe === 'number') {
|
||||||
|
b.config.timeframe = Timeframe[b.config.timeframe as keyof typeof Timeframe];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
id: b.id,
|
id: b.id,
|
||||||
config: b.config,
|
config: b.config,
|
||||||
finalPnl: b.finalPnl,
|
finalPnl: b.finalPnl,
|
||||||
@@ -45,7 +55,8 @@ const BundleRequestModal: React.FC<BundleRequestModalProps> = ({ open, onClose,
|
|||||||
sharpeRatio: b.sharpeRatio ?? null,
|
sharpeRatio: b.sharpeRatio ?? null,
|
||||||
score: b.score ?? 0,
|
score: b.score ?? 0,
|
||||||
scoreMessage: b.scoreMessage ?? '',
|
scoreMessage: b.scoreMessage ?? '',
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
enabled: !!open && !!bundle,
|
enabled: !!open && !!bundle,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
@@ -78,6 +89,19 @@ const BundleRequestModal: React.FC<BundleRequestModalProps> = ({ open, onClose,
|
|||||||
fetchOptions = await authBase.transformOptions(fetchOptions);
|
fetchOptions = await authBase.transformOptions(fetchOptions);
|
||||||
await fetch(`${apiUrl}/backtest/Bundle/Subscribe?requestId=${bundle.requestId}`, fetchOptions);
|
await fetch(`${apiUrl}/backtest/Bundle/Subscribe?requestId=${bundle.requestId}`, fetchOptions);
|
||||||
connection.on('BundleBacktestUpdate', (result: LightBacktestResponse) => {
|
connection.on('BundleBacktestUpdate', (result: LightBacktestResponse) => {
|
||||||
|
// Map enums if needed
|
||||||
|
if (result.config) {
|
||||||
|
if (typeof result.config.ticker === 'number') {
|
||||||
|
result.config.ticker = Ticker[result.config.ticker as keyof typeof Ticker];
|
||||||
|
} else if (typeof result.config.ticker === 'string' && Ticker[result.config.ticker as keyof typeof Ticker]) {
|
||||||
|
result.config.ticker = Ticker[result.config.ticker as keyof typeof Ticker];
|
||||||
|
}
|
||||||
|
if (typeof result.config.timeframe === 'number') {
|
||||||
|
result.config.timeframe = Timeframe[result.config.timeframe as keyof typeof Timeframe];
|
||||||
|
} else if (typeof result.config.timeframe === 'string' && Timeframe[result.config.timeframe as keyof typeof Timeframe]) {
|
||||||
|
result.config.timeframe = Timeframe[result.config.timeframe as keyof typeof Timeframe];
|
||||||
|
}
|
||||||
|
}
|
||||||
setBacktests((prev) => {
|
setBacktests((prev) => {
|
||||||
if (prev.some((b) => b.id === result.id)) return prev;
|
if (prev.some((b) => b.id === result.id)) return prev;
|
||||||
return [...prev, result];
|
return [...prev, result];
|
||||||
|
|||||||
Reference in New Issue
Block a user