//----------------------
// <auto-generated>
//     Generated using the NSwag toolchain v14.3.0.0 (NJsonSchema v11.2.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------

/* tslint:disable */
/* eslint-disable */
// ReSharper disable InconsistentNaming

export class AccountClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    account_PostAccount(account: Account): Promise<Account> {
        let url_ = this.baseUrl + "/Account";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(account);

        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.processAccount_PostAccount(_response);
        });
    }

    protected processAccount_PostAccount(response: Response): Promise<Account> {
        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 Account;
            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<Account>(null as any);
    }

    account_GetAccount(name: string | null | undefined): Promise<Account> {
        let url_ = this.baseUrl + "/Account?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processAccount_GetAccount(_response);
        });
    }

    protected processAccount_GetAccount(response: Response): Promise<Account> {
        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 Account;
            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<Account>(null as any);
    }

    account_DeleteAccount(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Account?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processAccount_DeleteAccount(_response);
        });
    }

    protected processAccount_DeleteAccount(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    account_GetAccounts(): Promise<Account[]> {
        let url_ = this.baseUrl + "/Account/accounts";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processAccount_GetAccounts(_response);
        });
    }

    protected processAccount_GetAccounts(response: Response): Promise<Account[]> {
        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 Account[];
            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<Account[]>(null as any);
    }

    account_GetAccountsBalances(): Promise<Account[]> {
        let url_ = this.baseUrl + "/Account/balances";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processAccount_GetAccountsBalances(_response);
        });
    }

    protected processAccount_GetAccountsBalances(response: Response): Promise<Account[]> {
        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 Account[];
            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<Account[]>(null as any);
    }
}

export class BacktestClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    backtest_Backtests(): Promise<Backtest[]> {
        let url_ = this.baseUrl + "/Backtest";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBacktest_Backtests(_response);
        });
    }

    protected processBacktest_Backtests(response: Response): Promise<Backtest[]> {
        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 Backtest[];
            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<Backtest[]>(null as any);
    }

    backtest_DeleteBacktest(id: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest?";
        if (id !== undefined && id !== null)
            url_ += "id=" + encodeURIComponent("" + id) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBacktest_DeleteBacktest(_response);
        });
    }

    protected processBacktest_DeleteBacktest(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    backtest_Backtest(id: string): Promise<Backtest> {
        let url_ = this.baseUrl + "/Backtest/{id}";
        if (id === undefined || id === null)
            throw new Error("The parameter 'id' must be defined.");
        url_ = url_.replace("{id}", encodeURIComponent("" + id));
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBacktest_Backtest(_response);
        });
    }

    protected processBacktest_Backtest(response: Response): Promise<Backtest> {
        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 Backtest;
            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<Backtest>(null as any);
    }

    backtest_Run(accountName: string | null | undefined, botType: BotType | undefined, ticker: Ticker | undefined, scenarioName: string | null | undefined, timeframe: Timeframe | undefined, watchOnly: boolean | undefined, balance: number | undefined, moneyManagementName: string | null | undefined, startDate: Date | undefined, endDate: Date | undefined, save: boolean | undefined, cooldownPeriod: number | undefined, maxLossStreak: number | undefined, moneyManagement: MoneyManagement | undefined): Promise<Backtest> {
        let url_ = this.baseUrl + "/Backtest/Run?";
        if (accountName !== undefined && accountName !== null)
            url_ += "accountName=" + encodeURIComponent("" + accountName) + "&";
        if (botType === null)
            throw new Error("The parameter 'botType' cannot be null.");
        else if (botType !== undefined)
            url_ += "botType=" + encodeURIComponent("" + botType) + "&";
        if (ticker === null)
            throw new Error("The parameter 'ticker' cannot be null.");
        else if (ticker !== undefined)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        if (scenarioName !== undefined && scenarioName !== null)
            url_ += "scenarioName=" + encodeURIComponent("" + scenarioName) + "&";
        if (timeframe === null)
            throw new Error("The parameter 'timeframe' cannot be null.");
        else if (timeframe !== undefined)
            url_ += "timeframe=" + encodeURIComponent("" + timeframe) + "&";
        if (watchOnly === null)
            throw new Error("The parameter 'watchOnly' cannot be null.");
        else if (watchOnly !== undefined)
            url_ += "watchOnly=" + encodeURIComponent("" + watchOnly) + "&";
        if (balance === null)
            throw new Error("The parameter 'balance' cannot be null.");
        else if (balance !== undefined)
            url_ += "balance=" + encodeURIComponent("" + balance) + "&";
        if (moneyManagementName !== undefined && moneyManagementName !== null)
            url_ += "moneyManagementName=" + encodeURIComponent("" + moneyManagementName) + "&";
        if (startDate === null)
            throw new Error("The parameter 'startDate' cannot be null.");
        else if (startDate !== undefined)
            url_ += "startDate=" + encodeURIComponent(startDate ? "" + startDate.toISOString() : "") + "&";
        if (endDate === null)
            throw new Error("The parameter 'endDate' cannot be null.");
        else if (endDate !== undefined)
            url_ += "endDate=" + encodeURIComponent(endDate ? "" + endDate.toISOString() : "") + "&";
        if (save === null)
            throw new Error("The parameter 'save' cannot be null.");
        else if (save !== undefined)
            url_ += "save=" + encodeURIComponent("" + save) + "&";
        if (cooldownPeriod === null)
            throw new Error("The parameter 'cooldownPeriod' cannot be null.");
        else if (cooldownPeriod !== undefined)
            url_ += "cooldownPeriod=" + encodeURIComponent("" + cooldownPeriod) + "&";
        if (maxLossStreak === null)
            throw new Error("The parameter 'maxLossStreak' cannot be null.");
        else if (maxLossStreak !== undefined)
            url_ += "maxLossStreak=" + encodeURIComponent("" + maxLossStreak) + "&";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(moneyManagement);

        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.processBacktest_Run(_response);
        });
    }

    protected processBacktest_Run(response: Response): Promise<Backtest> {
        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 Backtest;
            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<Backtest>(null as any);
    }
}

export class BotClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    bot_Start(request: StartBotRequest): Promise<string> {
        let url_ = this.baseUrl + "/Bot/Start";
        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_Start(_response);
        });
    }

    protected processBot_Start(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_Stop(botType: BotType | undefined, botName: string | null | undefined): Promise<string> {
        let url_ = this.baseUrl + "/Bot/Stop?";
        if (botType === null)
            throw new Error("The parameter 'botType' cannot be null.");
        else if (botType !== undefined)
            url_ += "botType=" + encodeURIComponent("" + botType) + "&";
        if (botName !== undefined && botName !== null)
            url_ += "botName=" + encodeURIComponent("" + botName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_Stop(_response);
        });
    }

    protected processBot_Stop(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_Delete(botName: string | null | undefined): Promise<boolean> {
        let url_ = this.baseUrl + "/Bot/Delete?";
        if (botName !== undefined && botName !== null)
            url_ += "botName=" + encodeURIComponent("" + botName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_Delete(_response);
        });
    }

    protected processBot_Delete(response: Response): Promise<boolean> {
        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 boolean;
            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<boolean>(null as any);
    }

    bot_StopAll(): Promise<string> {
        let url_ = this.baseUrl + "/Bot/stop-all";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_StopAll(_response);
        });
    }

    protected processBot_StopAll(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_Restart(botType: BotType | undefined, botName: string | null | undefined): Promise<string> {
        let url_ = this.baseUrl + "/Bot/Restart?";
        if (botType === null)
            throw new Error("The parameter 'botType' cannot be null.");
        else if (botType !== undefined)
            url_ += "botType=" + encodeURIComponent("" + botType) + "&";
        if (botName !== undefined && botName !== null)
            url_ += "botName=" + encodeURIComponent("" + botName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_Restart(_response);
        });
    }

    protected processBot_Restart(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_RestartAll(): Promise<string> {
        let url_ = this.baseUrl + "/Bot/restart-all";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_RestartAll(_response);
        });
    }

    protected processBot_RestartAll(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_ToggleIsForWatching(botName: string | null | undefined): Promise<string> {
        let url_ = this.baseUrl + "/Bot/ToggleIsForWatching?";
        if (botName !== undefined && botName !== null)
            url_ += "botName=" + encodeURIComponent("" + botName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_ToggleIsForWatching(_response);
        });
    }

    protected processBot_ToggleIsForWatching(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_GetActiveBots(): Promise<TradingBot[]> {
        let url_ = this.baseUrl + "/Bot";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processBot_GetActiveBots(_response);
        });
    }

    protected processBot_GetActiveBots(response: Response): Promise<TradingBot[]> {
        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 TradingBot[];
            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<TradingBot[]>(null as any);
    }

    bot_OpenPositionManually(request: OpenPositionManuallyRequest): Promise<Position> {
        let url_ = this.baseUrl + "/Bot/OpenPosition";
        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_OpenPositionManually(_response);
        });
    }

    protected processBot_OpenPositionManually(response: Response): Promise<Position> {
        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 Position;
            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<Position>(null as any);
    }

    bot_ClosePosition(request: ClosePositionRequest): Promise<Position> {
        let url_ = this.baseUrl + "/Bot/ClosePosition";
        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_ClosePosition(_response);
        });
    }

    protected processBot_ClosePosition(response: Response): Promise<Position> {
        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 Position;
            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<Position>(null as any);
    }
}

export class DataClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    data_GetTickers(timeframe: Timeframe | undefined): Promise<Ticker[]> {
        let url_ = this.baseUrl + "/Data/GetTickers?";
        if (timeframe === null)
            throw new Error("The parameter 'timeframe' cannot be null.");
        else if (timeframe !== undefined)
            url_ += "timeframe=" + encodeURIComponent("" + timeframe) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetTickers(_response);
        });
    }

    protected processData_GetTickers(response: Response): Promise<Ticker[]> {
        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 Ticker[];
            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<Ticker[]>(null as any);
    }

    data_GetSpotlight(): Promise<SpotlightOverview> {
        let url_ = this.baseUrl + "/Data/Spotlight";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetSpotlight(_response);
        });
    }

    protected processData_GetSpotlight(response: Response): Promise<SpotlightOverview> {
        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 SpotlightOverview;
            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<SpotlightOverview>(null as any);
    }

    data_GetCandles(exchange: TradingExchanges | undefined, ticker: Ticker | undefined, startDate: Date | undefined, timeframe: Timeframe | undefined): Promise<Candle[]> {
        let url_ = this.baseUrl + "/Data/GetCandles?";
        if (exchange === null)
            throw new Error("The parameter 'exchange' cannot be null.");
        else if (exchange !== undefined)
            url_ += "exchange=" + encodeURIComponent("" + exchange) + "&";
        if (ticker === null)
            throw new Error("The parameter 'ticker' cannot be null.");
        else if (ticker !== undefined)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        if (startDate === null)
            throw new Error("The parameter 'startDate' cannot be null.");
        else if (startDate !== undefined)
            url_ += "startDate=" + encodeURIComponent(startDate ? "" + startDate.toISOString() : "") + "&";
        if (timeframe === null)
            throw new Error("The parameter 'timeframe' cannot be null.");
        else if (timeframe !== undefined)
            url_ += "timeframe=" + encodeURIComponent("" + timeframe) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetCandles(_response);
        });
    }

    protected processData_GetCandles(response: Response): Promise<Candle[]> {
        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 Candle[];
            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<Candle[]>(null as any);
    }

    data_GetStrategiesStatistics(): Promise<StrategiesStatisticsViewModel> {
        let url_ = this.baseUrl + "/Data/GetStrategiesStatistics";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetStrategiesStatistics(_response);
        });
    }

    protected processData_GetStrategiesStatistics(response: Response): Promise<StrategiesStatisticsViewModel> {
        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 StrategiesStatisticsViewModel;
            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<StrategiesStatisticsViewModel>(null as any);
    }

    data_GetTopStrategies(): Promise<TopStrategiesViewModel> {
        let url_ = this.baseUrl + "/Data/GetTopStrategies";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetTopStrategies(_response);
        });
    }

    protected processData_GetTopStrategies(response: Response): Promise<TopStrategiesViewModel> {
        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 TopStrategiesViewModel;
            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<TopStrategiesViewModel>(null as any);
    }

    data_GetUserStrategies(agentName: string | null | undefined): Promise<UserStrategyDetailsViewModel[]> {
        let url_ = this.baseUrl + "/Data/GetUserStrategies?";
        if (agentName !== undefined && agentName !== null)
            url_ += "agentName=" + encodeURIComponent("" + agentName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetUserStrategies(_response);
        });
    }

    protected processData_GetUserStrategies(response: Response): Promise<UserStrategyDetailsViewModel[]> {
        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 UserStrategyDetailsViewModel[];
            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<UserStrategyDetailsViewModel[]>(null as any);
    }

    data_GetUserStrategy(agentName: string | null | undefined, strategyName: string | null | undefined): Promise<UserStrategyDetailsViewModel> {
        let url_ = this.baseUrl + "/Data/GetUserStrategy?";
        if (agentName !== undefined && agentName !== null)
            url_ += "agentName=" + encodeURIComponent("" + agentName) + "&";
        if (strategyName !== undefined && strategyName !== null)
            url_ += "strategyName=" + encodeURIComponent("" + strategyName) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetUserStrategy(_response);
        });
    }

    protected processData_GetUserStrategy(response: Response): Promise<UserStrategyDetailsViewModel> {
        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 UserStrategyDetailsViewModel;
            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<UserStrategyDetailsViewModel>(null as any);
    }

    data_GetPlatformSummary(timeFilter: string | null | undefined): Promise<PlatformSummaryViewModel> {
        let url_ = this.baseUrl + "/Data/GetPlatformSummary?";
        if (timeFilter !== undefined && timeFilter !== null)
            url_ += "timeFilter=" + encodeURIComponent("" + timeFilter) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processData_GetPlatformSummary(_response);
        });
    }

    protected processData_GetPlatformSummary(response: Response): Promise<PlatformSummaryViewModel> {
        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 PlatformSummaryViewModel;
            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<PlatformSummaryViewModel>(null as any);
    }
}

export class MoneyManagementClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    moneyManagement_PostMoneyManagement(moneyManagement: MoneyManagement): Promise<MoneyManagement> {
        let url_ = this.baseUrl + "/MoneyManagement";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(moneyManagement);

        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.processMoneyManagement_PostMoneyManagement(_response);
        });
    }

    protected processMoneyManagement_PostMoneyManagement(response: Response): Promise<MoneyManagement> {
        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 MoneyManagement;
            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<MoneyManagement>(null as any);
    }

    moneyManagement_GetMoneyManagement(name: string | null | undefined): Promise<MoneyManagement> {
        let url_ = this.baseUrl + "/MoneyManagement?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processMoneyManagement_GetMoneyManagement(_response);
        });
    }

    protected processMoneyManagement_GetMoneyManagement(response: Response): Promise<MoneyManagement> {
        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 MoneyManagement;
            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<MoneyManagement>(null as any);
    }

    moneyManagement_DeleteMoneyManagement(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/MoneyManagement?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processMoneyManagement_DeleteMoneyManagement(_response);
        });
    }

    protected processMoneyManagement_DeleteMoneyManagement(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    moneyManagement_GetMoneyManagements(): Promise<MoneyManagement[]> {
        let url_ = this.baseUrl + "/MoneyManagement/moneymanagements";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processMoneyManagement_GetMoneyManagements(_response);
        });
    }

    protected processMoneyManagement_GetMoneyManagements(response: Response): Promise<MoneyManagement[]> {
        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 MoneyManagement[];
            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<MoneyManagement[]>(null as any);
    }
}

export class ScenarioClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    scenario_GetScenarios(): Promise<Scenario[]> {
        let url_ = this.baseUrl + "/Scenario";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_GetScenarios(_response);
        });
    }

    protected processScenario_GetScenarios(response: Response): Promise<Scenario[]> {
        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 Scenario[];
            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<Scenario[]>(null as any);
    }

    scenario_CreateScenario(name: string | null | undefined, loopbackPeriod: number | null | undefined, strategies: string[]): Promise<Scenario> {
        let url_ = this.baseUrl + "/Scenario?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (loopbackPeriod !== undefined && loopbackPeriod !== null)
            url_ += "loopbackPeriod=" + encodeURIComponent("" + loopbackPeriod) + "&";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(strategies);

        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.processScenario_CreateScenario(_response);
        });
    }

    protected processScenario_CreateScenario(response: Response): Promise<Scenario> {
        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 Scenario;
            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<Scenario>(null as any);
    }

    scenario_DeleteScenario(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Scenario?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_DeleteScenario(_response);
        });
    }

    protected processScenario_DeleteScenario(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    scenario_UpdateScenario(name: string | null | undefined, loopbackPeriod: number | null | undefined, strategies: string[]): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Scenario?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (loopbackPeriod !== undefined && loopbackPeriod !== null)
            url_ += "loopbackPeriod=" + encodeURIComponent("" + loopbackPeriod) + "&";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(strategies);

        let options_: RequestInit = {
            body: content_,
            method: "PUT",
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_UpdateScenario(_response);
        });
    }

    protected processScenario_UpdateScenario(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    scenario_GetStrategies(): Promise<Strategy[]> {
        let url_ = this.baseUrl + "/Scenario/strategy";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_GetStrategies(_response);
        });
    }

    protected processScenario_GetStrategies(response: Response): Promise<Strategy[]> {
        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 Strategy[];
            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<Strategy[]>(null as any);
    }

    scenario_CreateStrategy(strategyType: StrategyType | undefined, name: string | null | undefined, period: number | null | undefined, fastPeriods: number | null | undefined, slowPeriods: number | null | undefined, signalPeriods: number | null | undefined, multiplier: number | null | undefined, stochPeriods: number | null | undefined, smoothPeriods: number | null | undefined, cyclePeriods: number | null | undefined): Promise<Strategy> {
        let url_ = this.baseUrl + "/Scenario/strategy?";
        if (strategyType === null)
            throw new Error("The parameter 'strategyType' cannot be null.");
        else if (strategyType !== undefined)
            url_ += "strategyType=" + encodeURIComponent("" + strategyType) + "&";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (period !== undefined && period !== null)
            url_ += "period=" + encodeURIComponent("" + period) + "&";
        if (fastPeriods !== undefined && fastPeriods !== null)
            url_ += "fastPeriods=" + encodeURIComponent("" + fastPeriods) + "&";
        if (slowPeriods !== undefined && slowPeriods !== null)
            url_ += "slowPeriods=" + encodeURIComponent("" + slowPeriods) + "&";
        if (signalPeriods !== undefined && signalPeriods !== null)
            url_ += "signalPeriods=" + encodeURIComponent("" + signalPeriods) + "&";
        if (multiplier !== undefined && multiplier !== null)
            url_ += "multiplier=" + encodeURIComponent("" + multiplier) + "&";
        if (stochPeriods !== undefined && stochPeriods !== null)
            url_ += "stochPeriods=" + encodeURIComponent("" + stochPeriods) + "&";
        if (smoothPeriods !== undefined && smoothPeriods !== null)
            url_ += "smoothPeriods=" + encodeURIComponent("" + smoothPeriods) + "&";
        if (cyclePeriods !== undefined && cyclePeriods !== null)
            url_ += "cyclePeriods=" + encodeURIComponent("" + cyclePeriods) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_CreateStrategy(_response);
        });
    }

    protected processScenario_CreateStrategy(response: Response): Promise<Strategy> {
        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 Strategy;
            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<Strategy>(null as any);
    }

    scenario_DeleteStrategy(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Scenario/strategy?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_DeleteStrategy(_response);
        });
    }

    protected processScenario_DeleteStrategy(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    scenario_UpdateStrategy(strategyType: StrategyType | undefined, name: string | null | undefined, period: number | null | undefined, fastPeriods: number | null | undefined, slowPeriods: number | null | undefined, signalPeriods: number | null | undefined, multiplier: number | null | undefined, stochPeriods: number | null | undefined, smoothPeriods: number | null | undefined, cyclePeriods: number | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Scenario/strategy?";
        if (strategyType === null)
            throw new Error("The parameter 'strategyType' cannot be null.");
        else if (strategyType !== undefined)
            url_ += "strategyType=" + encodeURIComponent("" + strategyType) + "&";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (period !== undefined && period !== null)
            url_ += "period=" + encodeURIComponent("" + period) + "&";
        if (fastPeriods !== undefined && fastPeriods !== null)
            url_ += "fastPeriods=" + encodeURIComponent("" + fastPeriods) + "&";
        if (slowPeriods !== undefined && slowPeriods !== null)
            url_ += "slowPeriods=" + encodeURIComponent("" + slowPeriods) + "&";
        if (signalPeriods !== undefined && signalPeriods !== null)
            url_ += "signalPeriods=" + encodeURIComponent("" + signalPeriods) + "&";
        if (multiplier !== undefined && multiplier !== null)
            url_ += "multiplier=" + encodeURIComponent("" + multiplier) + "&";
        if (stochPeriods !== undefined && stochPeriods !== null)
            url_ += "stochPeriods=" + encodeURIComponent("" + stochPeriods) + "&";
        if (smoothPeriods !== undefined && smoothPeriods !== null)
            url_ += "smoothPeriods=" + encodeURIComponent("" + smoothPeriods) + "&";
        if (cyclePeriods !== undefined && cyclePeriods !== null)
            url_ += "cyclePeriods=" + encodeURIComponent("" + cyclePeriods) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "PUT",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processScenario_UpdateStrategy(_response);
        });
    }

    protected processScenario_UpdateStrategy(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }
}

export class SentryTestClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    sentryTest_TestException(): Promise<FileResponse> {
        let url_ = this.baseUrl + "/api/SentryTest/test-exception";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSentryTest_TestException(_response);
        });
    }

    protected processSentryTest_TestException(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    sentryTest_ThrowException(): Promise<FileResponse> {
        let url_ = this.baseUrl + "/api/SentryTest/throw-exception";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSentryTest_ThrowException(_response);
        });
    }

    protected processSentryTest_ThrowException(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    sentryTest_TestMessage(): Promise<FileResponse> {
        let url_ = this.baseUrl + "/api/SentryTest/test-message";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSentryTest_TestMessage(_response);
        });
    }

    protected processSentryTest_TestMessage(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }
}

export class SettingsClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    settings_SetupSettings(): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Settings";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSettings_SetupSettings(_response);
        });
    }

    protected processSettings_SetupSettings(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    settings_ResetSettings(): Promise<boolean> {
        let url_ = this.baseUrl + "/Settings";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSettings_ResetSettings(_response);
        });
    }

    protected processSettings_ResetSettings(response: Response): Promise<boolean> {
        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 boolean;
            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<boolean>(null as any);
    }

    settings_CreateDefaultConfiguration(): Promise<boolean> {
        let url_ = this.baseUrl + "/Settings/create-default-config";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processSettings_CreateDefaultConfiguration(_response);
        });
    }

    protected processSettings_CreateDefaultConfiguration(response: Response): Promise<boolean> {
        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 boolean;
            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<boolean>(null as any);
    }
}

export class TradingClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    trading_GetPositions(positionInitiator: PositionInitiator | undefined): Promise<Position[]> {
        let url_ = this.baseUrl + "/Trading/GetPositions?";
        if (positionInitiator === null)
            throw new Error("The parameter 'positionInitiator' cannot be null.");
        else if (positionInitiator !== undefined)
            url_ += "positionInitiator=" + encodeURIComponent("" + positionInitiator) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processTrading_GetPositions(_response);
        });
    }

    protected processTrading_GetPositions(response: Response): Promise<Position[]> {
        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 Position[];
            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<Position[]>(null as any);
    }

    trading_GetTrade(accountName: string | null | undefined, ticker: Ticker | undefined, exchangeOrderId: string | null | undefined): Promise<Trade> {
        let url_ = this.baseUrl + "/Trading/GetTrade?";
        if (accountName !== undefined && accountName !== null)
            url_ += "accountName=" + encodeURIComponent("" + accountName) + "&";
        if (ticker === null)
            throw new Error("The parameter 'ticker' cannot be null.");
        else if (ticker !== undefined)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        if (exchangeOrderId !== undefined && exchangeOrderId !== null)
            url_ += "exchangeOrderId=" + encodeURIComponent("" + exchangeOrderId) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processTrading_GetTrade(_response);
        });
    }

    protected processTrading_GetTrade(response: Response): Promise<Trade> {
        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 Trade;
            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<Trade>(null as any);
    }

    trading_GetTrades(accountName: string | null | undefined, ticker: Ticker | undefined): Promise<Trade> {
        let url_ = this.baseUrl + "/Trading/GetTrades?";
        if (accountName !== undefined && accountName !== null)
            url_ += "accountName=" + encodeURIComponent("" + accountName) + "&";
        if (ticker === null)
            throw new Error("The parameter 'ticker' cannot be null.");
        else if (ticker !== undefined)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processTrading_GetTrades(_response);
        });
    }

    protected processTrading_GetTrades(response: Response): Promise<Trade> {
        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 Trade;
            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<Trade>(null as any);
    }

    trading_ClosePosition(identifier: string | null | undefined): Promise<Position> {
        let url_ = this.baseUrl + "/Trading/ClosePosition?";
        if (identifier !== undefined && identifier !== null)
            url_ += "identifier=" + encodeURIComponent("" + identifier) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "POST",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processTrading_ClosePosition(_response);
        });
    }

    protected processTrading_ClosePosition(response: Response): Promise<Position> {
        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 Position;
            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<Position>(null as any);
    }

    trading_Trade(accountName: string | null | undefined, moneyManagementName: string | null | undefined, direction: TradeDirection | undefined, ticker: Ticker | undefined, riskLevel: RiskLevel | undefined, isForPaperTrading: boolean | undefined, openPrice: number | null | undefined, moneyManagement: MoneyManagement | undefined): Promise<Position> {
        let url_ = this.baseUrl + "/Trading/OpenPosition?";
        if (accountName !== undefined && accountName !== null)
            url_ += "accountName=" + encodeURIComponent("" + accountName) + "&";
        if (moneyManagementName !== undefined && moneyManagementName !== null)
            url_ += "moneyManagementName=" + encodeURIComponent("" + moneyManagementName) + "&";
        if (direction === null)
            throw new Error("The parameter 'direction' cannot be null.");
        else if (direction !== undefined)
            url_ += "direction=" + encodeURIComponent("" + direction) + "&";
        if (ticker === null)
            throw new Error("The parameter 'ticker' cannot be null.");
        else if (ticker !== undefined)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        if (riskLevel === null)
            throw new Error("The parameter 'riskLevel' cannot be null.");
        else if (riskLevel !== undefined)
            url_ += "riskLevel=" + encodeURIComponent("" + riskLevel) + "&";
        if (isForPaperTrading === null)
            throw new Error("The parameter 'isForPaperTrading' cannot be null.");
        else if (isForPaperTrading !== undefined)
            url_ += "isForPaperTrading=" + encodeURIComponent("" + isForPaperTrading) + "&";
        if (openPrice !== undefined && openPrice !== null)
            url_ += "openPrice=" + encodeURIComponent("" + openPrice) + "&";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(moneyManagement);

        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_Trade(_response);
        });
    }

    protected processTrading_Trade(response: Response): Promise<Position> {
        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 Position;
            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<Position>(null as any);
    }
}

export class UserClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    user_CreateToken(login: LoginRequest): Promise<string> {
        let url_ = this.baseUrl + "/User";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(login);

        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.processUser_CreateToken(_response);
        });
    }

    protected processUser_CreateToken(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);
    }

    user_UpdateAgentName(agentName: string): Promise<User> {
        let url_ = this.baseUrl + "/User/agent-name";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(agentName);

        let options_: RequestInit = {
            body: content_,
            method: "PUT",
            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.processUser_UpdateAgentName(_response);
        });
    }

    protected processUser_UpdateAgentName(response: Response): Promise<User> {
        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 User;
            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<User>(null as any);
    }
}

export class WorkflowClient extends AuthorizedApiBase {
    private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
    private baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(configuration: IConfig, baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
        super(configuration);
        this.http = http ? http : window as any;
        this.baseUrl = baseUrl ?? "http://localhost:5000";
    }

    workflow_PostWorkflow(workflowRequest: SyntheticWorkflow): Promise<Workflow> {
        let url_ = this.baseUrl + "/Workflow";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(workflowRequest);

        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.processWorkflow_PostWorkflow(_response);
        });
    }

    protected processWorkflow_PostWorkflow(response: Response): Promise<Workflow> {
        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 Workflow;
            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<Workflow>(null as any);
    }

    workflow_GetWorkflows(): Promise<SyntheticWorkflow[]> {
        let url_ = this.baseUrl + "/Workflow";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processWorkflow_GetWorkflows(_response);
        });
    }

    protected processWorkflow_GetWorkflows(response: Response): Promise<SyntheticWorkflow[]> {
        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 SyntheticWorkflow[];
            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<SyntheticWorkflow[]>(null as any);
    }

    workflow_DeleteWorkflow(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Workflow?";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processWorkflow_DeleteWorkflow(_response);
        });
    }

    protected processWorkflow_DeleteWorkflow(response: Response): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
            let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
            let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
            if (fileName) {
                fileName = decodeURIComponent(fileName);
            } else {
                fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
                fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
            }
            return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
        } else if (status !== 200 && status !== 204) {
            return response.text().then((_responseText) => {
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
            });
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    workflow_GetAvailableFlows(): Promise<IFlow[]> {
        let url_ = this.baseUrl + "/Workflow/flows";
        url_ = url_.replace(/[?&]$/, "");

        let options_: RequestInit = {
            method: "GET",
            headers: {
                "Accept": "application/json"
            }
        };

        return this.transformOptions(options_).then(transformedOptions_ => {
            return this.http.fetch(url_, transformedOptions_);
        }).then((_response: Response) => {
            return this.processWorkflow_GetAvailableFlows(_response);
        });
    }

    protected processWorkflow_GetAvailableFlows(response: Response): Promise<IFlow[]> {
        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 IFlow[];
            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<IFlow[]>(null as any);
    }
}

export interface Account {
    name: string;
    exchange: TradingExchanges;
    type: AccountType;
    key?: string | null;
    secret?: string | null;
    user?: User | null;
    balances?: Balance[] | null;
    isPrivyWallet?: boolean;
}

export enum TradingExchanges {
    Binance = "Binance",
    Kraken = "Kraken",
    Ftx = "Ftx",
    Evm = "Evm",
    GmxV2 = "GmxV2",
}

export enum AccountType {
    Cex = "Cex",
    Trader = "Trader",
    Watch = "Watch",
    Auth = "Auth",
    Privy = "Privy",
}

export interface User {
    name?: string | null;
    accounts?: Account[] | null;
    agentName?: string | null;
}

export interface Balance {
    tokenImage?: string | null;
    tokenName?: string | null;
    amount?: number;
    price?: number;
    value?: number;
    tokenAdress?: string | null;
    chain?: Chain | null;
}

export interface Chain {
    id?: string | null;
    rpcUrl?: string | null;
    name?: string | null;
    chainId?: number;
}

export interface Backtest {
    id: string;
    finalPnl: number;
    winRate: number;
    growthPercentage: number;
    hodlPercentage: number;
    ticker: Ticker;
    scenario: string;
    positions: Position[];
    signals: Signal[];
    timeframe: Timeframe;
    botType: BotType;
    accountName: string;
    candles: Candle[];
    startDate: Date;
    endDate: Date;
    statistics: PerformanceMetrics;
    fees: number;
    walletBalances: KeyValuePairOfDateTimeAndDecimal[];
    optimizedMoneyManagement: MoneyManagement;
    moneyManagement: MoneyManagement;
    user: User;
    strategiesValues: { [key in keyof typeof StrategyType]?: StrategiesResultBase; };
    score: number;
}

export enum Ticker {
    AAVE = "AAVE",
    ADA = "ADA",
    APE = "APE",
    ALGO = "ALGO",
    ARB = "ARB",
    ATOM = "ATOM",
    AVAX = "AVAX",
    BNB = "BNB",
    BTC = "BTC",
    BAL = "BAL",
    CHZ = "CHZ",
    COMP = "COMP",
    CRO = "CRO",
    CRV = "CRV",
    DOGE = "DOGE",
    DOT = "DOT",
    DYDX = "DYDX",
    ENS = "ENS",
    ETC = "ETC",
    ETH = "ETH",
    FIL = "FIL",
    FLM = "FLM",
    FTM = "FTM",
    GALA = "GALA",
    GMX = "GMX",
    GRT = "GRT",
    IMX = "IMX",
    JASMY = "JASMY",
    KSM = "KSM",
    LDO = "LDO",
    LINK = "LINK",
    LRC = "LRC",
    LTC = "LTC",
    MANA = "MANA",
    MATIC = "MATIC",
    MKR = "MKR",
    NEAR = "NEAR",
    OP = "OP",
    PEPE = "PEPE",
    QTUM = "QTUM",
    REN = "REN",
    ROSE = "ROSE",
    RSR = "RSR",
    RUNE = "RUNE",
    SAND = "SAND",
    SOL = "SOL",
    SRM = "SRM",
    SUSHI = "SUSHI",
    THETA = "THETA",
    UNI = "UNI",
    USDC = "USDC",
    USDT = "USDT",
    WIF = "WIF",
    XMR = "XMR",
    XRP = "XRP",
    XTZ = "XTZ",
    SHIB = "SHIB",
    STX = "STX",
    ORDI = "ORDI",
    APT = "APT",
    BOME = "BOME",
    MEME = "MEME",
    FLOKI = "FLOKI",
    MEW = "MEW",
    TAO = "TAO",
    BONK = "BONK",
    WLD = "WLD",
    TBTC = "tBTC",
    WBTC_b = "WBTC_b",
    EIGEN = "EIGEN",
    SUI = "SUI",
    SEI = "SEI",
    USDC_e = "USDC_e",
    DAI = "DAI",
    TIA = "TIA",
    TRX = "TRX",
    TON = "TON",
    PENDLE = "PENDLE",
    WstETH = "wstETH",
    USDe = "USDe",
    SATS = "SATS",
    POL = "POL",
    XLM = "XLM",
    BCH = "BCH",
    ICP = "ICP",
    RENDER = "RENDER",
    INJ = "INJ",
    TRUMP = "TRUMP",
    MELANIA = "MELANIA",
    ENA = "ENA",
    FARTCOIN = "FARTCOIN",
    AI16Z = "AI16Z",
    ANIME = "ANIME",
    BERA = "BERA",
    VIRTUAL = "VIRTUAL",
    PENGU = "PENGU",
    ONDO = "ONDO",
    FET = "FET",
    AIXBT = "AIXBT",
    CAKE = "CAKE",
    S = "S",
    JUP = "JUP",
    HYPE = "HYPE",
    OM = "OM",
    DOLO = "DOLO",
    Unknown = "Unknown",
}

export interface Position {
    accountName: string;
    date: Date;
    originDirection: TradeDirection;
    ticker: Ticker;
    moneyManagement: MoneyManagement;
    open: Trade;
    stopLoss: Trade;
    takeProfit1: Trade;
    takeProfit2?: Trade | null;
    profitAndLoss?: ProfitAndLoss | null;
    status: PositionStatus;
    signalIdentifier?: string | null;
    identifier: string;
    initiator: PositionInitiator;
    user: User;
}

export enum TradeDirection {
    None = "None",
    Short = "Short",
    Long = "Long",
}

export interface MoneyManagement {
    name: string;
    timeframe: Timeframe;
    stopLoss: number;
    takeProfit: number;
    leverage: number;
    user?: User | null;
}

export enum Timeframe {
    FiveMinutes = "FiveMinutes",
    FifteenMinutes = "FifteenMinutes",
    ThirtyMinutes = "ThirtyMinutes",
    OneHour = "OneHour",
    FourHour = "FourHour",
    OneDay = "OneDay",
    OneMinute = "OneMinute",
}

export interface Trade {
    fee?: number;
    date: Date;
    direction: TradeDirection;
    status: TradeStatus;
    tradeType: TradeType;
    ticker: Ticker;
    quantity: number;
    price: number;
    leverage?: number;
    exchangeOrderId: string;
    message?: string | null;
}

export enum TradeStatus {
    PendingOpen = "PendingOpen",
    Requested = "Requested",
    Cancelled = "Cancelled",
    Filled = "Filled",
}

export enum TradeType {
    Limit = "Limit",
    Market = "Market",
    StopMarket = "StopMarket",
    StopLimit = "StopLimit",
    StopLoss = "StopLoss",
    TakeProfit = "TakeProfit",
    StopLossProfit = "StopLossProfit",
    StopLossProfitLimit = "StopLossProfitLimit",
    StopLossLimit = "StopLossLimit",
    TakeProfitLimit = "TakeProfitLimit",
    TrailingStop = "TrailingStop",
    TrailingStopLimit = "TrailingStopLimit",
    StopLossAndLimit = "StopLossAndLimit",
    SettlePosition = "SettlePosition",
}

export interface ProfitAndLoss {
    realized?: number;
    net?: number;
    averageOpenPrice?: number;
}

export enum PositionStatus {
    New = "New",
    Canceled = "Canceled",
    Rejected = "Rejected",
    Updating = "Updating",
    PartiallyFilled = "PartiallyFilled",
    Filled = "Filled",
    Flipped = "Flipped",
    Finished = "Finished",
}

export enum PositionInitiator {
    PaperTrading = "PaperTrading",
    Bot = "Bot",
    User = "User",
    CopyTrading = "CopyTrading",
}

export interface ValueObject {
}

export interface Signal extends ValueObject {
    status: SignalStatus;
    direction: TradeDirection;
    confidence: Confidence;
    timeframe: Timeframe;
    date: Date;
    candle: Candle;
    identifier: string;
    ticker: Ticker;
    exchange: TradingExchanges;
    strategyType: StrategyType;
    signalType: SignalType;
    user?: User | null;
}

export enum SignalStatus {
    WaitingForPosition = "WaitingForPosition",
    PositionOpen = "PositionOpen",
    Expired = "Expired",
}

export enum Confidence {
    Low = "Low",
    Medium = "Medium",
    High = "High",
    None = "None",
}

export interface Candle {
    exchange: TradingExchanges;
    ticker: string;
    openTime: Date;
    date: Date;
    open: number;
    close: number;
    volume?: number;
    high: number;
    low: number;
    baseVolume?: number;
    quoteVolume?: number;
    tradeCount?: number;
    takerBuyBaseVolume?: number;
    takerBuyQuoteVolume?: number;
    timeframe: Timeframe;
}

export enum StrategyType {
    RsiDivergence = "RsiDivergence",
    RsiDivergenceConfirm = "RsiDivergenceConfirm",
    MacdCross = "MacdCross",
    EmaCross = "EmaCross",
    ThreeWhiteSoldiers = "ThreeWhiteSoldiers",
    SuperTrend = "SuperTrend",
    ChandelierExit = "ChandelierExit",
    EmaTrend = "EmaTrend",
    Composite = "Composite",
    StochRsiTrend = "StochRsiTrend",
    Stc = "Stc",
    StDev = "StDev",
    LaggingStc = "LaggingStc",
    SuperTrendCrossEma = "SuperTrendCrossEma",
}

export enum SignalType {
    Signal = "Signal",
    Trend = "Trend",
    Context = "Context",
}

export enum BotType {
    SimpleBot = "SimpleBot",
    ScalpingBot = "ScalpingBot",
    FlippingBot = "FlippingBot",
}

export interface PerformanceMetrics {
    count?: number;
    sharpeRatio?: number;
    maxDrawdown?: number;
    maxDrawdownPc?: number;
    maxDrawdownRecoveryTime?: string;
    winningTrades?: number;
    loosingTrades?: number;
    totalPnL?: number;
}

export interface KeyValuePairOfDateTimeAndDecimal {
    key?: Date;
    value?: number;
}

export interface StrategiesResultBase {
    ema?: EmaResult[] | null;
    macd?: MacdResult[] | null;
    rsi?: RsiResult[] | null;
    stoch?: StochResult[] | null;
    stochRsi?: StochRsiResult[] | null;
    bollingerBands?: BollingerBandsResult[] | null;
    chandelierShort?: ChandelierResult[] | null;
    stc?: StcResult[] | null;
    stdDev?: StdDevResult[] | null;
    superTrend?: SuperTrendResult[] | null;
    chandelierLong?: ChandelierResult[] | null;
}

export interface ResultBase {
    date?: Date;
}

export interface EmaResult extends ResultBase {
    ema?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface MacdResult extends ResultBase {
    macd?: number | null;
    signal?: number | null;
    histogram?: number | null;
    fastEma?: number | null;
    slowEma?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface RsiResult extends ResultBase {
    rsi?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

/** Stochastic indicator results includes aliases for those who prefer the simpler K,D,J outputs.  See  documentation  for more information. */
export interface StochResult extends ResultBase {
    oscillator?: number | null;
    signal?: number | null;
    percentJ?: number | null;
    k?: number | null;
    d?: number | null;
    j?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface StochRsiResult extends ResultBase {
    stochRsi?: number | null;
    signal?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface BollingerBandsResult extends ResultBase {
    sma?: number | null;
    upperBand?: number | null;
    lowerBand?: number | null;
    percentB?: number | null;
    zScore?: number | null;
    width?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface ChandelierResult extends ResultBase {
    chandelierExit?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface StcResult extends ResultBase {
    stc?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface StdDevResult extends ResultBase {
    stdDev?: number | null;
    mean?: number | null;
    zScore?: number | null;
    stdDevSma?: number | null;
    "skender.Stock.Indicators.IReusableResult.Value"?: number | null;
}

export interface SuperTrendResult extends ResultBase {
    superTrend?: number | null;
    upperBand?: number | null;
    lowerBand?: number | null;
}

export interface StartBotRequest {
    botType?: BotType;
    botName?: string | null;
    ticker?: Ticker;
    scenario?: string | null;
    timeframe?: Timeframe;
    accountName?: string | null;
    moneyManagementName?: string | null;
    isForWatchOnly?: boolean;
    initialTradingBalance?: number;
}

export interface TradingBot {
    name: string;
    status: string;
    signals: Signal[];
    positions: Position[];
    candles: Candle[];
    winRate: number;
    profitAndLoss: number;
    timeframe: Timeframe;
    ticker: Ticker;
    scenario: string;
    isForWatchingOnly: boolean;
    botType: BotType;
    accountName: string;
    moneyManagement: MoneyManagement;
}

export interface OpenPositionManuallyRequest {
    botName?: string | null;
    direction?: TradeDirection;
}

export interface ClosePositionRequest {
    botName?: string | null;
    positionId?: string | null;
}

export interface SpotlightOverview {
    spotlights: Spotlight[];
    dateTime: Date;
    identifier?: string;
    scenarioCount?: number;
}

export interface Spotlight {
    scenario: Scenario;
    tickerSignals: TickerSignal[];
}

export interface Scenario {
    name?: string | null;
    strategies?: Strategy[] | null;
    loopbackPeriod?: number | null;
    user?: User | null;
}

export interface Strategy {
    name?: string | null;
    type?: StrategyType;
    signalType?: SignalType;
    minimumHistory?: number;
    period?: number | null;
    fastPeriods?: number | null;
    slowPeriods?: number | null;
    signalPeriods?: number | null;
    multiplier?: number | null;
    smoothPeriods?: number | null;
    stochPeriods?: number | null;
    cyclePeriods?: number | null;
    user?: User | null;
}

export interface TickerSignal {
    ticker: Ticker;
    fiveMinutes: Signal[];
    fifteenMinutes: Signal[];
    oneHour: Signal[];
    fourHour: Signal[];
    oneDay: Signal[];
}

export interface StrategiesStatisticsViewModel {
    totalStrategiesRunning?: number;
    changeInLast24Hours?: number;
}

export interface TopStrategiesViewModel {
    topStrategies?: StrategyPerformance[] | null;
}

export interface StrategyPerformance {
    strategyName?: string | null;
    pnL?: number;
}

export interface UserStrategyDetailsViewModel {
    name?: string | null;
    strategyName?: string | null;
    state?: string | null;
    pnL?: number;
    roiPercentage?: number;
    roiLast24H?: number;
    runtime?: Date;
    winRate?: number;
    totalVolumeTraded?: number;
    volumeLast24H?: number;
    wins?: number;
    losses?: number;
    positions?: Position[] | null;
}

export interface PlatformSummaryViewModel {
    totalAgents?: number;
    totalActiveStrategies?: number;
    totalPlatformPnL?: number;
    totalPlatformVolume?: number;
    totalPlatformVolumeLast24h?: number;
    agentSummaries?: AgentSummaryViewModel[] | null;
    timeFilter?: string | null;
}

export interface AgentSummaryViewModel {
    username?: string | null;
    totalPnL?: number;
    pnLLast24h?: number;
    totalROI?: number;
    roiLast24h?: number;
    wins?: number;
    losses?: number;
    averageWinRate?: number;
    activeStrategiesCount?: number;
    totalVolume?: number;
    volumeLast24h?: number;
}

export enum RiskLevel {
    Low = "Low",
    Medium = "Medium",
    High = "High",
    Adaptive = "Adaptive",
}

export interface LoginRequest {
    name: string;
    address: string;
    signature: string;
    message: string;
}

export interface Workflow {
    name: string;
    usage: WorkflowUsage;
    flows: IFlow[];
    description: string;
}

export enum WorkflowUsage {
    Trading = "Trading",
    Task = "Task",
}

export interface IFlow {
    id: string;
    name: string;
    type: FlowType;
    description: string;
    acceptedInputs: FlowOutput[];
    children?: IFlow[] | null;
    parameters: FlowParameter[];
    parentId?: string;
    output?: string | null;
    outputTypes: FlowOutput[];
}

export enum FlowType {
    RsiDivergence = "RsiDivergence",
    FeedTicker = "FeedTicker",
    OpenPosition = "OpenPosition",
}

export enum FlowOutput {
    Signal = "Signal",
    Candles = "Candles",
    Position = "Position",
    MoneyManagement = "MoneyManagement",
}

export interface FlowParameter {
    value?: any | null;
    name?: string | null;
}

export interface SyntheticWorkflow {
    name: string;
    usage: WorkflowUsage;
    description: string;
    flows: SyntheticFlow[];
}

export interface SyntheticFlow {
    id: string;
    parentId?: string | null;
    type: FlowType;
    parameters: SyntheticFlowParameter[];
}

export interface SyntheticFlowParameter {
    value: string;
    name: string;
}

export interface FileResponse {
    data: Blob;
    status: number;
    fileName?: string;
    headers?: { [name: string]: any };
}

export class ApiException extends Error {
    override message: string;
    status: number;
    response: string;
    headers: { [key: string]: any; };
    result: any;

    constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
        super();

        this.message = message;
        this.status = status;
        this.response = response;
        this.headers = headers;
        this.result = result;
    }

    protected isApiException = true;

    static isApiException(obj: any): obj is ApiException {
        return obj.isApiException === true;
    }
}

function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
    if (result !== null && result !== undefined)
        throw result;
    else
        throw new ApiException(message, status, response, headers, null);
}