initial
This commit is contained in:
61
trade/types.go
Normal file
61
trade/types.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package trade
|
||||
|
||||
import (
|
||||
"git.apinb.com/quant/strategy/internal/core/market"
|
||||
"git.apinb.com/quant/strategy/internal/models"
|
||||
)
|
||||
|
||||
type Spec struct {
|
||||
AllowSymbols []string
|
||||
PlanKeyName string
|
||||
Api *models.ExchangeApi
|
||||
StrategyConf *models.StrategyConf
|
||||
SymbolsSetting map[string]*market.PairSetting
|
||||
BinanceClient *BinanceClient `json:"-"`
|
||||
BitgetClient *BitgetClient `json:"-"`
|
||||
}
|
||||
|
||||
type Positions struct {
|
||||
Long []*PositionData `json:"long"`
|
||||
Short []*PositionData `json:"short"`
|
||||
Data []*PositionData `json:"data"`
|
||||
}
|
||||
|
||||
type PositionData struct {
|
||||
Symbol string `json:"symbol"` // 交易对
|
||||
Side string `json:"side"` // 持仓方向
|
||||
Amt float64 `json:"amt"` // 持仓数量
|
||||
AvgPrice float64 `json:"avgPrice"` // 持仓均价
|
||||
MarkPrice float64 `json:"markPrice"` // 当前标记价格
|
||||
UnRealizedProfit float64 `json:"unRealizedProfit"` // 未实现盈亏
|
||||
UnRealizedProfitRate float64 `json:"unRealizedProfitRate"` // 未实现盈亏率
|
||||
MarginType string `json:"marginType"` // 保证金模式
|
||||
MarginSize float64 `json:"marginSize"` // 保证金
|
||||
Leverage int `json:"leverage"` // 杠杆倍数
|
||||
IsMaxMarginSize bool `json:"isMaxMarginSize"` // 是否达到最大保证金
|
||||
}
|
||||
|
||||
// 持仓状态
|
||||
type PositionStatus int
|
||||
|
||||
const (
|
||||
NoPositions PositionStatus = iota // 空头,多头均无持仓
|
||||
LongOnly // 多头持仓
|
||||
ShortOnly // 空头持仓
|
||||
BothPositions // 双向持仓
|
||||
Unknown // 未知状态
|
||||
)
|
||||
|
||||
func (ps PositionStatus) String() string {
|
||||
switch ps {
|
||||
case NoPositions:
|
||||
return "NoPositions"
|
||||
case LongOnly:
|
||||
return "LONG"
|
||||
case ShortOnly:
|
||||
return "SHORT"
|
||||
case BothPositions:
|
||||
return "BothPositions"
|
||||
}
|
||||
return "Unknown"
|
||||
}
|
||||
Reference in New Issue
Block a user