uclatommy / Clairvoyant

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

Can you provide acceptable data layout ? #11

Closed arambula1980 closed 7 years ago

arambula1980 commented 7 years ago

Great package !!! I am eager to test it. Can you provide sample data / csv file with the acceptable data layout ?

I am trying to test performance on a single stock. I have downloaded data from Google / Yahoo and populated the csv. The CSV contains the following fields Date, Open, High, Low, Close, Volume.

Per your documentation, I am running the following code :

`from clairvoyant import Backtest, History

variables = ["SSO", "SSC"] # Financial indicators of choice ( Are these Cusips or StockSymbols ? ) 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)

backtest = Backtest(variables, trainStart, trainEnd, testStart, testEnd)

cols = {'Date': 'date', 'Open': 'open', 'Close': 'close', 'SSO': 'sentiment', 'SSC': 'influence'} # Define a column map data = History("Stocks/SBUX.csv", col_map=cols) # Read in data This is my csv with all my data backtest.stocks.append("SBUX") # Inform the model which stock is being tested for i in range(0,10): # Run the model 10-15 times backtest.runModel(data) ` But I am getting the following error :

Traceback (most recent call last): File "C:/Program Files/Python35/Lib/site-packages/clairvoyant/data.py", line 1, in from clairvoyant import Backtest, History File "C:\Program Files\Python35\lib\site-packages\clairvoyant__init__.py", line 1, in from .history import History File "C:\Program Files\Python35\lib\site-packages\clairvoyant\history.py", line 121 raise KeyError(f'\'{v}\' is not a valid column.') ^ SyntaxError: invalid syntax

I have tried referencing History.py file but not sure what am I supposed to do here. Also, I have checked your Test Folder, for any clues or how exactly to run it, and I only have further questions. The csv file that you have there, this information where does it come from ? What are the pre-requisites before running the aforementioned code ?

Thanks,

Eric

uclatommy commented 7 years ago

Hi arambula1980,

Sorry I'm making too much money and don't have time to respond. Kidding.

An example of the data layout is provided by tesla-sentiment.csv.

If you do not define your own column map for your data, then you should follow this layout exactly. In the code example, these lines define the column map:

cols = {'Date': 'date', 'Open': 'open', 'Close': 'close',
        'SSO': 'sentiment', 'SSC': 'influence'}       # Define a column map
data = History("Stocks/SBUX.csv", col_map=cols)       # Read in data 

Notice the column map is being used by History to understand what columns are defined. Based on your error, I suspect that something is wrong with your column map or data. However, as I am currently traveling for an extended time, I do not have regular access to computer and internet so have limited ability to provide further assistance, I'm afraid.

To answer your question about SSO and SSC, these are social sentiment scores I mined and calculated using real-time tweets from twitter. You can provide any type of indicator you feel would provide Clair with viable data for learning. In machine learning, these are called features. For example, perhaps you want Clair to make decisions based on P/E ratio. You can provide that as a learning feature as long as you define it appropriately in the column map.

Hope that helps and good luck.

arambula1980 commented 7 years ago

Thanks Tommy, you have done plenty. Really appreciate the time looking into this, and thanks for pointing me to the right direction. Safe Travels !!!