def load_data():
	symbols = ['XOM', 'AAPL', 'MSFT', 'JNJ', 'GE', 'GOOG', 'CVX', 'PG', 'WFC']
	cap = {'^GSPC':14.90e12, 'XOM':403.02e9, 'AAPL':392.90e9, 'MSFT':283.60e9, 'JNJ':243.17e9, 'GE':236.79e9, 'GOOG':292.72e9, 'CVX':231.03e9, 'PG':214.99e9, 'WFC':218.79e9}
	n = len(symbols)
	prices_out, caps_out = [], []	
	for s in symbols:
		print("Reading symbol %s" % s)
		q = QuoteSeries.loadfromfile(s, 'data/black_litterman/%s.csv' % s)
		prices = q.getprices()[-500:]		
		prices_out.append(prices)
		caps_out.append(cap[s])
	return symbols, prices_out, caps_out
Esempio n. 2
0
def load_data():
    symbols = ['XOM', 'AAPL', 'MSFT', 'JNJ', 'GE', 'GOOG', 'CVX', 'PG', 'WFC']
    cap = {
        '^GSPC': 14.90e12,
        'XOM': 403.02e9,
        'AAPL': 392.90e9,
        'MSFT': 283.60e9,
        'JNJ': 243.17e9,
        'GE': 236.79e9,
        'GOOG': 292.72e9,
        'CVX': 231.03e9,
        'PG': 214.99e9,
        'WFC': 218.79e9
    }
    n = len(symbols)
    prices_out, caps_out = [], []
    for s in symbols:
        print("Reading symbol %s" % s)
        q = QuoteSeries.loadfromfile(s, 'data/black_litterman/%s.csv' % s)
        prices = q.getprices()[-500:]
        prices_out.append(prices)
        caps_out.append(cap[s])
    return symbols, prices_out, caps_out
Esempio n. 3
0
# Copyright (c) 2012 Quantitative & Financial, All rights reserved
# www.quantandfinancial.com

import datasources.google as google
from structures.quote import QuoteSeries
import numpy
from math import log, exp
from datetime import datetime

# Definition of enumerators
call, put, european, american = 100, 101, 102, 103

#google.getquotesfromweb('IVV').savetofile('data/ivv.csv')

prices = QuoteSeries.loadfromfile('IVV', 'data/ivv_2012_11_05.csv').getprices()
prices = prices[-250:]	# We will use last 250 trading days

# Calculation of daily continuous (logaritmic) returns
returns = []
for i in range(0, len(prices)-1):
	r = log(prices[i] / prices[i-1])
	returns.append(r)

# Calculation of daily and annualized volatility from daily returns
volat_d = numpy.std(returns)	# Daily volatility
volat = volat_d * 250**.5		# Annualized volatility

# Calculation inputs
side = call				# Option side
style = american 		# Option style
price = prices[-1]		# Current instrument price (147.31, as of 2012/11/05)