0

我正在尝试分配一个从 X 开始并在 Y 结束的索引。

例如:

startday -01.01.2012,
endday - 31.02.2012. 

另一个 DataFrame 在该时间段内模拟了 14 个股票订单,其中包含以下列:
日期、股票代码、股票数量、价格(收盘价)、价值(orders_df.Amount * orders_df.Price)。

我正在计算投资组合的日终价值(现金 + 股票价值),起始现金等于 1,000,000。

我不确定如何为整个期间的 DataFrame(第一个 DataFrame)分配索引。到目前为止,我能够计算出 14 天股票订单的投资组合价值。

cash.append(1000000)
cash = pd.Series(index=timestamps)
day = startday
for i in orders_df.Date:
    if i == day:
        cash = cash + orders_df.Value
4

0 回答 0