mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.88k stars 856 forks source link

IBSimulatedExecutionHandler> #272

Closed leonlee723 closed 7 months ago

leonlee723 commented 5 years ago

Not Implemented Error: Could not find signature for parse: When I debug kalman-strategy, I encounter the error. Please help me,THX

https://www.quantstart.com/articles/kalman-filter-based-pairs-trading-strategy-in-qstrader I follow above url

MohammadMoradi commented 5 years ago

I have the same issue. It seems the example is out of date and not compatible with qstrader. Did you find any solution?

adam-hanna commented 5 years ago

Same issue with hidden markov models: https://www.quantstart.com/articles/market-regime-detection-using-hidden-markov-models-in-qstrader

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/.pyenv/learn-r/lib/python3.5/site-packages/multipledispatch/dispatcher.py in __call__(self, *args, **kwargs)
    268         try:
--> 269             func = self._cache[types]
    270         except KeyError:

KeyError: (<class 'qstrader.execution_handler.ib_simulated.IBSimulatedExecutionHandler'>,)

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-21-a10db4707b57> in <module>
      4 tickers = ['BTC']
      5 
----> 6 run(config, testing, tickers, filename)

<ipython-input-16-fe8653186cbc> in run(config, testing, tickers, filename)
     60         portfolio_handler, execution_handler,
     61         position_sizer, risk_manager,
---> 62         statistics, initial_equity
     63     )
     64     results = backtest.simulate_trading(testing=testing)

~/.pyenv/learn-r/lib/python3.5/site-packages/qstrader/trading_session.py in __init__(self, config, strategy, tickers, equity, start_date, end_date, events_queue, session_type, end_session_time, price_handler, portfolio_handler, compliance, position_sizer, execution_handler, risk_manager, statistics, sentiment_handler, title, benchmark)
     35         self.strategy = strategy
     36         self.tickers = tickers
---> 37         self.equity = PriceParser.parse(equity)
     38         self.start_date = start_date
     39         self.end_date = end_date

~/.pyenv/learn-r/lib/python3.5/site-packages/multipledispatch/dispatcher.py in __call__(self, *args, **kwargs)
    273                 raise NotImplementedError(
    274                     'Could not find signature for %s: <%s>' %
--> 275                     (self.name, str_signature(types)))
    276             self._cache[types] = func
    277         try:

NotImplementedError: Could not find signature for parse: <IBSimulatedExecutionHandler>
adam-hanna commented 5 years ago

I was able to fix the above error by using named arguments, e.g.:

backtest = TradingSession(
    config, strategy, tickers,
    initial_equity, start_date, end_date,
    events_queue, title=title, risk_manager=risk_manager,
    execution_handler=execution_handler, position_sizer=position_sizer
)