futures: Implement GetLatestFundingRates across exchanges (#1339)

* adds funding rate implementations and improvements

* merge fixes x1

* lint

* kucoin funding rates func make

* migrate sync-manager to keys

* some kucoin work

* adds some kucoin wrapper funcs

* ehhh, todo

* kucoin position

* start of orders

* adds the kucoin tests yay

* multiplier

* nits, EWS includes order limits

* NotYetImplemented, IsPerp improvements, cleaning

* lint, test fix, huobi time

* fixes issues, improves testing

* fixes linters I WRECKED

* local lint but remote lint, lint, lint, lint

* fixes err

* skip CI

* lint

* Supported rates, binance endpoints

* fixes weird mocktest problems

* no, CZ is invalid

* fixes some new EWS test errors
This commit is contained in:
Scott
2023-11-03 10:01:32 +10:00
committed by GitHub
parent f9437dbd08
commit 70690d9a04
78 changed files with 4088 additions and 527 deletions

View File

@@ -3584,3 +3584,22 @@ func TestGetContractLength(t *testing.T) {
t.Error("expected semi annually")
}
}
func TestIsPerpetualFutureCurrency(t *testing.T) {
t.Parallel()
enabled, err := b.GetEnabledPairs(asset.Futures)
if err != nil {
t.Fatal(err)
}
for x := range enabled {
isPerp, err := b.IsPerpetualFutureCurrency(asset.Futures, enabled[x])
if err != nil {
t.Fatal(err)
}
if enabled[x].Quote.Equal(currency.PFC) && !isPerp {
t.Error("expected true")
} else if !enabled[x].Quote.Equal(currency.PFC) && isPerp {
t.Error("expected false")
}
}
}

View File

@@ -17,6 +17,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/deposit"
"github.com/thrasher-corp/gocryptotrader/exchanges/fundingrate"
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
@@ -2416,3 +2417,14 @@ func getContractLength(contractLength time.Duration) (futures.ContractType, erro
}
return ct, nil
}
// IsPerpetualFutureCurrency ensures a given asset and currency is a perpetual future
func (by *Bybit) IsPerpetualFutureCurrency(a asset.Item, p currency.Pair) (bool, error) {
return a == asset.Futures && p.Quote.Equal(currency.PFC), nil
}
// GetLatestFundingRates returns the latest funding rates data
func (by *Bybit) GetLatestFundingRates(context.Context, *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error) {
// TODO: implement with v5 API upgrade
return nil, common.ErrNotYetImplemented
}