金融数据分析与高级NumPy应用
1. 金融数据基础与分组分析
1.1 数据示例
首先给出一组月度数据示例,展示了2012年1月至7月的数据值:
2012-01 0.127111
2012-02 0.188311
2012-03 0.105284
2012-04 -0.025969
2012-05 -0.010702
2012-06 0.010853
2012-07 0.001986
Freq: M
如果有股息日期和百分比,将它们包含在每日总回报中,可以使用以下代码:
returns[dividend_dates] += dividend_pcts
1.2 分组变换与分析
考虑一组假设的股票投资组合,具体步骤如下:
1. 生成股票代码 :
import random; random.seed(0)
import string
import numpy as np
from pandas import DataFrame, Series
N = 1000
def rands(n):
choices = string.ascii_uppercase
return ''.join([random.choice(choices) for _ in rang
超级会员免费看
订阅专栏 解锁全文
977

被折叠的 条评论
为什么被折叠?



