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?

 

  1. def on_data(self, slice: Slice) -> None:
  2. if self.is_warming_up: return
  3. #Track MES contract to trade
  4. mes_chains = slice.future_chains.get(self.mes.symbol)
  5. if mes_chains is not None:
  6. # Filter out contracts with open interest <= 200
  7. mes_contracts = mes_chains.contracts.values
  8. valid_mes = [c for c in mes_contracts if c.open_interest > 200]
  9. if valid_mes:
  10. # Sort descending by open interest, pick top
  11. sorted_mes = sorted(valid_es, key=lambda c: c.open_interest, reverse=True)
  12. top_mes_contract = sorted_es[0]
  13. top_mes_symbol = top_mes_contract.symbol

Author

Ethan Wertlieb

23 days ago