Giter Club home page Giter Club logo

signal_backtester's Introduction

Alt text GitHub top language GitHub repo size PyPI

Signal Backtester

a tiny backtester Based on Backtesting Lib .
easiest way to backtest your generated signal. just need a csv file contain candleStick informations. OHLCV + signal see Dataset Structure for more information

why ?

some time writing good backtest for a strategy is not too easy . and you may have some challenge with backtest libraries.

so i decided to make a seprate repo for backtesting in easiest way. what you need is a csv file contain signal column . for buy signal you should put 2, and for sell signal you put 1.

and good news is you did not need to write strategy for how trade we wrote it before you just choose yours and finish you did it :)) see Strategy guide.

Quick Start

installation

pip install signal-backtester

Usage

from signal_backtester import SignalBacktester

# address of your dataset file 
# columns should include "Open, High, Low, Close, Volume, signal"

backtest = SignalBacktester(
                dataset="/home/xibalbas/sample.csv",
                strategy='two_side_sl_tp_reversed',
                cash=1000,
                commission=0.0005,  # equal 0.05 %
                percent_of_portfolio=99,
                stop_loss=1,
                take_profit=10,
                trailing_stop=3,    # if you are using trailing stop
                time_frame='30m', 
                output_path='.'     # path of result files
            )
            
backtest.run()
  • also you can see this example for how generate signal . and how backtest generated signal

strategy

available strategy to use are :

  • two_side_sl_tp_reversed

this strategy open position in both side buy and sell. it close position with stoploss or take profit also if you have an open buy position and you give a sell signal we close your last position an open new one

  • two_side_sl_trailing_reversed

this strategy open position in both side buy and sell. it close position with stoploss. your stop loss is dynamic if price change your stop loss will change . also if you have an open buy position and you give a sell signal we close your last position an open new one

  • one_side_buy_sl_tp

this strategy open position just in one side buy. it close position with stoploss or take profit

  • one_side_sell_sl_tp

this strategy open position just in one side sell. it close position with stoploss or take profit

  • one_side_buy_sl_trailing

this strategy open position just in one side buy. it close position with stoploss. your stop loss is dynamic if price change your stop loss will change .

  • one_side_sell_sl_trailing

this strategy open position just in one side sell. it close position with stoploss. your stop loss is dynamic if price change your stop loss will change .

dataset structure

your data set structure should be like this table

your buy signals should generate as 2 and your sell signals should generate as 1

you must have this columns in your dataset

  • Date
  • Open
  • High
  • Low
  • Close
  • Volume
  • signal

Alt text

Contributing

see contributing guide here

License

signal_backtester is freely available under the MIT license.

signal_backtester's People

Contributors

alm0ra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.