Skip to content

Commit

Permalink
[IndexTrading] add rebalance logs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Nov 17, 2024
1 parent 7da9914 commit cc63932
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Trading/Mode/index_trading_mode/index_trading.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,28 @@ async def _rebalance_portfolio(self, details: dict):
orders = []
try:
# 1. make sure we can actually rebalance the portfolio
self.logger.info("Step 1/3: ensuring enough funds are available for rebalance")
await self._ensure_enough_funds_to_buy_after_selling()
# 2. sell indexed coins for reference market
self.logger.info(
f"Step 2/3: selling coins to free "
f"{self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market}"
)
orders += await self._sell_indexed_coins_for_reference_market(details)
# 3. split reference market into indexed coins
self.logger.info(
f"Step 3/3: buying coins using "
f"{self.exchange_manager.exchange_personal_data.portfolio_manager.reference_market}"
)
orders += await self._split_reference_market_into_indexed_coins(details)
except trading_errors.MissingMinimalExchangeTradeVolume as err:
self.logger.warning(f"Aborting rebalance on {self.exchange_manager.exchange_name}: {err}")
self._update_producer_last_activity(
IndexActivity.REBALANCING_SKIPPED,
RebalanceSkipDetails.NOT_ENOUGH_AVAILABLE_FOUNDS.value
)
finally:
self.logger.info("Portoflio rebalance complete")
return orders

async def _sell_indexed_coins_for_reference_market(self, details: dict) -> list:
Expand Down

0 comments on commit cc63932

Please sign in to comment.