diff --git a/pkg/exchange/okex/exchange.go b/pkg/exchange/okex/exchange.go index 15a16fb7a..0c667fe89 100644 --- a/pkg/exchange/okex/exchange.go +++ b/pkg/exchange/okex/exchange.go @@ -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) { diff --git a/pkg/types/time.go b/pkg/types/time.go index 5781dd865..b82587cc6 100644 --- a/pkg/types/time.go +++ b/pkg/types/time.go @@ -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{}