mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
okex: implement query ticker
This commit is contained in:
parent
3511bcf13f
commit
d8c6545d2d
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
// OKB is the platform currency of OKEx, pre-allocate static string here
|
||||
const OKB = "OKB"
|
||||
|
||||
|
@ -81,7 +80,23 @@ func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error) {
|
|||
}
|
||||
|
||||
func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error) {
|
||||
return nil, nil
|
||||
symbol = toLocalSymbol(symbol)
|
||||
|
||||
marketTicker, err := e.client.MarketTicker(symbol)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.Ticker{
|
||||
Time: marketTicker.Timestamp.Time(),
|
||||
Volume: marketTicker.Volume24H.Float64(),
|
||||
Last: marketTicker.Last.Float64(),
|
||||
Open: marketTicker.Open24H.Float64(),
|
||||
High: marketTicker.High24H.Float64(),
|
||||
Low: marketTicker.Low24H.Float64(),
|
||||
Buy: marketTicker.BidPrice.Float64(),
|
||||
Sell: marketTicker.AskPrice.Float64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) QueryTickers(ctx context.Context, symbol string) (*types.Ticker, error) {
|
||||
|
|
|
@ -14,6 +14,10 @@ func (t MillisecondTimestamp) String() string {
|
|||
return time.Time(t).String()
|
||||
}
|
||||
|
||||
func (t MillisecondTimestamp) Time() time.Time {
|
||||
return time.Time(t)
|
||||
}
|
||||
|
||||
func (t *MillisecondTimestamp) UnmarshalJSON(data []byte) error {
|
||||
var v interface{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user