Comments (5)
Hi,
I install all the required libraries for the execution of following code:
from clairvoyant.engine import Backtest
import pandas as pd
features = ["EMA", "SSO"] # Financial indicators of choice
trainStart = 0 # Start of training period
trainEnd = 700 # End of training period
testStart = 701 # Start of testing period
testEnd = 1000 # 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)
continuedTraining = False # Continue training during testing period? (default = false)
Initialize backtester
backtest = Backtest(features, trainStart, trainEnd, testStart, testEnd, buyThreshold, sellThreshold, continuedTraining)
A little bit of pre-processing
data = pd.read_csv("SBUX.csv", date_parser=['date'])
data = data.round(3)
Start backtesting and optionally modify SVC parameters
Available paramaters can be found at: http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
backtest.start(data, kernel='rbf', C=1, gamma=10)
backtest.conditions()
backtest.statistics()
backtest.visualize('SBUX')
I got an error at line "backtest.start(data, kernel='rbf', C=1.0, gamma=10)". It says that
TypeError: 'str' object cannot be interpreted as an integer, and KeyError: 'EMA'
I checked the clairvoyant.engine for the solution but I don't know why this happens.
from clairvoyant.
I didn't include the "SBUX.csv" data which is unfortunately causing a lot of confusion because I use it in the README. I will update this soon. For now, the example data is called "data.csv" and the features are called "X1" and X2". Please update those in your example and it should run.
from clairvoyant.
from clairvoyant.
Thanks for the responce. I did use data.csv and rename it to SBUX.csv but when I ran the code its giving an error of "IndexError: single positional indexer is out-of-bounds". I am geting this error at line" backtest.start(data, kernel='rbf', C=1, gamma=10)"
from clairvoyant.
The test data only has 322 data points, try:
trainStart = 0 # Start of training period
trainEnd = 200 # End of training period
testStart = 201 # Start of testing period
testEnd = 321 # End of testing period
from clairvoyant.
Related Issues (20)
- Bug in predict_proba? HOT 1
- Working example HOT 1
- ImportError: No module named 'backtester' HOT 7
- Dimensionality reduction with t-SNE
- Does trainStart and trainEnd not support date formats anymore? HOT 3
- IndexError: single positional indexer is out-of-bounds HOT 1
- IndexError: single positional indexer is out-of-bounds HOT 2
- SyntaxError: invalid syntax : "self.svc = SVC(**kwargs, probability=True)" HOT 4
- TypeError: a float is required: "self.svc.fit(self.scaler.transform(self.XX), self.yy)" HOT 5
- KeyError: 'EMA' HOT 1
- NameError: name 'backtester' is not defined HOT 7
- data named 'SBUX.csv' HOT 1
- Code seems incorrect HOT 1
- Could you supply the file("SBUX.csv")? HOT 2
- Cannot Run Code HOT 4
- Error when running example: ufunc 'isfinite' not supported for the input types
- #HELP# Some errors appeared unusually HOT 1
- Project dependencies have API risk issues HOT 1
- Stock prediction tool
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clairvoyant.