avantis_trader_sdk.rpc package

Submodules

avantis_trader_sdk.rpc.asset_parameters module

class avantis_trader_sdk.rpc.asset_parameters.AssetParametersRPC(client)[source]

Bases: object

This class provides methods to retrieve and calculate various asset parameters related to open interest, open interest limits, and asset utilization.

async get_asset_skew()[source]

Calculates the asset skew for all trading pairs.

Returns:

An Skew instance containing the asset skew absolute value for each trading pair.

async get_oi()[source]

Retrieves the current open interest for all trading pairs.

Returns:

An OpenInterest instance containing the long and short open interest ratios for each trading pair.

async get_oi_limits()[source]

Retrieves the open interest limits for all trading pairs.

Returns:

An OpenInterestLimits instance containing the open interest limits for each trading pair.

async get_one_percent_depth()[source]

Retrieves the one percent depth for all trading pairs.

Returns:

A Depth instance containing the one percent depth for each trading pair.

async get_opening_price_impact_spread(pair, position_size=0, open_price=0, is_long=None)[source]

Retrieves the trade price impact spread for pair.

Parameters:
  • pair (str) – The trading pair for which the price impact is to be calculated.

  • position_size (int) – The size of the position (collateral * leverage). Supports upto 6 decimals. Defaults to 0.

  • open_price (float) – The price at which the position was opened. Supports upto 10 decimals. Defaults to 0.

  • is_long (Optional[bool]) – A boolean indicating if the position is a buy or sell. Defaults to None. If None, the price impact for both buy and sell will be returned.

Returns:

A Spread instance containing the trade price impact for pair in bps.

async get_price_impact_spread(position_size=0, is_long=None, pair=None)[source]

Retrieves the price impact spread for all trading pairs.

Parameters:
  • is_long (Optional[bool]) – A boolean indicating if the position is a buy or sell. Defaults to None. If None, the price impact spread for both buy and sell will be returned.

  • position_size (int) – The size of the position (collateral * leverage). Supports upto 6 decimals. Defaults to 0.

  • pair (str) – The trading pair for which the price impact spread is to be calculated. Defaults to None. If None, the price impact spread for all trading pairs will be returned.

Returns:

A Spread instance containing the price impact spread for each trading pair in bps.

async get_skew_impact_spread(position_size=0, is_long=None, pair=None)[source]

Retrieves the skew impact spread for all trading pairs.

Parameters:
  • is_long (Optional[bool]) – A boolean indicating if the position is a buy or sell. Defaults to None. If None, the skew impact spread for both buy and sell will be returned.

  • position_size (int) – The size of the position (collateral * leverage). Supports upto 6 decimals. Defaults to 0.

  • pair (str) – The trading pair for which the skew impact spread is to be calculated. Defaults to None. If None, the skew impact spread for all trading pairs will be returned.

Returns:

A Spread instance containing the skew impact spread for each trading pair in bps.

async get_utilization()[source]

Calculates the asset utilization for all trading pairs.

Returns:

A Utilization instance containing the asset utilization absolute value for each trading pair.

avantis_trader_sdk.rpc.blended module

class avantis_trader_sdk.rpc.blended.BlendedRPC(client)[source]

Bases: object

This class provides methods to retrieve and calculate various blended parameters

async get_blended_skew()[source]

Retrieves the blended skew for all trading pairs.

Returns:

A Skew instance containing the blended skew for each trading pair.

async get_blended_utilization_ratio()[source]

Retrieves the blended utilization ratio for all trading pairs.

Returns:

A Utilization instance containing the blended utilization ratio for each trading pair.

avantis_trader_sdk.rpc.category_parameters module

class avantis_trader_sdk.rpc.category_parameters.CategoryParametersRPC(client)[source]

Bases: object

This class provides methods to retrieve and calculate various category parameters related to open interest, open interest limits, and category utilization.

async get_category_skew()[source]

Calculates the category skew for all categories.

Returns:

An Skew instance containing the category skew absolute value for each category.

async get_oi()[source]

Retrieves the current open interest for all categories.

Returns:

An OpenInterest instance containing the long and short open interest

async get_oi_limits()[source]

Retrieves the open interest limits for all categories.

Returns:

An OpenInterestLimits instance containing the open interest limits. The index of the list corresponds to the category index.

async get_utilization()[source]

Calculates the category utilization for all categories.

Returns:

A Utilization instance containing the category utilization absolute value for each category.

avantis_trader_sdk.rpc.fee_parameters module

class avantis_trader_sdk.rpc.fee_parameters.FeeParametersRPC(client)[source]

Bases: object

This class provides methods to retrieve and calculate various fee parameters related to trades.

async constant_spread_parameter()[source]

Retrieves the spread for all trading pairs.

Returns:

A PairSpread instance containing the spread for each trading pair in bps.

async get_margin_fee()[source]

Retrieves the margin fee for all trading pairs.

Returns:

A MarginFee instance containing the margin fee for each trading pair in bps.

async get_opening_fee(position_size=0, is_long=None, pair_index=None, pair=None, trade_input=None)[source]

Retrieves the opening fee for all trading pairs.

Parameters:
  • is_long (Optional[bool]) – A boolean indicating if the position is a buy or sell. Defaults to None. If None, the opening fee for both buy and sell will be returned.

  • position_size (float) – The size of the position (collateral * leverage). Supports upto 6 decimals. Defaults to 0.

  • pair_index (int) – The pair index for which the opening fee is to be calculated. Defaults to None. If None, the opening fee for all trading pairs will be returned.

  • pair (str) – The trading pair for which the opening fee is to be calculated. Defaults to None. If None, the opening fee for all trading pairs will be returned.

  • trade_input (TradeInput) – The trade input object. Defaults to None. If provided, the pair index will be extracted from the trade input.

Returns:

A Fee instance containing the opening Fee for each trading pair in bps or final opening fee in USDC if trade_input is provided.

avantis_trader_sdk.rpc.pairs_cache module

class avantis_trader_sdk.rpc.pairs_cache.PairsCache(client)[source]

Bases: object

This class provides methods to retrieve pairs information from the blockchain.

async get_group_indexes()[source]

Retrieves the group ids from the blockchain.

Returns:

The group ids as a set.

async get_pair_index(pair)[source]

Retrieves the index of a pair from the blockchain.

Parameters:

pair – The pair to retrieve the index for. Expects a string in the format “from/to”.

Returns:

The index of the pair as an integer.

Raises:

ValueError – If the pair is not found in the pairs information.

async get_pair_name_from_index(pair_index)[source]

Retrieves the pair name from the index.

Parameters:

pair_index – The pair index.

Returns:

The pair name.

async get_pairs_count()[source]

Retrieves the number of pairs from the blockchain.

Returns:

The number of pairs as an integer.

async get_pairs_info(force_update=False)[source]

Retrieves the pairs information from the blockchain. The information is cached and will be returned from the cache if it is available and force_update is False. This is to avoid unnecessary calls to the blockchain.

Parameters:

force_update – If True, the cache will be ignored and the information will be retrieved from the blockchain. Defaults to False.

Returns:

A dictionary containing the pairs information.

avantis_trader_sdk.rpc.rpc_helpers module

avantis_trader_sdk.rpc.rpc_helpers.map_output_to_pairs(pairs_info, decoded_response)[source]

Module contents