mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-23 07:26:47 +00:00
bithumb: Add websocket support (#745)
* bithumb: Add websocket support (WIP) * bithumb: cont impl. * bithumb: finish, issues with orderbook needs review * linter issues * bithumb: move to separate file * bithumb: change to pointer for book * bithumb: Add tests * bithumb: Address nits * websocket: Export subscription error and wrap returns * bithumb: cleanup/ fix tests * gctrpc/bithumb: fix misspelling * bithumb: gofmt * readme: update support table, regen doc * tradesReadme: update * readme: update template
This commit is contained in:
31
exchanges/bithumb/convert.go
Normal file
31
exchanges/bithumb/convert.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package bithumb
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// bithumbMSTime provides an internal conversion helper for microsecond parsing
|
||||
type bithumbTime time.Time
|
||||
|
||||
// UnmarshalJSON implements the unmarshal interface
|
||||
func (t *bithumbTime) UnmarshalJSON(data []byte) error {
|
||||
var timestamp string
|
||||
if err := json.Unmarshal(data, ×tamp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(timestamp, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*t = bithumbTime(time.Unix(0, i*int64(time.Microsecond)))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Time returns a time.Time object
|
||||
func (t bithumbTime) Time() time.Time {
|
||||
return time.Time(t)
|
||||
}
|
||||
Reference in New Issue
Block a user