Use Kelly allocation for Torch position scaling
This commit is contained in:
@@ -94,10 +94,7 @@ class PaperBroker:
|
||||
return False, "достигнут общий лимит открытых позиций"
|
||||
if self.settings.strategy_mode == "trend_macd" and len(self.positions_for_symbol(symbol)) >= 1:
|
||||
return False, "DCA/усреднение отключено: позиция по паре уже открыта"
|
||||
dynamic_pair_limit = max(
|
||||
self.settings.max_positions_per_symbol,
|
||||
int(self.settings.max_symbol_exposure_usdt // max(self.settings.min_position_usdt, 0.01)),
|
||||
)
|
||||
dynamic_pair_limit = _symbol_position_limit(self.settings)
|
||||
if len(self.positions_for_symbol(symbol)) >= dynamic_pair_limit:
|
||||
return False, "достигнут лимит позиций по паре"
|
||||
requested = requested_notional if requested_notional is not None else self.settings.min_position_usdt
|
||||
@@ -384,3 +381,12 @@ class LiveBroker(PaperBroker):
|
||||
|
||||
def prices_from_tickers(tickers: Iterable[Ticker]) -> dict[str, float]:
|
||||
return {ticker.symbol: ticker.last_price for ticker in tickers}
|
||||
|
||||
|
||||
def _symbol_position_limit(settings: Settings) -> int:
|
||||
configured_limit = max(1, settings.max_positions_per_symbol)
|
||||
exposure_based_limit = max(
|
||||
1,
|
||||
int(settings.max_symbol_exposure_usdt // max(settings.min_position_usdt, 0.01)),
|
||||
)
|
||||
return min(configured_limit, exposure_based_limit)
|
||||
|
||||
Reference in New Issue
Block a user