qbtrade/pkg/exchange/okex/okexapi/get_tickers_request.go

52 lines
1.5 KiB
Go
Raw Normal View History

2024-06-27 14:42:38 +00:00
package okexapi
import (
"github.com/c9s/requestgen"
"git.qtrade.icu/lychiyu/qbtrade/pkg/fixedpoint"
"git.qtrade.icu/lychiyu/qbtrade/pkg/types"
)
//go:generate -command GetRequest requestgen -method GET -responseType .APIResponse -responseDataField Data
//go:generate -command PostRequest requestgen -method POST -responseType .APIResponse -responseDataField Data
type MarketTicker struct {
InstrumentType string `json:"instType"`
InstrumentID string `json:"instId"`
// last traded price
Last fixedpoint.Value `json:"last"`
// last traded size
LastSize fixedpoint.Value `json:"lastSz"`
AskPrice fixedpoint.Value `json:"askPx"`
AskSize fixedpoint.Value `json:"askSz"`
BidPrice fixedpoint.Value `json:"bidPx"`
BidSize fixedpoint.Value `json:"bidSz"`
Open24H fixedpoint.Value `json:"open24h"`
High24H fixedpoint.Value `json:"high24H"`
Low24H fixedpoint.Value `json:"low24H"`
Volume24H fixedpoint.Value `json:"vol24h"`
VolumeCurrency24H fixedpoint.Value `json:"volCcy24h"`
// Millisecond timestamp
Timestamp types.MillisecondTimestamp `json:"ts"`
}
//go:generate GetRequest -url "/api/v5/market/tickers" -type GetTickersRequest -responseDataType []MarketTicker
type GetTickersRequest struct {
client requestgen.APIClient
instType InstrumentType `param:"instType,query" validValues:"SPOT"`
}
func (c *RestClient) NewGetTickersRequest() *GetTickersRequest {
return &GetTickersRequest{
client: c,
instType: InstrumentTypeSpot,
}
}