Skip to content

Commit

Permalink
feat: add perpetual support to liquidity provisioner in service.py
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel1302 committed Aug 31, 2023
1 parent 974f04b commit 8fb2c8d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions vega_sim/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,18 @@ def asset_decimals(self) -> int:
@property
def market_to_asset(self) -> str:
if self._market_to_asset is None:
self._market_to_asset = DecimalsCache(
lambda market_id: self.data_cache.market_from_feed(
def get_settlement_asset(market_id):
market_data = self.data_cache.market_from_feed(
market_id=market_id
).tradable_instrument.instrument.future.settlement_asset
)

settlement_asset_id = market_data.tradable_instrument.instrument.future.settlement_asset
if len(settlement_asset_id) < 1:
settlement_asset_id = market_data.tradable_instrument.instrument.perpetual.settlement_asset
return settlement_asset_id

self._market_to_asset = DecimalsCache(
get_settlement_asset,
)
return self._market_to_asset

Expand Down Expand Up @@ -1437,9 +1445,13 @@ def submit_simple_liquidity(
wallet_name:
str, The name of the wallet which is placing the order
"""
asset_id = data_raw.market_info(

market_data = data_raw.market_info(
market_id=market_id, data_client=self.trading_data_client_v2
).tradable_instrument.instrument.future.settlement_asset
)
asset_id = market_data.tradable_instrument.instrument.future.settlement_asset
if len(asset_id) < 1:
asset_id = market_data.tradable_instrument.instrument.perpetual.settlement_asset

market_decimals = data.market_price_decimals(
market_id=market_id, data_client=self.trading_data_client_v2
Expand Down

0 comments on commit 8fb2c8d

Please sign in to comment.