Add filters and sorting for backtests

This commit is contained in:
2025-10-14 18:06:36 +07:00
parent 49b0f7b696
commit 74adad5834
21 changed files with 4028 additions and 81 deletions

View File

@@ -665,7 +665,7 @@ export class BacktestClient extends AuthorizedApiBase {
return Promise.resolve<PaginatedBacktestsResponse>(null as any);
}
backtest_GetBacktestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: string | null | undefined, sortOrder: string | null | undefined): Promise<PaginatedBacktestsResponse> {
backtest_GetBacktestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: BacktestSortableColumn | undefined, sortOrder: string | null | undefined, scoreMin: number | null | undefined, scoreMax: number | null | undefined, winrateMin: number | null | undefined, winrateMax: number | null | undefined, maxDrawdownMax: number | null | undefined, tickers: string | null | undefined, indicators: string | null | undefined, durationMinDays: number | null | undefined, durationMaxDays: number | null | undefined): Promise<PaginatedBacktestsResponse> {
let url_ = this.baseUrl + "/Backtest/Paginated?";
if (page === null)
throw new Error("The parameter 'page' cannot be null.");
@@ -675,10 +675,30 @@ export class BacktestClient extends AuthorizedApiBase {
throw new Error("The parameter 'pageSize' cannot be null.");
else if (pageSize !== undefined)
url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
if (sortBy !== undefined && sortBy !== null)
if (sortBy === null)
throw new Error("The parameter 'sortBy' cannot be null.");
else if (sortBy !== undefined)
url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
if (sortOrder !== undefined && sortOrder !== null)
url_ += "sortOrder=" + encodeURIComponent("" + sortOrder) + "&";
if (scoreMin !== undefined && scoreMin !== null)
url_ += "scoreMin=" + encodeURIComponent("" + scoreMin) + "&";
if (scoreMax !== undefined && scoreMax !== null)
url_ += "scoreMax=" + encodeURIComponent("" + scoreMax) + "&";
if (winrateMin !== undefined && winrateMin !== null)
url_ += "winrateMin=" + encodeURIComponent("" + winrateMin) + "&";
if (winrateMax !== undefined && winrateMax !== null)
url_ += "winrateMax=" + encodeURIComponent("" + winrateMax) + "&";
if (maxDrawdownMax !== undefined && maxDrawdownMax !== null)
url_ += "maxDrawdownMax=" + encodeURIComponent("" + maxDrawdownMax) + "&";
if (tickers !== undefined && tickers !== null)
url_ += "tickers=" + encodeURIComponent("" + tickers) + "&";
if (indicators !== undefined && indicators !== null)
url_ += "indicators=" + encodeURIComponent("" + indicators) + "&";
if (durationMinDays !== undefined && durationMinDays !== null)
url_ += "durationMinDays=" + encodeURIComponent("" + durationMinDays) + "&";
if (durationMaxDays !== undefined && durationMaxDays !== null)
url_ += "durationMaxDays=" + encodeURIComponent("" + durationMaxDays) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
@@ -4275,6 +4295,21 @@ export interface LightBacktestResponse {
scoreMessage: string;
}
export enum BacktestSortableColumn {
Score = "Score",
FinalPnl = "FinalPnl",
WinRate = "WinRate",
GrowthPercentage = "GrowthPercentage",
HodlPercentage = "HodlPercentage",
Duration = "Duration",
Timeframe = "Timeframe",
IndicatorsCount = "IndicatorsCount",
MaxDrawdown = "MaxDrawdown",
Fees = "Fees",
SharpeRatio = "SharpeRatio",
Ticker = "Ticker",
}
export interface LightBacktest {
id?: string | null;
config?: TradingBotConfig | null;
@@ -4290,6 +4325,7 @@ export interface LightBacktest {
score?: number;
scoreMessage?: string | null;
metadata?: any | null;
ticker?: string | null;
}
export interface RunBacktestRequest {
@@ -4305,7 +4341,7 @@ export interface RunBacktestRequest {
}
export interface TradingBotConfigRequest {
accountName: string;
accountName?: string | null;
ticker: Ticker;
timeframe: Timeframe;
isForWatchingOnly: boolean;