Bybit: Add support for SOL options (#1533)

This commit is contained in:
Scott
2024-05-06 16:23:19 +10:00
committed by GitHub
parent 3ee65b92b1
commit ece58ebf6d
3 changed files with 58176 additions and 13849 deletions

View File

@@ -13,6 +13,9 @@ import (
var validCategory = []string{"spot", "linear", "inverse", "option"}
// supportedOptionsTypes Bybit does not offer a way to retrieve option denominations via its API
var supportedOptionsTypes = []string{"BTC", "ETH", "SOL"}
type orderbookResponse struct {
Symbol string `json:"s"`
Asks [][2]string `json:"a"`

View File

@@ -266,6 +266,9 @@ func (by *Bybit) AuthenticateWebsocket(ctx context.Context) error {
// FetchTradablePairs returns a list of the exchanges tradable pairs
func (by *Bybit) FetchTradablePairs(ctx context.Context, a asset.Item) (currency.Pairs, error) {
if !by.SupportsAsset(a) {
return nil, fmt.Errorf("%s %w", a, asset.ErrNotSupported)
}
var pair currency.Pair
var category string
format, err := by.GetPairFormat(a, false)
@@ -287,13 +290,19 @@ func (by *Bybit) FetchTradablePairs(ctx context.Context, a asset.Item) (currency
allPairs = response.List
case asset.Options:
category = getCategoryName(a)
baseCoins := []string{"BTC", "ETH"}
for x := range baseCoins {
response, err = by.GetInstrumentInfo(ctx, category, "", "Trading", baseCoins[x], "", int64(by.Features.Enabled.Kline.GlobalResultLimit))
if err != nil {
return nil, err
for x := range supportedOptionsTypes {
var bookmark = ""
for {
response, err = by.GetInstrumentInfo(ctx, category, "", "Trading", supportedOptionsTypes[x], bookmark, int64(by.Features.Enabled.Kline.GlobalResultLimit))
if err != nil {
return nil, err
}
allPairs = append(allPairs, response.List...)
if response.NextPageCursor == "" || (bookmark != "" && bookmark == response.NextPageCursor) || len(response.List) == 0 {
break
}
bookmark = response.NextPageCursor
}
allPairs = append(allPairs, response.List...)
}
default:
return nil, fmt.Errorf("%w %v", asset.ErrNotSupported, a)
@@ -432,9 +441,8 @@ func (by *Bybit) UpdateTickers(ctx context.Context, assetType asset.Item) error
}
}
case asset.Options:
baseCoins := []string{"BTC", "ETH"}
for x := range baseCoins {
ticks, err = by.GetTickers(ctx, getCategoryName(assetType), "", baseCoins[x], time.Time{})
for x := range supportedOptionsTypes {
ticks, err = by.GetTickers(ctx, getCategoryName(assetType), "", supportedOptionsTypes[x], time.Time{})
if err != nil {
return err
}