Hello all, I am looking to build a strategy that trades MES futures with an indicator. I have used an algorithm similar to this a few months ago and the logic worked but since then it seems like the API has changed and the way I was able to trade futures then no longer works. I really just cannot even get QC to place the order. All the documentation I can find seem to use outdated API and the responses Mia is giving me do the same. The latest error I am getting, using this code below basically made entirely by Mia, is:
"Runtime Error: 'MethodBinding' object is not iterable
at on_data
valid_mes = [c for c in mes_contracts if c.open_interest > 200]"
What can I do to fix this? Is there another standard way I can just place a futures order?
def on_data(self, slice: Slice) -> None:
if self.is_warming_up: return
#Track MES contract to trade
mes_chains = slice.future_chains.get(self.mes.symbol)
if mes_chains is not None:
# Filter out contracts with open interest <= 200
mes_contracts = mes_chains.contracts.values
valid_mes = [c for c in mes_contracts if c.open_interest > 200]
if valid_mes:
# Sort descending by open interest, pick top
sorted_mes = sorted(valid_es, key=lambda c: c.open_interest, reverse=True)
top_mes_contract = sorted_es[0]
top_mes_symbol = top_mes_contract.symbol
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!