Skip to content

Commit

Permalink
feat: buy ticket for optimal portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
WLM1ke committed Mar 3, 2025
1 parent 8083e7d commit 3e3e0c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions poptimizer/use_cases/portfolio/forecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,22 @@ def _update_forecast(

forecast.risk_tolerance = median_risk_tol.item() # type: ignore[reportUnknownMemberType]

bye_grad, bye_ticker = max((pos.grad_lower, pos.ticker) for pos in forecast.positions)
buy_grad, buy_ticker = max((pos.grad_lower, pos.ticker) for pos in forecast.positions)
sell_grad, sell_ticker = min((pos.grad_upper, pos.ticker) for pos in forecast.positions if pos.weight)

match bye_grad > sell_grad:
match buy_grad > sell_grad:
case True:
self._lgr.warning(
"New %d forecasts update - sell %s and buy %s",
forecast.forecasts_count,
sell_ticker,
bye_ticker,
buy_ticker,
)
case False:
self._lgr.warning(
"New %d forecasts update - portfolio is close to optimal optimization is not required",
"New %d forecasts update - portfolio is close to optimal, allocate free cash to %s",
forecast.forecasts_count,
buy_ticker,
)


Expand Down

0 comments on commit 3e3e0c6

Please sign in to comment.