mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 15:11:03 +00:00
exchanges/futures: Implement open interest (#1417)
* adds open interest to exchanges * ADDS TESTING YEAH * New endpoints, BTSE, RPCS, cached * slight design change, begin gateio You will need to get cached for each exchange that supports it * gateio, huobi, rpc * fix up kraken, cache retrieval * okx, gateio * finalising all implementations and tests * definitely my final ever commit on this * Well, well, well * final v2 * quick fix of bug * test coverage, assert notempty, test helper Added a new testhelper for currency management because its very annoying in a parallel test setting which wastes so much space otherwise * minimises REST requests for Open Interest * types.Number merge misses * Minimises Kraken REST calls * len change, value -> pointer receiver * further fixup * fixes gateio, batch calculates open interest * single gateio, lint const fixes * rejig and more thorough oi for huobi * formatting expansion * minor fix for handling expiring contracts * rm unused Binance strings * add bybit support, fix bybit issues * oopsie doopsie, dont look at my whoopsie * Fix issue, remove feature * move an irrelevant function for the pr * mini bybit upgrades * fixes cli request bug
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/common/key"
|
||||
"github.com/thrasher-corp/gocryptotrader/core"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
||||
@@ -629,22 +630,6 @@ func TestGetFuturesExchangeInfo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetUndocumentedInterestHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetUndocumentedInterestHistory(context.Background())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCrossMarginInterestHistory(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetCrossMarginInterestHistory(context.Background())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFuturesOrderbook(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetFuturesOrderbook(context.Background(), currency.NewPairWithDelimiter("BTCUSD", "PERP", "_"), 1000)
|
||||
@@ -796,9 +781,9 @@ func TestGetFuturesOrderbookTicker(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetOpenInterest(t *testing.T) {
|
||||
func TestOpenInterest(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetOpenInterest(context.Background(), currency.NewPairWithDelimiter("BTCUSD", "PERP", "_"))
|
||||
_, err := b.OpenInterest(context.Background(), currency.NewPairWithDelimiter("BTCUSD", "PERP", "_"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -3432,3 +3417,29 @@ func TestUGetFundingRateInfo(t *testing.T) {
|
||||
_, err := b.UGetFundingRateInfo(context.Background())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestGetOpenInterest(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp, err := b.GetOpenInterest(context.Background(), key.PairAsset{
|
||||
Base: currency.BTC.Item,
|
||||
Quote: currency.USDT.Item,
|
||||
Asset: asset.USDTMarginedFutures,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, resp)
|
||||
|
||||
resp, err = b.GetOpenInterest(context.Background(), key.PairAsset{
|
||||
Base: currency.NewCode("BTCUSD").Item,
|
||||
Quote: currency.PERP.Item,
|
||||
Asset: asset.CoinMarginedFutures,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, resp)
|
||||
|
||||
_, err = b.GetOpenInterest(context.Background(), key.PairAsset{
|
||||
Base: currency.BTC.Item,
|
||||
Quote: currency.USDT.Item,
|
||||
Asset: asset.Spot,
|
||||
})
|
||||
assert.ErrorIs(t, err, asset.ErrNotSupported)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user