//----------------------
// <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>
//----------------------

import AuthorizedApiBase from "./AuthorizedApiBase";
import IConfig from "./IConfig";

/* 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);
    }

    account_GetGmxClaimableSummary(name: string): Promise<GmxClaimableSummary> {
        let url_ = this.baseUrl + "/Account/{name}/gmx-claimable-summary";
        if (name === undefined || name === null)
            throw new Error("The parameter 'name' must be defined.");
        url_ = url_.replace("{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_GetGmxClaimableSummary(_response);
        });
    }

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

    account_SwapGmxTokens(name: string, request: SwapTokensRequest): Promise<SwapInfos> {
        let url_ = this.baseUrl + "/Account/{name}/gmx-swap";
        if (name === undefined || name === null)
            throw new Error("The parameter 'name' must be defined.");
        url_ = url_.replace("{name}", encodeURIComponent("" + name));
        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.processAccount_SwapGmxTokens(_response);
        });
    }

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

    account_SendToken(name: string, request: SendTokenRequest): Promise<SwapInfos> {
        let url_ = this.baseUrl + "/Account/{name}/send-token";
        if (name === undefined || name === null)
            throw new Error("The parameter 'name' must be defined.");
        url_ = url_.replace("{name}", encodeURIComponent("" + name));
        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.processAccount_SendToken(_response);
        });
    }

    protected processAccount_SendToken(response: Response): Promise<SwapInfos> {
        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 SwapInfos;
            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<SwapInfos>(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_Map(moneyManagementRequest: MoneyManagementRequest): Promise<MoneyManagement> {
        let url_ = this.baseUrl + "/Backtest";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(moneyManagementRequest);

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

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

    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_DeleteBacktests(request: DeleteBacktestsRequest): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest/multiple";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(request);

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

    protected processBacktest_DeleteBacktests(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_GetBacktestsByRequestId(requestId: string): Promise<Backtest[]> {
        let url_ = this.baseUrl + "/Backtest/ByRequestId/{requestId}";
        if (requestId === undefined || requestId === null)
            throw new Error("The parameter 'requestId' must be defined.");
        url_ = url_.replace("{requestId}", encodeURIComponent("" + requestId));
        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_GetBacktestsByRequestId(_response);
        });
    }

    protected processBacktest_GetBacktestsByRequestId(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_GetBacktestsByRequestIdPaginated(requestId: string, page: number | undefined, pageSize: number | undefined, sortBy: string | null | undefined, sortOrder: string | null | undefined): Promise<PaginatedBacktestsResponse> {
        let url_ = this.baseUrl + "/Backtest/ByRequestId/{requestId}/Paginated?";
        if (requestId === undefined || requestId === null)
            throw new Error("The parameter 'requestId' must be defined.");
        url_ = url_.replace("{requestId}", encodeURIComponent("" + requestId));
        if (page === null)
            throw new Error("The parameter 'page' cannot be null.");
        else if (page !== undefined)
            url_ += "page=" + encodeURIComponent("" + page) + "&";
        if (pageSize === null)
            throw new Error("The parameter 'pageSize' cannot be null.");
        else if (pageSize !== undefined)
            url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
        if (sortBy !== undefined && sortBy !== null)
            url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
        if (sortOrder !== undefined && sortOrder !== null)
            url_ += "sortOrder=" + encodeURIComponent("" + sortOrder) + "&";
        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_GetBacktestsByRequestIdPaginated(_response);
        });
    }

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

    backtest_GetBacktestsPaginated(page: number | undefined, pageSize: number | undefined, sortBy: string | null | undefined, sortOrder: string | null | undefined): Promise<PaginatedBacktestsResponse> {
        let url_ = this.baseUrl + "/Backtest/Paginated?";
        if (page === null)
            throw new Error("The parameter 'page' cannot be null.");
        else if (page !== undefined)
            url_ += "page=" + encodeURIComponent("" + page) + "&";
        if (pageSize === null)
            throw new Error("The parameter 'pageSize' cannot be null.");
        else if (pageSize !== undefined)
            url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
        if (sortBy !== undefined && sortBy !== null)
            url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
        if (sortOrder !== undefined && sortOrder !== null)
            url_ += "sortOrder=" + encodeURIComponent("" + sortOrder) + "&";
        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_GetBacktestsPaginated(_response);
        });
    }

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

    backtest_Run(request: RunBacktestRequest): Promise<LightBacktest> {
        let url_ = this.baseUrl + "/Backtest/Run";
        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.processBacktest_Run(_response);
        });
    }

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

    backtest_RunBundle(request: RunBundleBacktestRequest): Promise<BundleBacktestRequest> {
        let url_ = this.baseUrl + "/Backtest/BacktestBundle";
        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.processBacktest_RunBundle(_response);
        });
    }

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

    backtest_GetBundleBacktestRequests(): Promise<BundleBacktestRequest[]> {
        let url_ = this.baseUrl + "/Backtest/Bundle";
        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_GetBundleBacktestRequests(_response);
        });
    }

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

    backtest_GetBundleBacktestRequest(id: string): Promise<BundleBacktestRequest> {
        let url_ = this.baseUrl + "/Backtest/Bundle/{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_GetBundleBacktestRequest(_response);
        });
    }

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

    backtest_DeleteBundleBacktestRequest(id: string): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest/Bundle/{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: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

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

    protected processBacktest_DeleteBundleBacktestRequest(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_SubscribeToBundle(requestId: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest/Bundle/Subscribe?";
        if (requestId !== undefined && requestId !== null)
            url_ += "requestId=" + encodeURIComponent("" + requestId) + "&";
        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.processBacktest_SubscribeToBundle(_response);
        });
    }

    protected processBacktest_SubscribeToBundle(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_UnsubscribeFromBundle(requestId: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest/Bundle/Unsubscribe?";
        if (requestId !== undefined && requestId !== null)
            url_ += "requestId=" + encodeURIComponent("" + requestId) + "&";
        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.processBacktest_UnsubscribeFromBundle(_response);
        });
    }

    protected processBacktest_UnsubscribeFromBundle(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_RunGenetic(request: RunGeneticRequest): Promise<GeneticRequest> {
        let url_ = this.baseUrl + "/Backtest/Genetic";
        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.processBacktest_RunGenetic(_response);
        });
    }

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

    backtest_GetGeneticRequests(): Promise<GeneticRequest[]> {
        let url_ = this.baseUrl + "/Backtest/Genetic";
        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_GetGeneticRequests(_response);
        });
    }

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

    backtest_GetGeneticRequest(id: string): Promise<GeneticRequest> {
        let url_ = this.baseUrl + "/Backtest/Genetic/{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_GetGeneticRequest(_response);
        });
    }

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

    backtest_DeleteGeneticRequest(id: string): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Backtest/Genetic/{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: "DELETE",
            headers: {
                "Accept": "application/octet-stream"
            }
        };

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

    protected processBacktest_DeleteGeneticRequest(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 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_Save(request: SaveBotRequest): Promise<string> {
        let url_ = this.baseUrl + "/Bot/Save";
        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_Save(_response);
        });
    }

    protected processBot_Save(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(identifier: string | undefined): Promise<BotStatus> {
        let url_ = this.baseUrl + "/Bot/Stop?";
        if (identifier === null)
            throw new Error("The parameter 'identifier' cannot be null.");
        else if (identifier !== undefined)
            url_ += "identifier=" + encodeURIComponent("" + identifier) + "&";
        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<BotStatus> {
        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 BotStatus;
            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<BotStatus>(null as any);
    }

    bot_StopAll(): Promise<boolean> {
        let url_ = this.baseUrl + "/Bot/StopAll";
        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_StopAll(_response);
        });
    }

    protected processBot_StopAll(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_Delete(identifier: string | undefined): Promise<boolean> {
        let url_ = this.baseUrl + "/Bot/Delete?";
        if (identifier === null)
            throw new Error("The parameter 'identifier' cannot be null.");
        else if (identifier !== undefined)
            url_ += "identifier=" + encodeURIComponent("" + identifier) + "&";
        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_Restart(identifier: string | undefined): Promise<string> {
        let url_ = this.baseUrl + "/Bot/Restart?";
        if (identifier === null)
            throw new Error("The parameter 'identifier' cannot be null.");
        else if (identifier !== undefined)
            url_ += "identifier=" + encodeURIComponent("" + identifier) + "&";
        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_GetActiveBots(): Promise<TradingBotResponse[]> {
        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<TradingBotResponse[]> {
        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 TradingBotResponse[];
            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<TradingBotResponse[]>(null as any);
    }

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

        const content_ = JSON.stringify(moneyManagementRequest);

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

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

    bot_GetBotsByStatus(status: BotStatus): Promise<TradingBotResponse[]> {
        let url_ = this.baseUrl + "/Bot/ByStatus/{status}";
        if (status === undefined || status === null)
            throw new Error("The parameter 'status' must be defined.");
        url_ = url_.replace("{status}", encodeURIComponent("" + status));
        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_GetBotsByStatus(_response);
        });
    }

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

    bot_GetMySavedBots(): Promise<TradingBotResponse[]> {
        let url_ = this.baseUrl + "/Bot/GetMySavedBots";
        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_GetMySavedBots(_response);
        });
    }

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

    bot_GetBotsPaginated(pageNumber: number | undefined, pageSize: number | undefined, status: BotStatus | null | undefined, name: string | null | undefined, ticker: string | null | undefined, agentName: string | null | undefined, sortBy: string | null | undefined, sortDirection: string | null | undefined): Promise<PaginatedResponseOfTradingBotResponse> {
        let url_ = this.baseUrl + "/Bot/Paginated?";
        if (pageNumber === null)
            throw new Error("The parameter 'pageNumber' cannot be null.");
        else if (pageNumber !== undefined)
            url_ += "pageNumber=" + encodeURIComponent("" + pageNumber) + "&";
        if (pageSize === null)
            throw new Error("The parameter 'pageSize' cannot be null.");
        else if (pageSize !== undefined)
            url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
        if (status !== undefined && status !== null)
            url_ += "status=" + encodeURIComponent("" + status) + "&";
        if (name !== undefined && name !== null)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (ticker !== undefined && ticker !== null)
            url_ += "ticker=" + encodeURIComponent("" + ticker) + "&";
        if (agentName !== undefined && agentName !== null)
            url_ += "agentName=" + encodeURIComponent("" + agentName) + "&";
        if (sortBy !== undefined && sortBy !== null)
            url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
        if (sortDirection !== undefined && sortDirection !== null)
            url_ += "sortDirection=" + encodeURIComponent("" + sortDirection) + "&";
        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_GetBotsPaginated(_response);
        });
    }

    protected processBot_GetBotsPaginated(response: Response): Promise<PaginatedResponseOfTradingBotResponse> {
        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 PaginatedResponseOfTradingBotResponse;
            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<PaginatedResponseOfTradingBotResponse>(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);
    }

    bot_GetBotConfig(identifier: string): Promise<TradingBotConfig> {
        let url_ = this.baseUrl + "/Bot/GetConfig/{identifier}";
        if (identifier === undefined || identifier === null)
            throw new Error("The parameter 'identifier' must be defined.");
        url_ = url_.replace("{identifier}", encodeURIComponent("" + identifier));
        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_GetBotConfig(_response);
        });
    }

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

    bot_UpdateBotConfig(request: UpdateBotConfigRequest): Promise<string> {
        let url_ = this.baseUrl + "/Bot/UpdateConfig";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(request);

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

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

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<TickerInfos[]> {
        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<TickerInfos[]> {
        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 TickerInfos[];
            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<TickerInfos[]>(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_GetCandlesWithIndicators(request: GetCandlesWithIndicatorsRequest): Promise<CandlesWithIndicatorsResponse> {
        let url_ = this.baseUrl + "/Data/GetCandlesWithIndicators";
        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.processData_GetCandlesWithIndicators(_response);
        });
    }

    protected processData_GetCandlesWithIndicators(response: Response): Promise<CandlesWithIndicatorsResponse> {
        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 CandlesWithIndicatorsResponse;
            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<CandlesWithIndicatorsResponse>(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_GetTopStrategiesByRoi(): Promise<TopStrategiesByRoiViewModel> {
        let url_ = this.baseUrl + "/Data/GetTopStrategiesByRoi";
        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_GetTopStrategiesByRoi(_response);
        });
    }

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

    data_GetTopAgentsByPnL(): Promise<TopAgentsByPnLViewModel> {
        let url_ = this.baseUrl + "/Data/GetTopAgentsByPnL";
        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_GetTopAgentsByPnL(_response);
        });
    }

    protected processData_GetTopAgentsByPnL(response: Response): Promise<TopAgentsByPnLViewModel> {
        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 TopAgentsByPnLViewModel;
            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<TopAgentsByPnLViewModel>(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(): Promise<PlatformSummaryViewModel> {
        let url_ = this.baseUrl + "/Data/GetPlatformSummary";
        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);
    }

    data_GetAgentIndexPaginated(page: number | undefined, pageSize: number | undefined, sortBy: SortableFields | undefined, sortOrder: string | null | undefined, agentNames: string | null | undefined): Promise<PaginatedAgentIndexResponse> {
        let url_ = this.baseUrl + "/Data/GetAgentIndexPaginated?";
        if (page === null)
            throw new Error("The parameter 'page' cannot be null.");
        else if (page !== undefined)
            url_ += "page=" + encodeURIComponent("" + page) + "&";
        if (pageSize === null)
            throw new Error("The parameter 'pageSize' cannot be null.");
        else if (pageSize !== undefined)
            url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
        if (sortBy === null)
            throw new Error("The parameter 'sortBy' cannot be null.");
        else if (sortBy !== undefined)
            url_ += "sortBy=" + encodeURIComponent("" + sortBy) + "&";
        if (sortOrder !== undefined && sortOrder !== null)
            url_ += "sortOrder=" + encodeURIComponent("" + sortOrder) + "&";
        if (agentNames !== undefined && agentNames !== null)
            url_ += "agentNames=" + encodeURIComponent("" + agentNames) + "&";
        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_GetAgentIndexPaginated(_response);
        });
    }

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

    data_GetAgentBalances(agentName: string | null | undefined, startDate: Date | undefined, endDate: Date | null | undefined): Promise<AgentBalanceHistory> {
        let url_ = this.baseUrl + "/Data/GetAgentBalances?";
        if (agentName !== undefined && agentName !== null)
            url_ += "agentName=" + encodeURIComponent("" + agentName) + "&";
        if (startDate === null)
            throw new Error("The parameter 'startDate' cannot be null.");
        else if (startDate !== undefined)
            url_ += "startDate=" + encodeURIComponent(startDate ? "" + startDate.toISOString() : "") + "&";
        if (endDate !== undefined && endDate !== null)
            url_ += "endDate=" + encodeURIComponent(endDate ? "" + endDate.toISOString() : "") + "&";
        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_GetAgentBalances(_response);
        });
    }

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

    data_GetBestAgents(startDate: Date | undefined, endDate: Date | null | undefined, page: number | undefined, pageSize: number | undefined): Promise<BestAgentsResponse> {
        let url_ = this.baseUrl + "/Data/GetBestAgents?";
        if (startDate === null)
            throw new Error("The parameter 'startDate' cannot be null.");
        else if (startDate !== undefined)
            url_ += "startDate=" + encodeURIComponent(startDate ? "" + startDate.toISOString() : "") + "&";
        if (endDate !== undefined && endDate !== null)
            url_ += "endDate=" + encodeURIComponent(endDate ? "" + endDate.toISOString() : "") + "&";
        if (page === null)
            throw new Error("The parameter 'page' cannot be null.");
        else if (page !== undefined)
            url_ += "page=" + encodeURIComponent("" + page) + "&";
        if (pageSize === null)
            throw new Error("The parameter 'pageSize' cannot be null.");
        else if (pageSize !== undefined)
            url_ += "pageSize=" + encodeURIComponent("" + pageSize) + "&";
        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_GetBestAgents(_response);
        });
    }

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

    data_GetOnlineAgent(): Promise<string[]> {
        let url_ = this.baseUrl + "/Data/GetOnlineAgent";
        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_GetOnlineAgent(_response);
        });
    }

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

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<ScenarioViewModel[]> {
        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<ScenarioViewModel[]> {
        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 ScenarioViewModel[];
            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<ScenarioViewModel[]>(null as any);
    }

    scenario_CreateScenario(name: string | null | undefined, loopbackPeriod: number | null | undefined, strategies: string[]): Promise<ScenarioViewModel> {
        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<ScenarioViewModel> {
        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 ScenarioViewModel;
            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<ScenarioViewModel>(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_GetIndicators(): Promise<IndicatorViewModel[]> {
        let url_ = this.baseUrl + "/Scenario/indicator";
        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_GetIndicators(_response);
        });
    }

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

    scenario_CreateIndicator(indicatorType: IndicatorType | 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<IndicatorViewModel> {
        let url_ = this.baseUrl + "/Scenario/indicator?";
        if (indicatorType === null)
            throw new Error("The parameter 'indicatorType' cannot be null.");
        else if (indicatorType !== undefined)
            url_ += "indicatorType=" + encodeURIComponent("" + indicatorType) + "&";
        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_CreateIndicator(_response);
        });
    }

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

    scenario_DeleteIndicator(name: string | null | undefined): Promise<FileResponse> {
        let url_ = this.baseUrl + "/Scenario/indicator?";
        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_DeleteIndicator(_response);
        });
    }

    protected processScenario_DeleteIndicator(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_Updateindicator(indicatorType: IndicatorType | 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/indicator?";
        if (indicatorType === null)
            throw new Error("The parameter 'indicatorType' cannot be null.");
        else if (indicatorType !== undefined)
            url_ += "indicatorType=" + encodeURIComponent("" + indicatorType) + "&";
        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_Updateindicator(_response);
        });
    }

    protected processScenario_Updateindicator(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<boolean> {
        let url_ = this.baseUrl + "/Settings";
        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_SetupSettings(_response);
        });
    }

    protected processSettings_SetupSettings(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_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_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 | undefined): Promise<Position> {
        let url_ = this.baseUrl + "/Trading/ClosePosition?";
        if (identifier === null)
            throw new Error("The parameter 'identifier' cannot be null.");
        else if (identifier !== undefined)
            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);
    }

    trading_InitPrivyWallet(publicAddress: string): Promise<PrivyInitAddressResponse> {
        let url_ = this.baseUrl + "/Trading/InitPrivyWallet";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(publicAddress);

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

    protected processTrading_InitPrivyWallet(response: Response): Promise<PrivyInitAddressResponse> {
        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 PrivyInitAddressResponse;
            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<PrivyInitAddressResponse>(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/create-token";
        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_GetCurrentUser(): Promise<User> {
        let url_ = this.baseUrl + "/User";
        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.processUser_GetCurrentUser(_response);
        });
    }

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

    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);
    }

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

        const content_ = JSON.stringify(avatarUrl);

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

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

    user_UpdateTelegramChannel(telegramChannel: string): Promise<User> {
        let url_ = this.baseUrl + "/User/telegram-channel";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(telegramChannel);

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

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

    user_TestTelegramChannel(): Promise<string> {
        let url_ = this.baseUrl + "/User/telegram-channel/test";
        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.processUser_TestTelegramChannel(_response);
        });
    }

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

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 {
    id?: number;
    name?: string | null;
    accounts?: Account[] | null;
    agentName?: string | null;
    avatarUrl?: string | null;
    telegramChannel?: 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 GmxClaimableSummary {
    claimableFundingFees?: FundingFeesData | null;
    claimableUiFees?: UiFeesData | null;
    rebateStats?: RebateStatsData | null;
}

export interface FundingFeesData {
    totalUsdc?: number;
}

export interface UiFeesData {
    totalUsdc?: number;
}

export interface RebateStatsData {
    totalRebateUsdc?: number;
    discountUsdc?: number;
    rebateFactor?: number;
    discountFactor?: number;
}

export interface SwapInfos {
    success?: boolean;
    hash?: string | null;
    message?: string | null;
    error?: string | null;
    errorType?: string | null;
    suggestion?: string | null;
}

export interface SwapTokensRequest {
    fromTicker: Ticker;
    toTicker: Ticker;
    amount: number;
    orderType?: string | null;
    triggerRatio?: number | null;
    allowedSlippage?: 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 SendTokenRequest {
    recipientAddress: string;
    ticker: Ticker;
    amount: number;
    chainId?: number | null;
}

export interface Backtest {
    id: string;
    finalPnl: number;
    winRate: number;
    growthPercentage: number;
    hodlPercentage: number;
    config: TradingBotConfig;
    positions: { [key: string]: Position; };
    signals: { [key: string]: LightSignal; };
    candles: Candle[];
    startDate: Date;
    endDate: Date;
    statistics: PerformanceMetrics;
    fees: number;
    walletBalances: KeyValuePairOfDateTimeAndDecimal[];
    user: User;
    score: number;
    requestId?: string;
    metadata?: any | null;
    scoreMessage?: string;
}

export interface TradingBotConfig {
    accountName: string;
    moneyManagement: LightMoneyManagement;
    ticker: Ticker;
    timeframe: Timeframe;
    isForWatchingOnly: boolean;
    botTradingBalance: number;
    isForBacktest: boolean;
    cooldownPeriod: number;
    maxLossStreak: number;
    flipPosition: boolean;
    name: string;
    riskManagement?: RiskManagement | null;
    scenario?: LightScenario | null;
    scenarioName?: string | null;
    maxPositionTimeHours?: number | null;
    closeEarlyWhenProfitable?: boolean;
    flipOnlyWhenInProfit: boolean;
    useSynthApi?: boolean;
    useForPositionSizing?: boolean;
    useForSignalFiltering?: boolean;
    useForDynamicStopLoss?: boolean;
}

export interface LightMoneyManagement {
    name: string;
    timeframe: Timeframe;
    stopLoss: number;
    takeProfit: number;
    leverage: number;
}

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

export interface RiskManagement {
    adverseProbabilityThreshold: number;
    favorableProbabilityThreshold: number;
    riskAversion: number;
    kellyMinimumThreshold: number;
    kellyMaximumCap: number;
    maxLiquidationProbability: number;
    signalValidationTimeHorizonHours: number;
    positionMonitoringTimeHorizonHours: number;
    positionWarningThreshold: number;
    positionAutoCloseThreshold: number;
    kellyFractionalMultiplier: number;
    riskTolerance: RiskToleranceLevel;
    useExpectedUtility: boolean;
    useKellyCriterion: boolean;
}

export enum RiskToleranceLevel {
    Conservative = "Conservative",
    Moderate = "Moderate",
    Aggressive = "Aggressive",
}

export interface LightScenario {
    name?: string | null;
    indicators?: LightIndicator[] | null;
    loopbackPeriod?: number | null;
}

export interface LightIndicator {
    name?: string | null;
    type?: IndicatorType;
    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;
}

export enum IndicatorType {
    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",
    DualEmaCross = "DualEmaCross",
}

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

export interface Position {
    accountName: string;
    date: Date;
    originDirection: TradeDirection;
    ticker: Ticker;
    moneyManagement: LightMoneyManagement;
    Open: Trade;
    StopLoss: Trade;
    TakeProfit1: Trade;
    TakeProfit2?: Trade | null;
    ProfitAndLoss?: ProfitAndLoss | null;
    status: PositionStatus;
    signalIdentifier?: string | null;
    identifier: string;
    initiator: PositionInitiator;
    user: User;
    initiatorIdentifier: string;
}

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

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;
}

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 LightSignal {
    status: SignalStatus;
    direction: TradeDirection;
    confidence: Confidence;
    timeframe: Timeframe;
    date: Date;
    candle: Candle;
    identifier: string;
    ticker: Ticker;
    exchange: TradingExchanges;
    indicatorType: IndicatorType;
    signalType: SignalType;
    indicatorName: string;
}

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;
    high: number;
    low: number;
    timeframe: Timeframe;
    volume?: number;
}

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 DeleteBacktestsRequest {
    backtestIds: string[];
}

export interface PaginatedBacktestsResponse {
    backtests?: LightBacktestResponse[] | null;
    totalCount?: number;
    currentPage?: number;
    pageSize?: number;
    totalPages?: number;
    hasNextPage?: boolean;
    hasPreviousPage?: boolean;
}

export interface LightBacktestResponse {
    id: string;
    config: TradingBotConfig;
    finalPnl: number;
    winRate: number;
    growthPercentage: number;
    hodlPercentage: number;
    startDate: Date;
    endDate: Date;
    maxDrawdown: number;
    fees: number;
    sharpeRatio: number;
    score: number;
    scoreMessage: string;
}

export interface LightBacktest {
    id?: string | null;
    config?: TradingBotConfig | null;
    finalPnl?: number;
    winRate?: number;
    growthPercentage?: number;
    hodlPercentage?: number;
    startDate?: Date;
    endDate?: Date;
    maxDrawdown?: number | null;
    fees?: number;
    sharpeRatio?: number | null;
    score?: number;
    scoreMessage?: string | null;
}

export interface RunBacktestRequest {
    config?: TradingBotConfigRequest | null;
    startDate?: Date;
    endDate?: Date;
    save?: boolean;
    withCandles?: boolean;
}

export interface TradingBotConfigRequest {
    accountName: string;
    ticker: Ticker;
    timeframe: Timeframe;
    isForWatchingOnly: boolean;
    botTradingBalance: number;
    name: string;
    flipPosition: boolean;
    cooldownPeriod: number;
    maxLossStreak: number;
    scenario?: ScenarioRequest | null;
    scenarioName?: string | null;
    moneyManagementName?: string | null;
    moneyManagement?: MoneyManagementRequest | null;
    maxPositionTimeHours?: number | null;
    closeEarlyWhenProfitable?: boolean;
    flipOnlyWhenInProfit?: boolean;
    useSynthApi?: boolean;
    useForPositionSizing?: boolean;
    useForSignalFiltering?: boolean;
    useForDynamicStopLoss?: boolean;
}

export interface ScenarioRequest {
    name: string;
    indicators: IndicatorRequest[];
    loopbackPeriod?: number | null;
}

export interface IndicatorRequest {
    name: string;
    type: IndicatorType;
    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;
}

export interface MoneyManagementRequest {
    name: string;
    timeframe: Timeframe;
    stopLoss: number;
    takeProfit: number;
    leverage: number;
}

export interface BundleBacktestRequest {
    requestId: string;
    user: User;
    createdAt: Date;
    completedAt?: Date | null;
    status: BundleBacktestRequestStatus;
    name: string;
    backtestRequestsJson: string;
    results?: string[] | null;
    totalBacktests: number;
    completedBacktests: number;
    failedBacktests: number;
    progressPercentage?: number;
    errorMessage?: string | null;
    progressInfo?: string | null;
    currentBacktest?: string | null;
    estimatedTimeRemainingSeconds?: number | null;
}

export enum BundleBacktestRequestStatus {
    Pending = "Pending",
    Running = "Running",
    Completed = "Completed",
    Failed = "Failed",
    Cancelled = "Cancelled",
}

export interface RunBundleBacktestRequest {
    name: string;
    requests: RunBacktestRequest[];
}

export interface GeneticRequest {
    requestId: string;
    user: User;
    createdAt: Date;
    completedAt?: Date | null;
    status: GeneticRequestStatus;
    ticker: Ticker;
    timeframe: Timeframe;
    startDate: Date;
    endDate: Date;
    balance: number;
    populationSize: number;
    generations: number;
    mutationRate: number;
    selectionMethod: GeneticSelectionMethod;
    crossoverMethod: GeneticCrossoverMethod;
    mutationMethod: GeneticMutationMethod;
    elitismPercentage: number;
    maxTakeProfit: number;
    eligibleIndicators: IndicatorType[];
    results?: Backtest[] | null;
    bestFitness?: number | null;
    bestIndividual?: string | null;
    errorMessage?: string | null;
    progressInfo?: string | null;
    bestChromosome?: string | null;
    currentGeneration?: number;
    bestFitnessSoFar?: number | null;
}

export enum GeneticRequestStatus {
    Pending = "Pending",
    Running = "Running",
    Completed = "Completed",
    Failed = "Failed",
    Cancelled = "Cancelled",
}

export enum GeneticSelectionMethod {
    Elite = "Elite",
    Roulette = "Roulette",
    StochasticUniversalSampling = "StochasticUniversalSampling",
    Tournament = "Tournament",
    Truncation = "Truncation",
}

export enum GeneticCrossoverMethod {
    AlternatingPosition = "AlternatingPosition",
    CutAndSplice = "CutAndSplice",
    Cycle = "Cycle",
    OnePoint = "OnePoint",
    OrderBased = "OrderBased",
    Ordered = "Ordered",
    PartiallyMapped = "PartiallyMapped",
    PositionBased = "PositionBased",
    ThreeParent = "ThreeParent",
    TwoPoint = "TwoPoint",
    Uniform = "Uniform",
    VotingRecombination = "VotingRecombination",
}

export enum GeneticMutationMethod {
    Displacement = "Displacement",
    FlipBit = "FlipBit",
    Insertion = "Insertion",
    PartialShuffle = "PartialShuffle",
    ReverseSequence = "ReverseSequence",
    Twors = "Twors",
    Uniform = "Uniform",
}

export interface RunGeneticRequest {
    ticker?: Ticker;
    timeframe?: Timeframe;
    startDate?: Date;
    endDate?: Date;
    balance?: number;
    populationSize?: number;
    generations?: number;
    mutationRate?: number;
    selectionMethod?: GeneticSelectionMethod;
    crossoverMethod?: GeneticCrossoverMethod;
    mutationMethod?: GeneticMutationMethod;
    elitismPercentage?: number;
    maxTakeProfit?: number;
    eligibleIndicators?: IndicatorType[] | null;
}

export interface MoneyManagement extends LightMoneyManagement {
    user?: User | null;
}

export interface StartBotRequest {
    config?: TradingBotConfigRequest | null;
}

export interface SaveBotRequest extends StartBotRequest {
}

export enum BotStatus {
    Saved = "Saved",
    Stopped = "Stopped",
    Running = "Running",
}

export interface TradingBotResponse {
    status: string;
    signals: { [key: string]: LightSignal; };
    positions: { [key: string]: Position; };
    candles: Candle[];
    winRate: number;
    profitAndLoss: number;
    identifier: string;
    agentName: string;
    createDate: Date;
    startupTime: Date;
    name: string;
    ticker: Ticker;
}

export interface PaginatedResponseOfTradingBotResponse {
    items?: TradingBotResponse[] | null;
    totalCount?: number;
    pageNumber?: number;
    pageSize?: number;
    totalPages?: number;
    hasPreviousPage?: boolean;
    hasNextPage?: boolean;
}

export interface OpenPositionManuallyRequest {
    identifier?: string;
    direction?: TradeDirection;
}

export interface ClosePositionRequest {
    identifier?: string;
    positionId?: string;
}

export interface UpdateBotConfigRequest {
    identifier: string;
    config: TradingBotConfigRequest;
    moneyManagementName?: string | null;
    moneyManagement?: MoneyManagement | null;
}

export interface TickerInfos {
    ticker?: Ticker;
    imageUrl?: 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;
    indicators?: IndicatorBase[] | null;
    loopbackPeriod?: number | null;
    user?: User | null;
}

export interface IndicatorBase {
    name?: string | null;
    type?: IndicatorType;
    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: LightSignal[];
    fifteenMinutes: LightSignal[];
    oneHour: LightSignal[];
    fourHour: LightSignal[];
    oneDay: LightSignal[];
}

export interface CandlesWithIndicatorsResponse {
    candles?: Candle[] | null;
    indicatorsValues?: { [key in keyof typeof IndicatorType]?: IndicatorsResultBase; } | null;
}

export interface IndicatorsResultBase {
    ema?: EmaResult[] | null;
    fastEma?: EmaResult[] | null;
    slowEma?: 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 GetCandlesWithIndicatorsRequest {
    ticker?: Ticker;
    startDate?: Date;
    endDate?: Date;
    timeframe?: Timeframe;
    scenario?: ScenarioRequest | null;
}

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

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

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

export interface TopStrategiesByRoiViewModel {
    topStrategiesByRoi?: StrategyRoiPerformance[] | null;
}

export interface StrategyRoiPerformance {
    strategyName?: string | null;
    roi?: number;
    pnL?: number;
    volume?: number;
}

export interface TopAgentsByPnLViewModel {
    topAgentsByPnL?: AgentPerformance[] | null;
}

export interface AgentPerformance {
    agentName?: string | null;
    pnL?: number;
    totalROI?: number;
    totalVolume?: number;
    activeStrategiesCount?: number;
    totalBalance?: number;
}

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

export interface PlatformSummaryViewModel {
    totalAgents?: number;
    totalActiveStrategies?: number;
    totalPlatformPnL?: number;
    totalPlatformVolume?: number;
    totalPlatformVolumeLast24h?: number;
    totalOpenInterest?: number;
    totalPositionCount?: number;
    agentsChange24h?: number;
    strategiesChange24h?: number;
    pnLChange24h?: number;
    volumeChange24h?: number;
    openInterestChange24h?: number;
    positionCountChange24h?: number;
    volumeByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
    positionCountByAsset?: { [key in keyof typeof Ticker]?: number; } | null;
    positionCountByDirection?: { [key in keyof typeof TradeDirection]?: number; } | null;
    lastUpdated?: Date;
    last24HourSnapshot?: Date;
    volumeHistory?: VolumeHistoryPoint[] | null;
}

export interface VolumeHistoryPoint {
    date?: Date;
    volume?: number;
}

export interface PaginatedAgentIndexResponse {
    agentSummaries?: AgentSummaryViewModel[] | null;
    totalCount?: number;
    currentPage?: number;
    pageSize?: number;
    totalPages?: number;
    hasNextPage?: boolean;
    hasPreviousPage?: boolean;
    timeFilter?: string | null;
    sortBy?: SortableFields;
    sortOrder?: string | null;
    filteredAgentNames?: string | null;
}

export interface AgentSummaryViewModel {
    agentName?: string | null;
    totalPnL?: number;
    totalROI?: number;
    wins?: number;
    losses?: number;
    activeStrategiesCount?: number;
    totalVolume?: number;
    totalBalance?: number;
}

export enum SortableFields {
    TotalPnL = "TotalPnL",
    TotalROI = "TotalROI",
    Wins = "Wins",
    Losses = "Losses",
    AgentName = "AgentName",
    CreatedAt = "CreatedAt",
    UpdatedAt = "UpdatedAt",
}

export interface AgentBalanceHistory {
    agentName?: string | null;
    agentBalances?: AgentBalance[] | null;
}

export interface AgentBalance {
    agentName?: string | null;
    totalValue?: number;
    totalAccountUsdValue?: number;
    botsAllocationUsdValue?: number;
    pnL?: number;
    time?: Date;
}

export interface BestAgentsResponse {
    agents?: AgentBalanceHistory[] | null;
    totalCount?: number;
    currentPage?: number;
    pageSize?: number;
    totalPages?: number;
}

export interface ScenarioViewModel {
    name: string;
    indicators: IndicatorViewModel[];
    loopbackPeriod?: number | null;
    userName: string;
}

export interface IndicatorViewModel {
    name: string;
    type: IndicatorType;
    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;
    userName: string;
}

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

export interface PrivyInitAddressResponse {
    success?: boolean;
    usdcHash?: string | null;
    orderVaultHash?: string | null;
    exchangeRouterHash?: string | null;
    error?: string | null;
}

export interface LoginRequest {
    name: string;
    address: string;
    signature: string;
    message: 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);
}