Skip to content

Instantly share code, notes, and snippets.

View raovinnakota's full-sized avatar

Rao Vinnakota raovinnakota

View GitHub Profile
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
from pymongo import MongoClient
import json
import sys
MONGO_HOST= 'mongodb://localhost/miscdb' # assuming you have mongoDB installed locally
@raovinnakota
raovinnakota / robo-advisor.py
Created June 25, 2018 20:04
Robo-advisor algorithm with multiple universes implemented through an INI file
from zipline.api import *
from configparser import ConfigParser
import datetime
import ast
def initialize(context):
print ("Starting the robo advisor")
core_series = symbols('VTI', 'VXUS', 'BND', 'BNDX')
crsp_series = symbols('VUG', 'VTV', 'VB', 'VEA', 'VWO', 'BSV', 'BIV', 'BLV', 'VMBS', 'BNDX')
[CORE_SERIES]
0 = (0,0,0.686,0.294)
1 = (0.059,0.039,0.617,0.265)
2 = (0.118,0.078,0.549,0.235)
3 = (0.176,0.118,0.480,0.206)
4 = (0.235,0.157,0.412,0.176)
5 = (0.294,0.196,0.343,0.147)
6 = (0.353,0.235,0.274,0.118)
7 = (0.412,0.274,0.206,0.088)
8 = (0.470,0.314,0.137,0.059)
@raovinnakota
raovinnakota / buy-and-hold.py
Created June 25, 2018 18:00
Weight-based allocation of stocks in Zipline
from zipline.api import *
import datetime
def initialize(context):
context.stocks = symbols('VTI', 'VXUS', 'BND', 'BNDX')
context.bought = False
risk_level = 5
risk_based_allocation = {0: (0,0,0.686,0.294),
1: (0.059,0.039,0.617,0.265),