Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: '_Broker' object is not callable #1103

Open
sandeepbhutani304 opened this issue Jan 7, 2024 · 0 comments
Open

TypeError: '_Broker' object is not callable #1103

sandeepbhutani304 opened this issue Jan 7, 2024 · 0 comments

Comments

@sandeepbhutani304
Copy link

Expected Behavior

On optimize it should run smoothly as per documentation

Actual Behavior

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\sandeep\anaconda3\lib\threading.py", line 973, in _bootstrap_inner
    self.run()
  File "C:\Users\sandeep\anaconda3\lib\threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "C:\sandcodes\backtest_realtime_f.py", line 2135, in bt_thread
    stats, heatmap = bt.optimize(
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1745, in optimize
    output = _optimize_grid()
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1635, in _optimize_grid
    _, values = Backtest._mp_task(backtest_uuid, batch_index)
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1755, in _mp_task
    return batch_index, [maximize_func(stats) if stats['# Trades'] else np.nan
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1755, in <listcomp>
    return batch_index, [maximize_func(stats) if stats['# Trades'] else np.nan
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1756, in <genexpr>
    for stats in (bt.run(**params)
  File "C:\sandcodes\backtesting_sand_f\backtesting.py", line 1245, in run
    broker: _Broker = self._broker(data=data)
TypeError: '_Broker' object is not callable
[]

Steps to Reproduce

        bt = None
        bt = Backtest(ticker, strat, #OpenLowIntraday, # OpenLow_SMA_Intraday,
                    cash=10000, commission=0.0003,
                    margin=1, #0.1, #best value as of now.. due to this trade count is changing
                    exclusive_orders=True, exclusive_orders_nocancel=True) # True)

        if OPTIMIZE_MODE == True:
            import numpy as np
            print("ENTERING OPTIMIZE MODE TO SEARCH BEST HYPER PARAMETERS::: ")
            stats, heatmap = bt.optimize(
                _pat_mul=range(1, 10),
                _macross_slope10threshold=list(np.arange(0.001, 1., 0.01)),
                _entry_price_factor=list(np.arange(1.0015, 1.01, 0.0001)),
                maximize='Equity Final [₹]',
                max_tries=200,
                random_state=0,
                return_heatmap=True,
                )

Additional info

  • Backtesting version: 0.3.3
  • bokeh.__version__:
  • OS: Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant