github.com/frankrap/okex-api@v1.0.4/futures_results.go (about)

     1  package okex
     2  
     3  /*
     4   OKEX futures contract api response results
     5   @author Tony Tian
     6   @date 2018-03-17
     7   @version 1.0.0
     8  */
     9  
    10  type ServerTime struct {
    11  	Iso   string `json:"iso"`
    12  	Epoch string `json:"epoch"`
    13  }
    14  
    15  type ExchangeRate struct {
    16  	InstrumentId string  `json:"instrument_id"`
    17  	Rate         float64 `json:"rate,string"`
    18  	Timestamp    string  `json:"timestamp"`
    19  }
    20  
    21  type BizWarmTips struct {
    22  	Code    int    `json:"code"`
    23  	Message string `json:"message"`
    24  	Msg     string `json:"msg"`
    25  }
    26  
    27  type Result struct {
    28  	Result bool `json:"result"`
    29  }
    30  
    31  type PageResult struct {
    32  	From  int
    33  	To    int
    34  	Limit int
    35  }
    36  
    37  type FuturesPosition struct {
    38  	BizWarmTips
    39  	Result
    40  	MarginMode    string
    41  	CrossPosition []FuturesCrossPositionHolding
    42  	FixedPosition []FuturesFixedPositionHolding
    43  }
    44  
    45  type FuturesCrossPosition struct {
    46  	Result
    47  	MarginMode    string                        `json:"margin_mode"`
    48  	CrossPosition []FuturesCrossPositionHolding `json:"holding"`
    49  }
    50  
    51  type FuturesFixedPosition struct {
    52  	Result
    53  	MarginMode    string                        `json:"margin_mode"`
    54  	FixedPosition []FuturesFixedPositionHolding `json:"holding"`
    55  }
    56  
    57  type FuturesCrossPositionHolding struct {
    58  	FuturesPositionBase
    59  	LiquidationPrice float64 `json:"liquidation_price,string"`
    60  	Leverage         float64 `json:"leverage,string"`
    61  }
    62  
    63  type FuturesFixedPositionHolding struct {
    64  	FuturesPositionBase
    65  	LongMargin      float64 `json:"long_margin,string"`
    66  	LongLiquiPrice  float64 `json:"long_liqui_price,string"`
    67  	LongPnlRatio    float64 `json:"long_pnl_ratio,string"`
    68  	LongLeverage    float64 `json:"long_leverage,string"`
    69  	ShortMargin     float64 `json:"short_margin,string"`
    70  	ShortLiquiPrice float64 `json:"short_liqui_price,string"`
    71  	ShortPnlRatio   float64 `json:"short_pnl_ratio,string"`
    72  	ShortLeverage   float64 `json:"short_leverage,string"`
    73  }
    74  
    75  type FuturesPositionBase struct {
    76  	LongQty              float64 `json:"long_qty,string"`
    77  	LongAvailQty         float64 `json:"long_avail_qty,string"`
    78  	LongAvgCost          float64 `json:"long_avg_cost,string"`
    79  	LongSettlementPrice  float64 `json:"long_settlement_price,string"`
    80  	RealizedPnl          float64 `json:"realized_pnl,string"`
    81  	ShortQty             float64 `json:"short_qty,string"`
    82  	ShortAvailQty        float64 `json:"short_avail_qty,string"`
    83  	ShortAvgCost         float64 `json:"short_avg_cost,string"`
    84  	ShortSettlementPrice float64 `json:"short_settlement_price,string"`
    85  	InstrumentId         string  `json:"instrument_id"`
    86  	CreatedAt            string  `json:"created_at"`
    87  	UpdatedAt            string  `json:"updated_at"`
    88  }
    89  
    90  type FuturesAccount struct {
    91  	BizWarmTips
    92  	Result
    93  	MarginMode   string
    94  	CrossAccount map[string]FuturesCrossAccount
    95  	FixedAccount map[string]FuturesFixedAccount
    96  }
    97  
    98  type FuturesAccountsContract struct {
    99  	AvailableQty      string  `json:"available_qty"`
   100  	FixedBalance      string  `json:"fixed_balance"`
   101  	InstrumentID      string  `json:"instrument_id"`
   102  	MarginForUnfilled string  `json:"margin_for_unfilled"`
   103  	MarginFrozen      string  `json:"margin_frozen"`
   104  	RealizedPnl       string  `json:"realized_pnl"`
   105  	UnrealizedPnl     string  `json:"unrealized_pnl"`
   106  	MarginRatio       string  `json:"margin_ratio"`
   107  	MaintMarginRatio  string  `json:"maint_margin_ratio"`
   108  	CanWithdraw       string  `json:"can_withdraw"`
   109  	Equity            string  `json:"equity"`
   110  	MarginMode        string  `json:"margin_mode"`
   111  	TotalAvailBalance float64 `json:"total_avail_balance,string"`
   112  	AutoMargin        string  `json:"auto_margin"`
   113  	Underlying        string  `json:"underlying"`
   114  }
   115  
   116  type GetFuturesAccountsResult struct {
   117  	Info struct {
   118  		Btc     FuturesAccountsContract `json:"btc"`
   119  		Eth     FuturesAccountsContract `json:"eth"`
   120  		Etc     FuturesAccountsContract `json:"etc"`
   121  		Ltc     FuturesAccountsContract `json:"ltc"`
   122  		Xrp     FuturesAccountsContract `json:"xrp"`
   123  		Bsv     FuturesAccountsContract `json:"bsv"`
   124  		Trx     FuturesAccountsContract `json:"trx"`
   125  		Bch     FuturesAccountsContract `json:"bch"`
   126  		Eos     FuturesAccountsContract `json:"eos"`
   127  		BtcUSDT FuturesAccountsContract `json:"btc-usdt"`
   128  		EthUSDT FuturesAccountsContract `json:"eth-usdt"`
   129  		EtcUSDT FuturesAccountsContract `json:"etc-usdt"`
   130  		LtcUSDT FuturesAccountsContract `json:"ltc-usdt"`
   131  		XrpUSDT FuturesAccountsContract `json:"xrp-usdt"`
   132  		BsvUSDT FuturesAccountsContract `json:"bsv-usdt"`
   133  		TrxUSDT FuturesAccountsContract `json:"trx-usdt"`
   134  		BchUSDT FuturesAccountsContract `json:"bch-usdt"`
   135  		EosUSDT FuturesAccountsContract `json:"eos-usdt"`
   136  	} `json:"info"`
   137  }
   138  
   139  type FuturesMarkdown struct {
   140  	BizWarmTips
   141  	InstrumentId string  `json:"instrument_id"`
   142  	Timestamp    string  `json:"timestamp"`
   143  	MarkPrice    float32 `json:"mark_price"`
   144  }
   145  
   146  type FuturesFixedAccountInfo struct {
   147  	Result
   148  	Info map[string]FuturesFixedAccount `json:"info"`
   149  }
   150  
   151  type FuturesCrossAccountInfo struct {
   152  	Result
   153  	Info map[string]FuturesCrossAccount `json:"info"`
   154  }
   155  
   156  type FuturesFixedAccount struct {
   157  	MarginMode        string                         `json:"margin_mode"`
   158  	Equity            float64                        `json:"equity,string"`
   159  	TotalAvailBalance float64                        `json:"total_avail_balance,string"`
   160  	Contracts         []FuturesFixedAccountContracts `json:"contracts"`
   161  }
   162  
   163  type FuturesFixedAccountContracts struct {
   164  	AvailableQty      float64 `json:"available_qty,string"`
   165  	FixedBalance      float64 `json:"fixed_balance,string"`
   166  	InstrumentId      string  `json:"instrument_id"`
   167  	MarginFixed       float64 `json:"margin_fixed,string"`
   168  	MarginForUnfilled float64 `json:"margin_for_unfilled,string"`
   169  	MarginFrozen      float64 `json:"margin_frozen,string"`
   170  	RealizedPnl       float64 `json:"realized_pnl,string"`
   171  	UnrealizedPnl     float64 `json:"unrealizedPnl,string"`
   172  }
   173  
   174  type FuturesCrossAccount struct {
   175  	Equity            float64 `json:"equity,string"`
   176  	Margin            float64 `json:"margin,string"`
   177  	MarginMode        string  `json:"margin_mode"`
   178  	MarginRatio       float64 `json:"margin_ratio,string"`
   179  	RealizedPnl       float64 `json:"realized_pnl,string"`
   180  	UnrealizedPnl     float64 `json:"unrealized_pnl,string"`
   181  	TotalAvailBalance float64 `json:"total_avail_balance,string"`
   182  }
   183  
   184  type FuturesCurrencyAccount struct {
   185  	TotalAvailBalance float64                        `json:"total_avail_balance,string"` // 账户余额(账户静态权益)
   186  	Contracts         []FuturesFixedAccountContracts `json:"contracts"`
   187  	Equity            float64                        `json:"equity,string"`         // 账户权益(账户动态权益)
   188  	MarginMode        string                         `json:"margin_mode"`           // 账户类型 全仓:crossed 逐仓: fixed
   189  	AutoMargin        int                            `json:"auto_margin,string"`    // 是否自动追加保证金 1: 自动追加已开启 0: 自动追加未开启
   190  	LiquiMode         string                         `json:"liqui_mode"`            // 强平模式:tier(梯度强平)
   191  	CanWithdraw       float64                        `json:"can_withdraw,string"`   // 可划转数量
   192  	RealizedPnl       float64                        `json:"realized_pnl,string"`   // 全仓模式 已实现盈亏
   193  	UnRealizedPnl     float64                        `json:"unrealized_pnl,string"` // 全仓模式 未实现盈亏
   194  	Margin            float64                        `json:"margin,string"`         // 保证金(挂单冻结+持仓已用)
   195  }
   196  
   197  type FuturesCurrencyAccountV0 struct {
   198  	BizWarmTips
   199  	Result
   200  	MarginMode   string
   201  	CrossAccount FuturesCrossAccount
   202  	FixedAccount FuturesFixedAccount
   203  }
   204  
   205  type FuturesCurrencyLedger struct {
   206  	LedgerId  int64                        `json:"ledger_id,string"`
   207  	Amount    float64                      `json:"amount,string"`
   208  	Balance   float64                      `json:"balance,string"`
   209  	Currency  string                       `json:"currency"`
   210  	Type      string                       `json:"type"`
   211  	Timestamp string                       `json:"timestamp"`
   212  	Details   FuturesCurrencyLedgerDetails `json:"details"`
   213  }
   214  
   215  type FuturesCurrencyLedgerDetails struct {
   216  	OrderId      string `json:"order_id"`
   217  	InstrumentId string `json:"instrument_id"`
   218  }
   219  
   220  type FuturesAccountsHolds struct {
   221  	InstrumentId string  `json:"instrument_id"`
   222  	Amount       float64 `json:"amount,string"`
   223  	Timestamp    string  `json:"timestamp"`
   224  }
   225  
   226  type FuturesNewOrderResult struct {
   227  	BizWarmTips
   228  	Result
   229  	ClientOid string `json:"client_oid"`
   230  	OrderId   string `json:"order_id"`
   231  }
   232  
   233  type FuturesBatchNewOrderResult struct {
   234  	Result
   235  	OrderInfo []OrderInfo `json:"order_info"`
   236  }
   237  
   238  type CodeMessage struct {
   239  	ErrorCode    int64  `json:"error_code"`
   240  	ErrorMessage string `json:"error_message"`
   241  }
   242  
   243  /*
   244    If OrderId = -1, ErrorCode > 0, error order
   245  */
   246  type OrderInfo struct {
   247  	ClientOid string `json:"client_oid"`
   248  	OrderId   string `json:"order_id"`
   249  	CodeMessage
   250  }
   251  
   252  type FuturesCancelInstrumentOrderResult struct {
   253  	Result
   254  	ErrorCode    int    `json:"error_code,string"`
   255  	ErrorMessage string `json:"error_message"`
   256  	OrderId      string `json:"order_id"`
   257  	ClientOid    string `json:"client_oid"`
   258  	InstrumentId string `json:"instrument_id"`
   259  }
   260  
   261  type FuturesBatchCancelInstrumentOrdersResult struct {
   262  	Result
   263  	OrderIds     []string `json:"order_ids"`
   264  	InstrumentId string   `json:"instrument_id"`
   265  }
   266  
   267  type FuturesClosePositionResult struct {
   268  	Result
   269  	ClosePositionInfo []ClosePositionInfo `json:"close_position_info"`
   270  }
   271  
   272  type ClosePositionInfo struct {
   273  	InstrumentId string `json:"instrument_id"`
   274  	CodeMessage
   275  }
   276  
   277  type FuturesGetOrdersResult struct {
   278  	Result
   279  	Orders []FuturesGetOrderResult `json:"order_info"`
   280  }
   281  
   282  type FuturesGetOrderResult struct {
   283  	InstrumentId string  `json:"instrument_id"`
   284  	Size         int64   `json:"size,string"`
   285  	Timestamp    string  `json:"timestamp"`
   286  	FilledQty    float64 `json:"filled_qty,string"`
   287  	Fee          float64 `json:"fee,string"`
   288  	OrderId      string  `json:"order_id"`
   289  	ClientOId    string  `json:"client_oid"`
   290  	Price        float64 `json:"price,string"`
   291  	PriceAvg     float64 `json:"price_avg,string"`
   292  	Status       string  `json:"status"`
   293  	State        int     `json:"state,string"`
   294  	Type         int     `json:"type,string"`
   295  	OrderType    int     `json:"order_type,string"`
   296  	ContractVal  float64 `json:"contract_val,string"`
   297  	Leverage     float64 `json:"leverage,string"`
   298  }
   299  
   300  type FuturesFillResult struct {
   301  	TradeId      int64   `json:"trade_id,string"`
   302  	InstrumentId string  `json:"instrument_id"`
   303  	Price        float64 `json:"price,string"`
   304  	OrderQty     float64 `json:"order_qty,string"`
   305  	OrderId      string  `json:"order_id"`
   306  	CreatedAt    string  `json:"created_at"`
   307  	ExecType     string  `json:"exec_type"`
   308  	Fee          float64 `json:"fee,string"`
   309  	Side         string  `json:"side"`
   310  }
   311  
   312  type FuturesUsersSelfTrailingVolumesResult struct {
   313  	FuturesUsersSelfTrailingVolumeResult []FuturesUsersSelfTrailingVolumeResult
   314  }
   315  
   316  type FuturesUsersSelfTrailingVolumeResult struct {
   317  	InstrumentId   string  `json:"instrument_id"`
   318  	ExchangeVolume float64 `json:"exchange_volume,string"`
   319  	Volume         float64 `json:"volume,string"`
   320  	RecordedAt     string  `json:"recorded_at"`
   321  }
   322  
   323  type FuturesInstrumentsResult struct {
   324  	InstrumentId        string  `json:"instrument_id"`
   325  	UnderlyingIndex     string  `json:"underlying_index"`
   326  	QuoteCurrency       string  `json:"quote_currency"`
   327  	TickSize            float64 `json:"tick_size,string"`
   328  	ContractVal         float64 `json:"contract_val,string"`
   329  	Listing             string  `json:"listing"`
   330  	Delivery            string  `json:"delivery"`
   331  	TradeIncrement      float64 `json:"trade_increment,string"`
   332  	Alias               string  `json:"alias"`
   333  	Underlying          string  `json:"underlying"`
   334  	BaseCurrency        string  `json:"base_currency"`
   335  	SettlementCurrency  string  `json:"settlement_currency"`
   336  	IsInverse           bool    `json:"is_inverse,string"`
   337  	ContractValCurrency string  `json:"contract_val_currency"`
   338  }
   339  
   340  type FuturesInstrumentCurrenciesResult struct {
   341  	Id      int64   `json:"id,string"`
   342  	Name    string  `json:"name"`
   343  	MinSize float64 `json:"min_size,string"`
   344  }
   345  
   346  type FuturesInstrumentBookResult struct {
   347  	Asks      [][]string `json:"asks"`
   348  	Bids      [][]string `json:"bids"`
   349  	Timestamp string     `json:"timestamp"`
   350  }
   351  
   352  type FuturesInstrumentTickerResult struct {
   353  	InstrumentId string  `json:"instrument_id"`
   354  	BestBid      float64 `json:"best_bid,string"`
   355  	BestAsk      float64 `json:"best_ask,string"`
   356  	High24h      float64 `json:"high_24h,string"`
   357  	Low24h       float64 `json:"low_24h,string"`
   358  	Last         float64 `json:"last,string"`
   359  	Volume24h    float64 `json:"volume_24h,string"`
   360  	Timestamp    string  `json:"timestamp"`
   361  }
   362  
   363  type FuturesInstrumentTradesResult struct {
   364  	TradeId   string  `json:"trade_id"`
   365  	Side      string  `json:"side"`
   366  	Price     float64 `json:"price,string"`
   367  	Qty       float64 `json:"qty,string"`
   368  	Timestamp string  `json:"timestamp"`
   369  }
   370  
   371  type FuturesInstrumentIndexResult struct {
   372  	InstrumentId string  `json:"instrument_id"`
   373  	Index        float64 `json:"index,string"`
   374  	Timestamp    string  `json:"timestamp"`
   375  }
   376  
   377  type FuturesInstrumentEstimatedPriceResult struct {
   378  	InstrumentId    string  `json:"instrument_id"`
   379  	SettlementPrice float64 `json:"settlement_price,string"`
   380  	Timestamp       string  `json:"timestamp"`
   381  }
   382  
   383  type FuturesInstrumentOpenInterestResult struct {
   384  	InstrumentId string `json:"instrument_id"`
   385  	Amount       int64  `json:"amount,string"`
   386  	Timestamp    string `json:"timestamp"`
   387  }
   388  
   389  type FuturesInstrumentPriceLimitResult struct {
   390  	InstrumentId string  `json:"instrument_id"`
   391  	Highest      float64 `json:"highest,string"`
   392  	Lowest       float64 `json:"lowest,string"`
   393  	Timestamp    string  `json:"timestamp"`
   394  }
   395  
   396  type FuturesInstrumentLiquidationListResult struct {
   397  	Page            PageResult
   398  	LiquidationList []FuturesInstrumentLiquidationResult
   399  }
   400  
   401  type FuturesInstrumentLiquidationResult struct {
   402  	InstrumentId string  `json:"instrument_id"`
   403  	Price        float64 `json:"price"`
   404  	Size         int64   `json:"size"`
   405  	Loss         float64 `json:"loss"`
   406  	CreatedAt    string  `json:"created_at"`
   407  }