anfederico / clairvoyant

Software designed to identify and monitor social/historical cues for short term stock movement
MIT License
2.4k stars 770 forks source link

#HELP# Some errors appeared unusually #36

Closed Charmve closed 5 months ago

Charmve commented 3 years ago

Hi, Some errors appeared unusually.

I used the example code to test environment. But, when I use the library, SyntaxError: invalid syntax note appeared.

charmve@charmve-virtual-machine:~/Clairvoyant$ python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from clairvoyant.engine import Backtest
  File "/home/charmve/.local/lib/python2.7/site-packages/clairvoyant/engine.py", line 16
    self.svc = SVC(**kwargs, probability=True)
                           ^
SyntaxError: invalid syntax

test.py

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')
kiran-taylor commented 3 years ago

I think in clairvoyant/clairvoyant/engine.py in line 16

 def __init__(self, **kwargs):
        self.kwargs = kwargs
        self.svc = SVC(probability=True, **kwargs)

position of **kwargs should be first and then probability=True like this

 def __init__(self, **kwargs):
        self.kwargs = kwargs
        self.svc = SVC(**kwargs, probability=True)