Created
February 3, 2017 04:46
-
-
Save antani/779d4dc8175efcfa427723f6524f0de8 to your computer and use it in GitHub Desktop.
Test with Clairvoyance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from clairvoyant import Backtest | |
from pandas import read_csv | |
from nsepy import get_history | |
from datetime import date | |
# Testing performance on a single stock | |
variables = [] # Financial indicators of choice # "SSO", "SSC" | |
trainStart = '2013-03-01' # Start of training period | |
trainEnd = '2015-07-15' # End of training period | |
testStart = '2015-07-16' # Start of testing period | |
testEnd = '2016-07-16' # End of testing period | |
buyThreshold = 0.65 # Confidence threshold for predicting buy (default = 0.65) | |
sellThreshold = 0.65 # Confidence threshold for predicting sell (default = 0.65) | |
C = 1 # Penalty parameter (default = 1) | |
gamma = 10 # Kernel coefficient (default = 10) | |
continuedTraining = False # Continue training during testing period? (default = false) | |
history = get_history(symbol="SBIN", | |
start=date(2013, 1, 1), | |
end=date(2017, 1, 1), | |
index=False) | |
history[['Open','High','Low','Close','Volume','Close']].to_csv("sbin.csv") | |
backtest = Backtest(variables, trainStart, trainEnd, testStart, testEnd) | |
data = read_csv("sbin.csv") # Read in data | |
data = data.round(3) # Round all values | |
backtest.stocks.append("sbin") # Inform the model which stock is being tested | |
for i in range(0,10): # Run the model 10-15 times | |
backtest.runModel(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment