PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/python/algo_local/read_sentiment.py

https://bitbucket.org/vroomzel/semester2
Python | 27 lines | 12 code | 7 blank | 8 comment | 0 complexity | 85ae5a519441470072481a9e2d177c04 MD5 | raw file
  1. import datetime as dt
  2. import pandas
  3. import numpy as np
  4. import os
  5. #set time zone, otherwise dates are screwed
  6. os.putenv("TZ","America/New_York")
  7. path="/backtest_data/sentiment_data/recorded_future/"
  8. rf=pandas.read_csv(path+'RF-R3000-HalfHour-History-Attention.csv', sep=',', index_col=[0,2], parse_dates=True)
  9. '''
  10. the data is MultyIndex pandas data frame. First index is ticker,
  11. second index is date
  12. '''
  13. #don't need RF_ID column
  14. rf.pop('RF_ID')
  15. #add weighted sentiment
  16. rf['w30']=(rf.Positive-rf.Negative)*rf['Attention.30min']
  17. rf['w24h']=(rf.Positive-rf.Negative)*rf['Attention.24hr']
  18. path="/backtest_data/1second/teams_data/team3/data/"
  19. rf.save(path+"recorded_future.bin")
  20. #sentiment.Count.ix['AAPL'].ix[dt.datetime(2011,1,2):dt.datetime(2011,1,3)].plot()