declare type numType = string | number; export declare enum ESide { LONG = 1, SHORT = -1 } export declare enum DirEnum { UP = "up", DOWN = "down" } /** * 参数非空校验 * @example paramIsNil(['a', 'b', 'c']) => {'a': 1, 'b': 2, 'c': undefined} => undefined * */ export declare function paramIsNil(params: Array, args: { [P: string]: any; }): string | undefined; /** * 预估强平价格计算 * @param posMargin 仓位保证金 * @param increaseMargin 增加保证金 * @param positionAmt 持仓数量 * @param averagePosPrice 持仓均价 * @param marginRatio 维持保证金率 * @param amtRate 资金费率 * @param takerRate taker手续费 * @param direction 多/空 * */ export interface liquidationPriceProps { posMargin: string | number; increaseMargin: string | number; positionAmt: string | number; averagePosPrice: string | number; marginRatio: string | number; amtRate: string | number; takerRate: string | number; direction: ESide; } export declare function calcLiquidationPrice({ posMargin, increaseMargin, positionAmt, averagePosPrice, marginRatio, amtRate, takerRate, direction }: liquidationPriceProps): number | "" | undefined; /** * 预计盈亏计算 * @param strikePrice 触发价 * @param avgEntryPrice 开仓价格 * @param amt 数量 * @param side 方向 * */ export interface CalcPreProfitProps { strikePrice: number | string; avgEntryPrice: number | string; amt: number | string; side: ESide; dir: DirEnum; } export declare function calcPreProfit({ strikePrice, avgEntryPrice, amt, side, dir }: CalcPreProfitProps): number | "--"; /** * 回报率触发价格计算 * @param returnRate 回报率 * @param posMargin 保证金 * @param avgEntryPrice 开仓价格 * */ export interface calcStrikePriceByReturnRateProps { returnRate: number | string; posMargin: number | string; avgEntryPrice: number | string; side: ESide; dir: DirEnum; } export declare function calcStrikePriceByReturnRate({ returnRate, posMargin, avgEntryPrice, side, dir }: calcStrikePriceByReturnRateProps): number; /** * 基于成本算数量 * 杠杆拉满计算数量(面值) * 做多: 委托数量 = 可用/委托价格/(taker费率 + 1/杠杆) * 做空: 委托数量 = 可用/max( 买一价,委托价格 )/(taker费率 + 1/ 杠杆 ) */ interface quantityByCostProps { /** 资产 */ balance: numType; /** 价格 */ price: numType; /** taker手续费 */ takerFee: numType; /** 杠杆 */ leverage: numType; } export declare const getQuantityByCost: ({ balance, price, takerFee, leverage }: quantityByCostProps) => number; /** * 基于面值算成本 * 成本=( 委托价格 * 委托数量 / 杠杆 ) + ( 委托价格 * 委托数量 * taker手续费率 ) */ interface costByQuantityProps { price: numType; quantity: numType; leverage: numType; takerFee: numType; } export declare const getCostByQuantity: ({ price, quantity, leverage, takerFee }: costByQuantityProps) => number; /** * 计算订单价值 value = price * quantity */ interface orderValueProps { price: numType; quantity: numType; scale: numType; } export declare const getOrderValue: ({ price, quantity, scale }: orderValueProps) => string; /** * 按比例取数据 * @param rate 比例 - 25/ 50这种 */ interface rateValueProps { /** 比例 */ rate: number; /** 总量 */ max: numType; } export declare const getRateValue: ({ rate, max }: rateValueProps) => number; /** * 数量(价值) = 张数 * 合约面值 */ interface valueByContrProps { /** 张 */ value: numType; /** 单张面值 */ multiplier: numType; /** 面值精度 */ scale: numType; } export declare const getValueByContr: ({ value, multiplier, scale }: valueByContrProps) => string; /** * 张数 = 价值 / 单张面值 * @param value * @param multiplier */ interface ContrByValueProps { value: numType; multiplier: numType; } export declare const getContrByValue: ({ value, multiplier }: ContrByValueProps) => string; /** * 张 / 面值转换 * @param value 原始数量 * @param multiplier 单张面值 * @param scale 精度 * @param getContr 是否获取张,默认false * @returns */ interface ContrOrValueProps { value: numType; multiplier: numType; scale: numType; getContr?: boolean; } export declare const getContrOrValue: ({ value, multiplier, scale, getContr }: ContrOrValueProps) => string; /** * 格式化杠杆 * @param leverage * @param scale * @returns */ export declare const getformatLeverage: (leverage: numType, scale: number) => number; export {};