package trade import "sig-pub/pkg/types" // sig -> close strategy // sig -> risk strategy -> trade strategy -> tarde account // position, trades type ITradeAccount interface { // 获取未平仓交易单 OpenPositions() map[int64]*Position // 获取未平仓交易单数 CountOpenPositions() int // 订单下单 TradeOrder(ta TradeArg) (ok bool, cause Cause, err error) // 将仓位进行平仓 ClosePosition(*Position, types.Kline, Cause) (err error) // // 根据当前价格对仓位进行 mark-to-market,返回账户净值 // GetCurrentEquity() decimal.Decimal // // 返回当前仓位的名义总敞口(绝对值) // GetCurrentExposure() decimal.Decimal // // 获取可交易空闲资金 // GetCash() decimal.Decimal // // 获取交易订单 // GetTradeOrder(tradeId int64) Trade // // 判断在给定价格下是否可以开仓(基于 MaxPosPct 和 MaxExposurePct) // CanOpen(instId string, side types.Side, qty, price float64) bool // // 直接用市价下单(简化),qty为基础货币数量 // ApplyMarketOrder(instId string, side types.Side, qty float64, price float64, ts int64) (t *entity.TradeOrder, ok bool) } type OkxTradeAccount struct { ITradeAccount }