通联情绪指标策略

来源:https://uqer.io/community/share/548111daf9f06c8e7733670a

  1. start = pd.datetime(2013, 11, 1)
  2. end = pd.datetime(2014, 11, 1)
  3. benchmark = 'HS300'
  4. universe = read('3b_ticker.txt').split(',')
  5. capital_base = 100000
  6. csvs = ['3b_news.csv']
  7. def initialize(account):
  8. add_history('hist1', 1)
  9. def handle_data(account, data):
  10. for stock in universe:
  11. if (stock not in account.hist1) or ('emotion' not in account.hist1[stock].columns):
  12. continue
  13. sig = account.hist1[stock].iloc[0,:]['emotion']
  14. if sig > 0.2 and account.position.stkpos.get(stock, 0)==0:
  15. order(stock, 100)
  16. elif sig < 0 and account.position.stkpos.get(stock, 0)>0:
  17. order_to(stock, 0)

通联情绪指标策略 - 图1