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

@@ -18,6 +18,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"
@@ -125,6 +126,7 @@ func (b *Bitfinex) SetDefaults() {
MultiChainDeposits: true,
MultiChainWithdrawals: true,
MultiChainDepositRequiresChainSet: true,
FundingRateFetching: true,
},
WebsocketCapabilities: protocol.Features{
AccountBalance: true,
@@ -150,6 +152,15 @@ func (b *Bitfinex) SetDefaults() {
DateRanges: true,
Intervals: true,
},
FuturesCapabilities: exchange.FuturesCapabilities{
FundingRates: true,
SupportedFundingRateFrequencies: map[kline.Interval]bool{
kline.EightHour: true,
},
FundingRateBatching: map[asset.Item]bool{
asset.Margin: true,
},
},
},
Enabled: exchange.FeaturesEnabled{
AutoPairUpdates: true,
@@ -362,12 +373,9 @@ func (b *Bitfinex) UpdateTickers(ctx context.Context, a asset.Item) error {
for key, val := range tickerNew {
pair, enabled, err := b.MatchSymbolCheckEnabled(key[1:], a, true)
if err != nil {
if !errors.Is(err, currency.ErrPairNotFound) {
return err
}
if err != nil && !errors.Is(err, currency.ErrPairNotFound) {
return err
}
if !enabled {
continue
}
@@ -1297,3 +1305,9 @@ func (b *Bitfinex) GetServerTime(_ context.Context, _ asset.Item) (time.Time, er
func (b *Bitfinex) GetFuturesContractDetails(context.Context, asset.Item) ([]futures.Contract, error) {
return nil, common.ErrFunctionNotSupported
}
// GetLatestFundingRates returns the latest funding rates data
func (b *Bitfinex) GetLatestFundingRates(context.Context, *fundingrate.LatestRateRequest) ([]fundingrate.LatestRateResponse, error) {
// TODO: Add futures support for Bitfinex
return nil, common.ErrNotYetImplemented
}