FX31337 / FX-BT-Scripts

:page_facing_up: Useful scripts for backtesting.
MIT License
34 stars 39 forks source link

Support for all non-standard timeframes #90

Closed kenorb closed 7 years ago

kenorb commented 7 years ago

Currently the conversion script is supporting only limited number of timeframes:

timeframe_conv = {
        'm1': 1, 'm5':  5, 'm15': 15, 'm30':  30,
        'h1':60, 'h4':240, 'd1':1440, 'w1':10080, 'mn':43200
}

Convert the logic, so number of minutes are automatically calculated based on the given timeframe (-t), e.g.

See Timeframes page for more details.

Filename

The generated FXT filename must have type name SSSSSSPP_M.fxt where:

Currently it's generated correctly for Every tick model (with 0), we need to add support for 1 and 2. If model is not specified, by default generate the Every tick model (0).

Steps

Steps

  1. In some folder, clone repo with CSV files:

    git clone --branch EURUSD-2014 --single-branch https://github.com/FX31337/FX-BT-Data-EURUSD-DS
  2. Combine CSV data from 2 days into single file:

    find FX*  \( -name "2014-02-02*" -o -name "2014-02-03*" \) -exec cat {} ';' | sort > ticks.csv

    or 4 days:

    find FX* \( -name "2014-02-02*" -o -name "2014-02-03*" -o -name "2014-02-04*" -o -name "2014-02-05*" \) -exec cat {} ';' | sort > ticks.csv
  3. Clone this repo:

    git clone https://github.com/FX31337/FX-BT-Scripts
  4. Convert CSV file into FXT (for M1, M5 and M30 timeframe):

    ./FX-BT-Scripts/convert_csv_to_mt.py -v -i ticks.csv -f fxt4 -t M1,M2,M12,H2,H6,H12,D1,D2,W1,MN1

    Similar to hst4 format and other if relevant.

  5. Read the generated files by:

    ./FX-BT-Scripts/convert_mt_to_csv.py -i EURUSD1_0.fxt -f fxt4 | less