Browse Source

fix hold strategy

pull/24/head
ErwanFagnou 7 months ago
parent
commit
1b6f70503d
  1. 29
      auto_trading/strat/prop.py

29
auto_trading/strat/prop.py

@ -67,22 +67,23 @@ class Prop(Strategy):
# Create the new buy orders from with the delta between the actual and the desired state.
for stock, amount in desired_state_dolards.items():
if amount > state.stocks[stock]:
orders.append(
Long(
stock,
amount / conversion_rate[stock] - state.stocks[stock],
conversion_rate[stock],
if stock in state.stocks:
if amount > state.stocks[stock]:
orders.append(
Long(
stock,
amount / conversion_rate[stock] - state.stocks[stock],
conversion_rate[stock],
)
)
)
else:
orders.append(
Short(
stock,
state.stocks[stock] - amount / conversion_rate[stock],
conversion_rate[stock],
else:
orders.append(
Short(
stock,
state.stocks[stock] - amount / conversion_rate[stock],
conversion_rate[stock],
)
)
)
# Filter low orders
orders = list(filter(self.filter_order, orders))

Loading…
Cancel
Save