Add copy trading functionality with StartCopyTrading endpoint and related models. Implemented position copying from master bot and subscription to copy trading stream in LiveTradingBotGrain. Updated TradingBotConfig to support copy trading parameters.
This commit is contained in:
@@ -1479,6 +1479,45 @@ export class BotClient extends AuthorizedApiBase {
|
||||
return Promise.resolve<string>(null as any);
|
||||
}
|
||||
|
||||
bot_StartCopyTrading(request: StartCopyTradingRequest): Promise<string> {
|
||||
let url_ = this.baseUrl + "/Bot/StartCopyTrading";
|
||||
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.processBot_StartCopyTrading(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processBot_StartCopyTrading(response: Response): Promise<string> {
|
||||
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 string;
|
||||
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<string>(null as any);
|
||||
}
|
||||
|
||||
bot_Save(request: SaveBotRequest): Promise<string> {
|
||||
let url_ = this.baseUrl + "/Bot/Save";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
@@ -4772,6 +4811,8 @@ export interface TradingBotConfig {
|
||||
useForPositionSizing?: boolean;
|
||||
useForSignalFiltering?: boolean;
|
||||
useForDynamicStopLoss?: boolean;
|
||||
isForCopyTrading?: boolean;
|
||||
masterBotIdentifier?: string | null;
|
||||
}
|
||||
|
||||
export interface LightMoneyManagement {
|
||||
@@ -5334,6 +5375,11 @@ export interface StartBotRequest {
|
||||
config?: TradingBotConfigRequest | null;
|
||||
}
|
||||
|
||||
export interface StartCopyTradingRequest {
|
||||
masterBotIdentifier?: string;
|
||||
botTradingBalance?: number;
|
||||
}
|
||||
|
||||
export interface SaveBotRequest extends StartBotRequest {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user