Skip to content

[Kraken] Add support for stocks/equities (xstock) via aclass_base='tokenized_asset' #3455

@jilongjia

Description

@jilongjia

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:

  1. When initializing KrakenInstrumentProvider with load_all=True, only crypto pairs are fetched. Stock pairs (e.g., TSLAx/USD, AAPLx/USD) are missing.
  2. I attempted to manually inject the Instrument into the TradingNode cache (constructing the CurrencyPair manually). However, this results in an OrderRejected event with Instrument not found in cache when 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:

  1. Automatically fetch both currency and tokenized_asset when load_all=True (fetching them in two requests or merging results).
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapterNautilus integration with external systemsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions