letianzj / quanttrader

Backtest and live trading in Python
Apache License 2.0
468 stars 104 forks source link

"No security definition has been found for the request" - onTick never gets called #5

Closed meltingscales closed 2 years ago

meltingscales commented 2 years ago

I am following this tutorial:

https://www.youtube.com/watch?v=CrsrTxqiXNY

Using these samples:

https://github.com/letianzj/quanttrader/tree/master/examples

Here is my code:

https://github.com/HenryFBP/algorithmic-trading/tree/master/algotradingtest/algotradingtest/quanttradertest

And I cannot seem to get a strategy to run.

The quanttrader package downloads all my stocks and orders properly, but onTick never seems to get called when I click on Start_Strat button. Perhaps my config_live.yaml is incorrect? It was copied directly from the "examples" folder of this repo.

account: [redacted]
client_id: 0
host: 127.0.0.1
port: 7497
theme: dark
strategy:
  #---------- Strategy and params control -----------#
  # DoubleMovingAverageCrossStrategy:
  #   active: false
  #   capital: 10000
  #   params:
  #     n_fast_ma: 20
  #     n_slow_ma: 200
  #   symbols:
  #   - NGZ0 FUT NYMEX
  #---------- Strategy and params control -----------#
  DualTimeFrameStrategy:
    active: false
    capital: 10000
    params:
      start_time: '09:30:00'
      end_time: '16:14:58'
      bar_start_time: '09:00:00'
      bar_end_time: '16:15:00'
      lookback_5sec: 50
      lookback_15sec: 20
    symbols:
    - ESM1 FUT GLOBEX
  #---------- Strategy and params control -----------#
  # DualThrustStrategy:
  #   active: false
  #   capital: 10000
  #   params:
  #     G: 20
  #   symbols:
  #   - MESZ0 FUT GLOBEX
  #---------- Strategy and params control -----------#
  # MovingAverageCrossStrategy:
  #   active: false
  #   capital: 10000
  #   params:
  #     G: 20
  #   symbols:
  #   - CLZ0 FUT NYMEX
  #---------- Strategy and params control -----------#
  # ActiveBuySellStrengthStrategy:
  #   active: false
  #   capital: 10000
  #   params:
  #     strength_abs_threshold: 200
  #   symbols:
  #     - NQZ0 FUT GLOBEX
  #---------- Strategy, params control, and local risk control -----------#
  OrderPerIntervalStrategy:
    active: false
    capital: 50000
    order_start_time: '10:00:00'
    order_end_time: '16:15:00'
    params:
      tick_trigger_threshold: 6000
    single_trade_limit: 3
    symbols:
    - ESM1 FUT GLOBEX
    total_active_limit: 2
    total_cancel_limit: 5
    total_loss_limit: 5000
    total_trade_limit: 15
#---------- global risk control -----------#
total_active_limit: 3
total_cancel_limit: 10
total_loss_limit: 10000
total_trade_limit: 20
letianzj commented 2 years ago

Yes, the contract expired. If you have subscribed to futures data, can you try ESM2? Otherwise, you may change ESM1 FUT GLOBEX to SPY STK SMART.

meltingscales commented 2 years ago

Yes, the contract expired. If you have subscribed to futures data, can you try ESM2? Otherwise, you may change ESM1 FUT GLOBEX to SPY STK SMART.

Thanks @letianzj . I will try this and update you on if it works.

meltingscales commented 2 years ago

@letianzj It works! thank you so much. Working code is at https://github.com/HenryFBP/algorithmic-trading/tree/master/src/algotradingtest/quanttradertest

Feel free to close this issue. I will do the same edit when those ESM1 FUT GLOBEX-like identifiers don't work. (Are they called "data subscriptions"?)

letianzj commented 2 years ago

@HenryFBP Yes it is about IB data subscription; and futures roll, from expiring to the next contract.