-
Notifications
You must be signed in to change notification settings - Fork 0
/
backtest.py
36 lines (31 loc) · 1.26 KB
/
backtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from preprocessing.data_ingest import data_in_csv
from preprocessing.timeframe import convert_timeframe
from Charts.candle_chart import interactive_candle_chart
from preprocessing.cleaning import data_cleaning
from preprocessing.indicator import sma, ema, rsi, macd, bollinger_bands, atr, garman_klass
from Evaluation.strategy_performance import strategy_performance
import pandas as pd
import numpy as np
#from Practice.random import randomdate_data
#from Practice.plotter import plotter
#from Practice.performance import performance
data = data_in_csv('data/NIFTY50-Minute_data.csv')
data = data_cleaning(data)
data = convert_timeframe(data, '5min')
#indicators
data = sma(data)
#data = ema(data)
#data = rsi(data)
#data = macd(data)
#data = bollinger_bands(data)
#data = atr(data)
#data = garman_klass(data
print(data.head(5))
print(data.tail(5))
print("Available strategies-'sma', 'bb', 'rsi', 'macd', 'idg', 'tfb', 'mr'")
strategy = input("Enter the strategy you want to implement: ")
close_capital ,pnl, points = strategy_performance(data, strategy , start_date="2020-12-01", end_date="2020-12-10", initial_capital=100000)
print(f"Close Capital: {close_capital}")
print(f"Points Captured: {points}")
print(f"Profit/Loss: {pnl}")
#fig = interactive_candle_chart(data, show_fig=True)