Giter Site home page Giter Site logo

Comments (5)

BariyaZ avatar BariyaZ commented on June 14, 2024

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.

anfederico avatar anfederico commented on June 14, 2024

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.

Shine119 avatar Shine119 commented on June 14, 2024

from clairvoyant.

BariyaZ avatar BariyaZ commented on June 14, 2024

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.

anfederico avatar anfederico commented on June 14, 2024

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)

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.