Move order settings to OrderSettings
This commit is contained in:
@@ -67,7 +67,7 @@ def get_trade_size_in_base(direction, account, strategy, cash_balance, base):
|
||||
"""
|
||||
|
||||
# Convert the trade size in percent to a ratio
|
||||
trade_size_as_ratio = D(strategy.trade_size_percent) / D(100)
|
||||
trade_size_as_ratio = D(strategy.order_settings.trade_size_percent) / D(100)
|
||||
log.debug(f"Trade size as ratio: {trade_size_as_ratio}")
|
||||
|
||||
# Multiply with cash balance to get the trade size in the account's
|
||||
@@ -146,16 +146,23 @@ def get_tp_sl(direction, strategy, price, round_to=None):
|
||||
:return: Take profit and stop loss prices
|
||||
"""
|
||||
cast = {}
|
||||
if strategy.take_profit_percent != 0:
|
||||
cast["take_profit"] = get_tp(direction, strategy.take_profit_percent, price)
|
||||
if strategy.order_settings.take_profit_percent != 0:
|
||||
cast["take_profit"] = get_tp(
|
||||
direction, strategy.order_settings.take_profit_percent, price
|
||||
)
|
||||
|
||||
if strategy.stop_loss_percent != 0:
|
||||
cast["stop_loss"] = get_sl(direction, strategy.stop_loss_percent, price)
|
||||
if strategy.order_settings.stop_loss_percent != 0:
|
||||
cast["stop_loss"] = get_sl(
|
||||
direction, strategy.order_settings.stop_loss_percent, price
|
||||
)
|
||||
|
||||
# Look up the TSL if required by the strategy
|
||||
if strategy.trailing_stop_loss_percent != 0:
|
||||
if strategy.order_settings.trailing_stop_loss_percent != 0:
|
||||
cast["trailing_stop_loss"] = get_sl(
|
||||
direction, strategy.trailing_stop_loss_percent, price, return_var=True
|
||||
direction,
|
||||
strategy.order_settings.trailing_stop_loss_percent,
|
||||
price,
|
||||
return_var=True,
|
||||
)
|
||||
|
||||
if round_to:
|
||||
@@ -412,7 +419,7 @@ def execute_strategy(callback, strategy, func):
|
||||
else:
|
||||
log.debug(f"Trend check passed for {symbol} - {direction}")
|
||||
|
||||
type = strategy.order_type
|
||||
type = strategy.order_settings.order_type
|
||||
|
||||
# Get the account's balance in the native account currency
|
||||
cash_balance = strategy.account.client.get_balance()
|
||||
@@ -450,7 +457,7 @@ def execute_strategy(callback, strategy, func):
|
||||
signal=signal,
|
||||
symbol=symbol,
|
||||
type=type,
|
||||
time_in_force=strategy.time_in_force,
|
||||
time_in_force=strategy.order_settings.time_in_force,
|
||||
# amount_fiat=amount_fiat,
|
||||
amount=amount_rounded,
|
||||
# price=price_bound,
|
||||
|
||||
Reference in New Issue
Block a user