Refactor signal generation in TradingService to process indicators individually, improving clarity and performance. Add new API types for refining indicators, including request and response structures.

This commit is contained in:
2025-12-28 20:59:11 +07:00
parent 4f3ec31501
commit 8a7addafd7
4 changed files with 110 additions and 32 deletions

View File

@@ -4137,6 +4137,45 @@ export class TradingClient extends AuthorizedApiBase {
}
return Promise.resolve<FileResponse>(null as any);
}
trading_RefineIndicators(request: RefineIndicatorsRequest): Promise<RefineIndicatorsResponse> {
let url_ = this.baseUrl + "/Trading/RefineIndicators";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(request);
let options_: RequestInit = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response: Response) => {
return this.processTrading_RefineIndicators(_response);
});
}
protected processTrading_RefineIndicators(response: Response): Promise<RefineIndicatorsResponse> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver) as RefineIndicatorsResponse;
return result200;
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<RefineIndicatorsResponse>(null as any);
}
}
export class UserClient extends AuthorizedApiBase {
@@ -5972,6 +6011,19 @@ export interface IndicatorRequestDto {
requesterName: string;
}
export interface RefineIndicatorsResponse {
indicatorsValues?: { [key in keyof typeof IndicatorType]?: IndicatorsResultBase; } | null;
signals?: LightSignal[] | null;
}
export interface RefineIndicatorsRequest {
ticker: Ticker;
timeframe: Timeframe;
startDate: Date;
endDate: Date;
indicators: IndicatorRequest[];
}
export interface LoginRequest {
name: string;
address: string;

View File

@@ -1469,6 +1469,19 @@ export interface IndicatorRequestDto {
requesterName: string;
}
export interface RefineIndicatorsResponse {
indicatorsValues?: { [key in keyof typeof IndicatorType]?: IndicatorsResultBase; } | null;
signals?: LightSignal[] | null;
}
export interface RefineIndicatorsRequest {
ticker: Ticker;
timeframe: Timeframe;
startDate: Date;
endDate: Date;
indicators: IndicatorRequest[];
}
export interface LoginRequest {
name: string;
address: string;