Skip to content

backtest.optimize throws error #500

Closed
@Kayne88

Description

@Kayne88

Expected Behavior

backtest.optimize(fast_period=range(2,10,2),medium_period=range(6,20,2),slow_period=range(10,30,2))
is executing without error.

Actual Behavior

It returns this traceback:

Traceback (most recent call last):
File "c:/Users/User/Documents/Trading/Back testing/run_backtest.py", line 19, in
optimal_parameters = backtest.optimize(fast_period=range(2,10,2),medium_period=range(6,20,2),slow_period=range(10,30,2))
File "C:\Users\User\Anaconda3\lib\site-packages\backtesting\backtesting.py", line 1487, in optimize
output = _optimize_grid()
File "C:\Users\User\Anaconda3\lib\site-packages\backtesting\backtesting.py", line 1324, in _optimize_grid
rand = np.random.RandomState(random_state).random
AttributeError: 'mtrand.RandomState' object has no attribute 'random'

Analysis

If I look at numpy RandomState doc: https://numpy.org/doc/1.16/reference/generated/numpy.random.RandomState.html
There is indeed no method handle called random, only rand.

Additional info

bug backtesting

  • Backtesting version: 0.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Hacktoberfesthttps://hacktoberfest.digitalocean.combugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions