package trade import ( "sig-pub/pkg/data/entity" "sig-pub/pkg/types" "github.com/govalues/decimal" ) // sig -> close strategy // sig -> risk strategy -> trade strategy -> tarde account type ITradeAccount interface { // 根据当前价格对仓位进行 mark-to-market,返回账户净值 GetCurrentEquity() decimal.Decimal // 返回当前仓位的名义总敞口(绝对值) GetCurrentExposure() decimal.Decimal // 获取可交易空闲资金 GetCash() decimal.Decimal // 获取未平仓交易单 ListOpenPosition() []*Position // 获取交易订单 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) // 将仓位进行平仓 ClosePosition() } type OkxTradeAccount struct { ITradeAccount }