Skip to main content

Automate and backtest on ohlcv data quickly

Project description

Fast Trade Python application

A library to do back-testing on currency data with generated strategies quickly and easily. The data comes from this project crypto-data.

Data

If you're looking for some data, here is roughly every minute of 2018 of every pair from binance. Here is the each file individually zipped and here is the entire directory zipped, with each file as a zip. If you have any questions, please email me at fast_trade (at) jedm.dev. I also have data every minute since December 2019 to now, shoot me an email if you'd like access.

Goals

  • run in less than 30s on average hardware
  • headless
  • extensible

Features

  • Extremely fast backtesting
  • ability to build complex strategies
  • ability to reproduce strategies since they are just a json file
  • can interface easily as an API, ex. put a web server in front and its an API

Install

pip install fast-trade

Or

python -m venv .fast_trade
source .fast_trade/bin/activate
pip install -r requirements.txt

Testing

python -m pytest

Available Indicators (graciously stolen from https://github.com/peerchemist/finta)

Output

The output its a dictionary. The summary is a summary all the inputs and of the performace of the model. It's all the information to run the simulation again. The df is a Pandas Dataframe, which contains all of the data used in the simulation.

Example output:

{
  "summary":
    {
      "return_perc": -6.478, # total return percentage
      "meadian_trade_len: ""
      "mean_trade_len": 147445.013888888, # mean trade length, in seconds
      "max_trade_held": 619920.0, # longest trade held length, in seconds
      "min_trade_len": 28799.0, # shortest trade held length, in seconds
      "best_trade_perc": 13.611,
      "min_trade_perc": -18.355,
      "mean": 0.083,
      "num_trades": 73,
      "win_perc": 58.904,
      "loss_perc": 39.726,
      "equity_peak": 1117.3126272,
      "equity_final": 935.2209955,
      "equity_peak_unit": 1117.3126272,
      "first_tic": "2018-01-01 01:48:01",
      "last_tic": "2018-05-03 22:43:02",
      "total_tics": 720,
      "test_duration": 0.420136
    },
    "df": DataFrame(...)
}

Strategy

The real goal of this project is to get to the point where these strategies can be generated and tested quickly and then be easily iterated on.

Below is an example of a very simple strategey. Basically, indicators are used to build a list of indicators to look at which must all be true to produce an enter or exit status for that tick.

{
   "name": "example",
   "chart_period": "4m",
   "start": "2018-05-01 00:00:00",
   "stop": "2018-05-04 00:00:00",
   "enter": [
     [
       "close",
       ">",
       "short"
     ],
     [
       "rsi",
       ">",
       30
     ]
   ],
   "exit": [
     [
       "close",
       "<",
       "long"
     ],
     [
       "rsi",
       "<",
       70
     ]
   ],
   "indicators": [
     {
       "name": "short",
       "func": "ta.zlema",
       "args": [
         7
       ],
       "df": "close"
     },
     {
       "name": "long",
       "func": "ta.zlema",
       "args": [
         150
       ],
       "df": "close"
     },
     {
       "name": "rsi",
       "func": "ta.rsi",
       "args": [
         14
       ],
       "df": "close"
     }
   ]
}

Indicators

      {
         "name": "short", # indicator name
         "func": "ta.zlema", # technical analysis function to be used
         "args": [12], # arguments to pass to the function
         "df": "close" # which column of the dataframe to look at
      }

Enter / Exit

   "enter": [ # all must be true to enter or exit
      [
         "close", # column of the dataframe to compare to
         ">", # logic to use to compare
         "short" # the name from the defined indicator
      ]
   ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast-trade-0.1.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

fast_trade-0.1.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file fast-trade-0.1.2.tar.gz.

File metadata

  • Download URL: fast-trade-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for fast-trade-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1ddf1f25843764d73e8916463754b993e6adc224eb3432daec5b6ee37ce7051e
MD5 975ad77143e5cc3690d6ddd03a5351aa
BLAKE2b-256 f7092261b690ddab6e13e1bfe3d6966bf4e23ea47a28d856af0e0efcd40528ca

See more details on using hashes here.

File details

Details for the file fast_trade-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fast_trade-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for fast_trade-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 284ebc4793631c631765be0389c5fba9f055f1bc007f78aca12c0d9a4a22d5c2
MD5 3f79417a23a40c5376084c915a3a679a
BLAKE2b-256 fc3d8de48063622653202ff1ed009632c36bd68e6839c5f78ed82d37662726b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page