mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Binance,OKx: Implement fetching funding rates (#1239)
* adds basic groundwork for rates on binance * more into rates on binance * rm redudant redundancy, add payments * mini commit before merging with testnet ability branch * changes function signature and fixes resulting build * gets billing data too * funding rates package, features use, testnet reimpl * new endpoint, refinements and tests * cli fix, rpc impl, testing, payments * fixups from looking at code * typo fix * niteroos * merge fixes * adds test, fixes cli issues * woah nelly
This commit is contained in:
@@ -226,3 +226,10 @@ func (f *StringToFloat64) UnmarshalJSON(data []byte) error {
|
||||
func (f *StringToFloat64) Float64() float64 {
|
||||
return float64(*f)
|
||||
}
|
||||
|
||||
// Decimal returns the decimal value of the FloatString
|
||||
// Warning: this does not handle big numbers as the underlying
|
||||
// is still a float
|
||||
func (f *StringToFloat64) Decimal() decimal.Decimal {
|
||||
return decimal.NewFromFloat(float64(*f))
|
||||
}
|
||||
|
||||
@@ -355,6 +355,20 @@ func TestStringToFloat64(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStringToFloat64Decimal(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := struct {
|
||||
Data StringToFloat64 `json:"data"`
|
||||
}{}
|
||||
err := json.Unmarshal([]byte(`{"data":"0.00000001"}`), &resp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !resp.Data.Decimal().Equal(decimal.NewFromFloat(0.00000001)) {
|
||||
t.Errorf("received '%v' expected '%v'", resp.Data.Decimal(), 0.00000001)
|
||||
}
|
||||
}
|
||||
|
||||
// 2677173 428.9 ns/op 240 B/op 5 allocs/op
|
||||
func BenchmarkStringToFloat64(b *testing.B) {
|
||||
resp := struct {
|
||||
|
||||
Reference in New Issue
Block a user