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:
Scott
2023-07-26 14:25:43 +10:00
committed by GitHub
parent 2ad9304045
commit 471f4f21c4
39 changed files with 5785 additions and 3416 deletions

View File

@@ -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))
}

View File

@@ -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 {