types: add FuturesPosition

This commit is contained in:
austin362667 2021-12-30 21:40:57 +08:00
parent 5474a42f24
commit b000f572b4
2 changed files with 23 additions and 1 deletions

View File

@ -121,6 +121,7 @@ func (m AssetMap) SlackAttachment() slack.Attachment {
type BalanceMap map[string]Balance
type PositionMap map[string]Position
type FuturesPositionMap map[string]FuturesPosition
func (m BalanceMap) String() string {
var ss []string
@ -229,7 +230,7 @@ type FuturesAccountInfo struct {
Assets map[Asset]FuturesUserAsset `json:"assets"`
FeeTier int `json:"feeTier"`
MaxWithdrawAmount fixedpoint.Value `json:"maxWithdrawAmount"`
Positions PositionMap `json:"positions"`
Positions FuturesPositionMap `json:"positions"`
TotalInitialMargin fixedpoint.Value `json:"totalInitialMargin"`
TotalMaintMargin fixedpoint.Value `json:"totalMaintMargin"`
TotalMarginBalance fixedpoint.Value `json:"totalMarginBalance"`

View File

@ -39,6 +39,27 @@ type Position struct {
FeeRate *ExchangeFee `json:"feeRate,omitempty"`
ExchangeFeeRates map[ExchangeName]ExchangeFee `json:"exchangeFeeRates"`
sync.Mutex
}
type FuturesPosition struct {
Symbol string `json:"symbol"`
BaseCurrency string `json:"baseCurrency"`
QuoteCurrency string `json:"quoteCurrency"`
Market Market `json:"market"`
Base fixedpoint.Value `json:"base"`
Quote fixedpoint.Value `json:"quote"`
AverageCost fixedpoint.Value `json:"averageCost"`
// ApproximateAverageCost adds the computed fee in quote in the average cost
// This is used for calculating net profit
ApproximateAverageCost fixedpoint.Value `json:"approximateAverageCost"`
FeeRate *ExchangeFee `json:"feeRate,omitempty"`
ExchangeFeeRates map[ExchangeName]ExchangeFee `json:"exchangeFeeRates"`
// Futures data fields
Isolated bool `json:"isolated"`
UpdateTime int64 `json:"updateTime"`