From a7ff3efdcc4409cff70289c1c86ea8ac6ce5c6e5 Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Tue, 28 Oct 2025 12:56:36 +0700 Subject: [PATCH] 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 :/ --- exchanges/deribit/deribit.go | 4 +++- exchanges/deribit/deribit_test.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/exchanges/deribit/deribit.go b/exchanges/deribit/deribit.go index 3240b814..f020db7b 100644 --- a/exchanges/deribit/deribit.go +++ b/exchanges/deribit/deribit.go @@ -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 diff --git a/exchanges/deribit/deribit_test.go b/exchanges/deribit/deribit_test.go index 9df90d8e..9df942aa 100644 --- a/exchanges/deribit/deribit_test.go +++ b/exchanges/deribit/deribit_test.go @@ -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},