Hi everyone
Not sure what it is happening with the pandas dataframe multiplication. I have try 2 different ways and not working. I am trying to multiply the data frame where the returns data frame has the series multiply by the weights. Can you guys check what I am doing wrong?
import pandas as pd
import numpy as np
from pandas import DataFrame as df
def initialize(context):
# Place orders with the order(SID, amount) method.
context.secs = [sid(24),sid(8554),sid(46632)]
pass
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# Implement your algorithm logic here.
hist = history(80, '1d','price',ffill=True)
weights = [10,0,0]
pd_all= pd.Series(weights,index=context.secs)
#First Option not working multiplication for the returns
returns= pd.DataFrame()
for eq in context.secs:
quant= (float(pd_all[eq])*float(.99))/ float(10)
returns[eq] = hist[eq] * quant
# Second option not doing multiplication
prices = np.log(history(50, '1d', 'price'))
assets = prices[context.secs]
returns = assets * pd_all
print assets
```e