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

Fix ticker interval #169

Merged
merged 3 commits into from Dec 12, 2017
Merged

Fix ticker interval #169

merged 3 commits into from Dec 12, 2017

Conversation

jblestang
Copy link
Contributor

Using the ticker interval configured by the user and fixing the average time duration estimation in the backtest script

@glonlas
Copy link
Member

glonlas commented Dec 11, 2017

I applied it and it works perfectly, the code is straightforward. However, the unittest is missing.

@jblestang you can add this following unitest to test that backtesting is loading 1 min ticker instead of 5.

  1. in tests/testdata mock a 1 ticker interval file for the purpose of this PR. It simulates a 1min file that does not have a 5min version)
  2. in test/test_optimize_backtesting.py add the following tests.
  3. you can fix the typo on "result" line 15 and 16 (resutls to results)

Add a mock file

In test/testdataduplicate a 1min ticker file and rename it, BTC_UNITEST-1.json. DO NOT do the same with the 5 min ticker.

Import pytest

In test/test_optimize_backtesting.py add on Line 7

import pytest

Add the unitest

In test/test_optimize_backtesting.py add on Line 19

def test_1min_ticker_interval(default_conf, mocker):
    mocker.patch.dict('freqtrade.main._CONF', default_conf)
    exchange._API = Bittrex({'key': '', 'secret': ''})

    # Run a backtesting for an exiting 5min ticker_interval
    data = optimize.load_data(ticker_interval=1, pairs=['BTC_UNITEST'])
    results = backtest(default_conf, optimize.preprocess(data), 1, True)
    assert len(results) > 0

    # Run a backtesting for 5min ticker_interval
    with pytest.raises(FileNotFoundError):
        data = optimize.load_data(ticker_interval=5, pairs=['BTC_UNITEST'])
        results = backtest(default_conf, optimize.preprocess(data), 1, True)

Re run test

pytest freqtrade/tests/test_optimize_backtesting.py should pass

@vertti
Copy link
Member

vertti commented Dec 11, 2017

@jblestang thanks for the fix!
@glonlas holy shit you are on fire with your PR reviews, thanks for all the effort!

@jblestang
Copy link
Contributor Author

The requested unit test has been added. Thanks @glonlas for showing how to do it!

@vertti vertti merged commit 77023c0 into freqtrade:develop Dec 12, 2017
@jblestang jblestang deleted the fix_ticker_interval branch June 5, 2018 12:13
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

Successfully merging this pull request may close these issues.

None yet

3 participants