def compute_portvals(orders_file = "./orders/orders2.csv", \
start_val = 1000000, leverLimit = True):
# this is the function the autograder will call to test your code
order = pd.read_csv(orders_file, index_col = 'Date', parse_dates = True,
na_values=['nan'])
"""Create dataframe prices with symbol/dates/prices relevant to the order"""
start_date = order.index[0]
end_date = order.index[-1]
dates = pd.date_range(start_date, end_date)
symbols = list( order.ix[:,0].unique() ) #ndarray to list of symbols in order
prices = get_data(symbols, dates)
"""Create dataframe of cash and deposits in stocks, indexed by date"""
cashStocks = get_cash_stocks(order, prices, symbols, start_val, leverLimit)
posVals = get_position_values(cashStocks, prices, symbols)
portVals = posVals.sum(axis = 1)
return portVals
marketsim.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录