def runOther(funds,symbols):
	tsstart =dt.datetime(funds.index[0].year,funds.index[0].month,funds.index[0].day)
	tsend =dt.datetime(funds.index[-1].year,funds.index[-1].month,funds.index[-1].day)
	timeofday=dt.timedelta(hours=16)
	timestamps=du.getNYSEdays(tsstart,tsend,timeofday)
	dataobj=da.DataAccess('Norgate')
	historic=dataobj.get_data(timestamps,symbols,"close")
	alloc_val=float(0.1/(float(len(symbols))+1))
	alloc_vals=alloc_val*ones(len(symbols))
	alloc=DataMatrix(index=[historic.index[0]],data=[alloc_vals], columns=symbols)
	alloc=alloc.append(DataMatrix(index=[historic.index[-1]], data=[alloc_vals], columns=symbols))
	alloc['_CASH']=alloc_val
	return qs.quickSim(alloc,historic,1000)
示例#2
0
def runOther(funds, symbols):
    tsstart = dt.datetime(funds.index[0].year, funds.index[0].month,
                          funds.index[0].day)
    tsend = dt.datetime(funds.index[-1].year, funds.index[-1].month,
                        funds.index[-1].day)
    timeofday = dt.timedelta(hours=16)
    timestamps = du.getNYSEdays(tsstart, tsend, timeofday)
    dataobj = da.DataAccess('Norgate')
    historic = dataobj.get_data(timestamps, symbols, "close")
    alloc_val = float(0.1 / (float(len(symbols)) + 1))
    alloc_vals = alloc_val * ones(len(symbols))
    alloc = DataMatrix(index=[historic.index[0]],
                       data=[alloc_vals],
                       columns=symbols)
    alloc = alloc.append(
        DataMatrix(index=[historic.index[-1]],
                   data=[alloc_vals],
                   columns=symbols))
    alloc['_CASH'] = alloc_val
    return qs.quickSim(alloc, historic, 1000)
示例#3
0
alloc = DataMatrix(index=[historic.index[0]], data=alloc_vals, columns=symbols)
for date in range(0, len(historic.index)):
    if (historic.index[date].day == 1):
        alloc = alloc.append(
            DataMatrix(index=[historic.index[date]],
                       data=alloc_vals,
                       columns=symbols))
alloc[symbols[0]] = .1
alloc['_CASH'] = .1

#output to pickle file
output = open("allocations.pkl", "wb")
cPickle.dump(alloc, output)

#test allocation with quicksim
print alloc
print historic
funds = qs.quickSim(alloc, historic, 1000)

#output to pickle file
output2 = open("funds2.pkl", "wb")
cPickle.dump(funds, output2)

#plot funds
plt.clf()
plt.plot(funds.index, funds.values)
plt.ylabel('Fund Value')
plt.xlabel('Date')
plt.draw()
savefig("funds.pdf", format='pdf')
示例#4
0
# create alloc
alloc_vals=.8/(len(historic.values[0,:])-1)*ones((1,len(historic.values[0,:])))
alloc=DataMatrix(index=[historic.index[0]], data=alloc_vals, columns=symbols)
for date in range(0, len(historic.index)):
	if(historic.index[date].day==1):
		alloc=alloc.append(DataMatrix(index=[historic.index[date]], data=alloc_vals, columns=symbols))
alloc[symbols[0]] = .1
alloc['_CASH'] = .1

#output to pickle file
output=open("allocations.pkl","wb")
cPickle.dump(alloc, output)

#test allocation with quicksim
print alloc
print historic
funds=qs.quickSim(alloc,historic,1000)

#output to pickle file
output2=open("funds2.pkl","wb")
cPickle.dump(funds, output2)

#plot funds
plt.clf()
plt.plot(funds.index,funds.values)
plt.ylabel('Fund Value')
plt.xlabel('Date')
plt.draw()
savefig("funds.pdf", format='pdf')