import { TccErrorListener } from ".";
import { IKeyObjectValue } from "../../../type";
import { BuiltInVariables } from "../buildInVariables";
import { VCommission, VDirection, VFormatType, VOca, VScale, VStrategy } from "../enum";
import { Risk } from '../strategyNamespace';
export interface IStrategy {
    title?: string;
    shorttitle?: string;
    overlay?: boolean;
    format?: VFormatType;
    precision?: number;
    scale?: VScale;
    pyramiding?: number;
    calc_on_order_fills?: boolean;
    calc_on_every_tick?: boolean;
    max_bars_back?: number;
    backtest_fill_limits_assumption?: number;
    default_qty_type?: VStrategy;
    default_qty_value?: number;
    initial_capital: number;
    currency?: string;
    slippage?: number;
    commission_type?: VCommission;
    commission_value?: number;
    process_orders_on_close?: boolean;
    close_entries_rule?: CloseEntriesRuleType;
    margin_long?: number;
    margin_short?: number;
    explicit_plot_zorder?: boolean;
    max_lines_count?: number;
    max_labels_count?: number;
    max_boxes_count?: number;
    calc_bars_count?: number;
    risk_free_rate?: number;
    use_bar_magnifier?: boolean;
    fill_orders_on_standard_ohlc?: boolean;
    max_polylines_count?: number;
    scriptType?: string;
    direction_short_long?: boolean;
}
interface IOrderArgs {
    id: string;
    direction: VDirection;
    from_entry?: string;
    qty?: number;
    limit?: number;
    loss?: number;
    stop?: number;
    oca_name?: string;
    oca_type?: VOca;
    comment?: string;
    alert_message?: string;
    disable_alert?: false;
    qty_percent?: number;
    immediately?: boolean;
    trail_price?: number;
    trail_points?: number;
    trail_offset?: number;
    profit?: number;
    comment_profit?: string;
    comment_loss?: string;
    comment_trailing?: string;
    last_commission?: number;
    when?: boolean;
    long?: boolean;
    createTime?: number;
}
type PlaceOrderType = 'order' | 'entry' | 'exit' | 'close' | 'close_all';
export interface IOrder extends IOrderArgs {
    isMarketPrice?: boolean;
    out_id?: string;
    in_index?: number;
    out_index?: number;
    in_price: number;
    out_price?: number;
    in_time?: number;
    out_time?: number;
    out_qty?: number;
    out_comment?: string;
    total_profit?: number;
    max_profit?: number;
    trading_loss?: number;
    place_order_type?: PlaceOrderType;
    position_close_type?: PlaceOrderType;
    isDeal?: boolean;
    exitIds?: string[];
    active_price?: number;
    trail_stop_price?: number;
    hasOrder?: boolean;
    isMarketPriceLimit?: boolean;
    isMarketPriceStop?: boolean;
    isCancel?: boolean;
    close_qty?: number;
    profit_percent?: number;
    max_profit_percent?: number;
    trading_loss_percent?: number;
    commission?: number;
    original_qty?: number;
    in_low?: number;
    in_high?: number;
    out_low?: number;
    out_high?: number;
    isTiggerClose?: boolean;
    entry_time?: number;
    unid?: string;
    realQty?: number;
    isPartClose?: boolean;
    occupancyQty?: number;
    exitOrder?: IKeyObjectValue;
    isEnd?: boolean;
}
interface IRisk {
    allow_entry_in?: VDirection;
    max_cons_loss_days?: number;
    max_drawdown?: number;
    max_drawdown_type?: VStrategy;
    max_intraday_filled_orders?: number;
    max_intraday_loss?: number;
    max_intraday_loss_type?: VStrategy;
    max_position_size?: number;
    isDisabledOpen?: boolean;
    lossDays?: number;
    totalProfit?: number;
    intradayOrders?: number;
    isTemporaryBan?: boolean;
    preNetprofit?: number;
}
interface IData {
    close: number;
    high: number;
    low: number;
    open: number;
}
interface IFillsData {
    data?: IData;
    tradeData?: IData;
    index: number;
    currentData?: IData;
}
type CloseEntriesRuleType = 'FIFO' | 'ANY';
export default class Strategy {
    private _variables;
    private _options;
    private _totalChangeCapital;
    private _historyOrder;
    private _orders;
    private _exitOrders;
    private _pendingOrders;
    private _mintick;
    private _funcOptions;
    private _pendingCloseOrders;
    private _errorListener;
    private _risk;
    private _riskNamespace;
    private _updateOptions;
    private _id;
    private _maxDrawdownVerifyIndex;
    calcOnOrderFillsData: IFillsData;
    private _cacheArgs;
    private _useSetArgs;
    private _closeOrderList;
    private _notCloseHistoryOrders;
    private _currentOrders;
    constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick: number, errorListener: TccErrorListener, id: string);
    get _strategyCacheData(): IKeyObjectValue;
    set _strategyCacheData(val: IKeyObjectValue);
    get orders(): IOrder[];
    get currentOrders(): IOrder[];
    get historyOrders(): IOrder[];
    get _freezeCapital(): number;
    get risk(): Risk;
    get isCalcOnEveryTick(): boolean | undefined;
    updateOptions(options?: IStrategy): void;
    update(): void;
    calcCurrentOrder(): void;
    updateRisk(risk: IRisk): void;
    endExecution(): void;
    private _maxIntradayLoss;
    private _maxIntradayFilledOrdersVerify;
    private _maxConsLossDaysVerify;
    private _maxDrawdownVerify;
    private _riskTouchOff;
    strategy(args: IKeyObjectValue, posStr: string): void;
    private _updateArgToOptions;
    order(args: IOrderArgs, posStr: string): void;
    entry(args: IOrderArgs, posStr: string): void;
    close(args: IOrder, posStr: string): void;
    close_all(args: IOrder, posStr: string): void;
    cancel(args: IOrderArgs, posStr: string): void;
    cancel_all(args: IOrderArgs, posStr: string): void;
    exit(args: IOrderArgs, posStr: string): void;
    private _calcDefaultQty;
    private _calcExitQty;
    private _getCommQty;
    private _getLen;
    private _getCapital;
    private _calcProfitAndLoss;
    private _calcProfitAndLossHandle;
    private _calcOrderPercent;
    private _calcLiquidate;
    private _marginCallOrders;
    private _orderHandle;
    private _orderOnCloseHandle;
    private _judgeCapitalEnough;
    private _getOrderProfit;
    private _ocaGroupVerify;
    private _processOrders;
    private _addPendingOrders;
    private _orderArgsParse;
    private _entryHandle;
    private _entryOnCloseHandle;
    private _getOrders;
    private _entryOrder;
    private _getAvailablePositionSize;
    private _getEntryOrders;
    private _addPendingEntry;
    private _closeAllOrders;
    private _closeOrders;
    private _closeOrder;
    private _exitOrdersHandle;
    private _updateExitOrders;
    private _orderInExitHandle;
    private _executesSort;
    private _getLimitPrice;
    private _getStopPrice;
    private _getTrailStopPrice;
    private _ordersHandle;
    private _calcTrailStopPrice;
    private _pendingOrderHandle;
    private _pendingOrderSort;
    private _pendingCloseOrderHandle;
    private _onCloseOrderHandle;
    private _entryOrderHandle;
    private _orderOrderHandle;
    private _getHisOrderSurplusQty;
    private _getCloseOrders;
    private _closeOrderHandle;
    private _processCloseOrdersFIFO;
    private _processCloseOrders;
    private _exitOrderHandle;
    private _getUnCloseOrders;
    private _exit;
    private _updateExitOrder;
    private _calcUpdateExitOrderQty;
    private _calcExitOrderQty;
    private _ordersToExit;
    private _calcLimitPrice;
    private _calcStopPrice;
    private _calcActivePrice;
    private _stopProfit;
    private _stopLoss;
    private _trailStopLoss;
    private _processExitOnClose;
    private _processExitOrders;
    private _processOrder;
    private _calcPercent;
    private _getCommission;
    private _calcCurrentOrder;
    private _calcOrderFillsHandle;
    private _isNaN;
    private _paramVerfiy;
    _verfiyRequestFunc(posStr: string, name: string): void;
}
export {};
