Code Monkey home page Code Monkey logo

backtesting's Introduction

Introduction

This code downloads historical data (1 minute candles) and backtest an easy strategy based on two ewma crossing.

Getting Started

  1. Installation process: Use virtual environment with python 3.8+. If you need help with virtual env here is a great explenation https://realpython.com/python-virtual-environments-a-primer/.
  2. Software dependencies: Install dependencies by running pip install -r requirements.txt
  3. Running backtesting:
if __name__ == "__main__":
    # Choose your market (works best with perpetual futures - ending "-PERP")
    market = 'BTC-PERP'
    # Data will be downloaded from 2019-08-01 00:00:00+00:00 by default
    download_data.main(market=market)
    '''
    You can set the following parameters when creating a Simulation instance
    
    market (str): the selected market (e.g., 'ETH-PERP')
    print_from (str): you can choose a date from '2019-08-01 00:00:00+00:00'
    print_to (str): you can limit the end of the range (same date format as print_from)
    fee (float): set in decimal number (e.g., 0.07% = 0.0007)
    interval_s (int): slow ewma in minutes (e.g., 120 = 2 hours)
    interval_f (int): fast ewma in minutes (e.g., 120 = 2 hours)
    leverage (int): if leverage <= 1 there is no leverage
    '''
    sim = Simulation(market=market, print_from='2019-08-01 00:00:00+01:00', fee=0.0006, interval_s=4320, interval_f=240, leverage=1)
    # Prepare data
    sim.data()
    # Run simul. iteration
    sim.simulate()
    # Plot the results
    sim.plot_strategy()

backtesting's People

Contributors

filipcz627 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.