-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Feature Request
Problem Statement
I am trying to trade Kraken Stocks (also known as xstock or tokenized assets) using Nautilus Trader, but they are currently not discovered by the KrakenInstrumentProvider.
Current Limitations:
- When initializing
KrakenInstrumentProviderwithload_all=True, only crypto pairs are fetched. Stock pairs (e.g.,TSLAx/USD,AAPLx/USD) are missing. - I attempted to manually inject the Instrument into the
TradingNodecache (constructing theCurrencyPairmanually). However, this results in anOrderRejectedevent withInstrument not found in cachewhen the execution client attempts to process the order. This suggests the underlying Kraken Adapter does not recognize the symbol because it wasn't returned in the initial API handshake.
Root Cause Analysis:
Upon checking the Kraken API documentation, the AssetPairs endpoint filters by aclass_base (Asset Class Base).
- Default value:
currency(Spot crypto pairs). - Required value for stocks:
tokenized_asset.
The current implementation seems to default to currency, ignoring tokenized_asset.
Proposed Solution
Update the KrakenInstrumentProvider (and potentially KrakenDataClientConfig) to support fetching tokenized assets.
Specific API Details:
- Endpoint:
https://api.kraken.com/0/public/AssetPairs - Parameter:
aclass_base
To support stocks, the adapter needs to either:
- Automatically fetch both
currencyandtokenized_assetwhenload_all=True(fetching them in two requests or merging results). - Or allow the user to specify the asset class in the configuration.
Example Usage
Ideally, I would like to be able to configure the client to include these assets.
Option A: Implicitly supported when requesting SPOT
provider_config = InstrumentProviderConfig(
load_all=True # Should fetch both crypto and xstocks automatically
)Option B: Explicit configuration via product_types or a new config field
data_client_config = KrakenDataClientConfig(
product_types=(
KrakenProductType.SPOT,
# Potential new enum member or config flag?
# KrakenProductType.STOCK,
),
environment=KrakenEnvironment.MAINNET,
instrument_provider=provider_config,
)Alternatives Considered
I attempted to manually construct and inject the instrument to bypass the provider loading logic, but the Execution Client rejected the order.
My failed workaround attempt:
I manually defined the Currency (ZUSD, GOOGLx) and CurrencyPair (GOOGLx/USD.KRAKEN as a test proxy for a stock) and added them to node.cache.
# Manually adding instrument to cache
manual_instrument = CurrencyPair(
instrument_id=InstrumentId.from_str("GOOGLx/USD.KRAKEN"),
raw_symbol=Symbol("GOOGLxUSD"),
# ... (other params)
)
node.cache.add_instrument(manual_instrument)Result:
The node starts, but upon sending an order:
[WARN] ... OrderRejected ... reason='Instrument not found in cache: GOOGLx/USD.KRAKEN'
This confirms that the internal adapter mapping requires the asset to be fetched and validated from the API correctly, and manual cache injection is insufficient.
Additional Context
Reference from Kraken Docs:
aclass_base (string)
Possible values:[currency, tokenized_asset]
Filters the asset class to retrieve (optional).
currency= spot currency pairs.tokenized_asset= tokenized asset pairs, i.e. xstocks.- Default value:
currency