mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Deribit: Fix future_combo instrument parsing and enhance tests (#2094)
Deribit seems to have opened up more instruments for future combos and is using a `-` delimiter in them, throwing off our parsing rule that it's always 3 parts for them. This change adds in the "FS" part, which seems consistent. I would have added checking for such a part to option_combo but some of them are missing it :/
This commit is contained in:
@@ -2619,7 +2619,9 @@ func getAssetFromInstrument(instrument string) (asset.Item, error) {
|
||||
return asset.Futures, nil
|
||||
case currencySuffix == "C", currencySuffix == "P": // options end in P or C to denote puts or calls eg BTC-26SEP25-30000-C
|
||||
return asset.Options, nil
|
||||
case partsLen == 3: // futures combos have 3 parts eg BTC-FS-12SEP25_PERP
|
||||
case partsLen >= 3 && currencyParts[partsLen-2] == "FS" && strings.Contains(currencySuffix, currency.UnderscoreDelimiter):
|
||||
// futures combos have underlying-FS-shortLeg_longLeg
|
||||
// eg BTC-FS-28NOV25_PERP or BTC-USDC-FS-28NOV25_PERP
|
||||
return asset.FutureCombo, nil
|
||||
case partsLen == 4: // option combos with more than 3 parts eg BTC_USDC-PS-19SEP25-113000_111000
|
||||
return asset.OptionCombo, nil
|
||||
|
||||
@@ -3551,7 +3551,12 @@ func TestGetAssetFromInstrument(t *testing.T) {
|
||||
{"PAXG_USDC-12SEP25-3320-P", asset.Options, nil},
|
||||
{"ETH-3OCT25-4800-P", asset.Options, nil},
|
||||
{"ETH-FS-26JUN26_26DEC25", asset.FutureCombo, nil},
|
||||
{"BTC-FS-28NOV25_PERP", asset.FutureCombo, nil},
|
||||
{"BTC-USDC-FS-28NOV25_PERP", asset.FutureCombo, nil},
|
||||
{"BTC_USDC-PBUT-31OCT25-90000_100000_102000", asset.OptionCombo, nil},
|
||||
{"BTC_USDC-CS-31OCT25-107000_111000", asset.OptionCombo, nil},
|
||||
{"BTC-ICOND-14NOV25-100000_105000_125000_130000", asset.OptionCombo, nil},
|
||||
{"BTC-PCAL-14NOV25_7NOV25-112000", asset.OptionCombo, nil},
|
||||
{"XRP_USDC-CBUT-26SEP25-2d9_3d2_3d4", asset.OptionCombo, nil},
|
||||
{"ETH-CS-26SEP25-5000_5500", asset.OptionCombo, nil},
|
||||
{"HELLOMOTO", asset.Empty, errUnsupportedInstrumentFormat},
|
||||
|
||||
Reference in New Issue
Block a user