In [ ]:
Copied!
from pathlib import Path
import sys
docs_root = next(parent for parent in [Path.cwd(), *Path.cwd().parents]
if (parent / 'utils' / 'data_loader.py').exists())
sys.path.insert(0, str(docs_root))
from utils.data_loader import load_sample_prices
prices = load_sample_prices()
returns = prices.pct_change().dropna()
assert prices.index.is_monotonic_increasing
assert returns.notna().all().all()
print(f'价格形状: {prices.shape}; 收益率形状: {returns.shape}')
print('检查通过:再回到课程正文,用本节方法替换这里的最小示例。')
from pathlib import Path
import sys
docs_root = next(parent for parent in [Path.cwd(), *Path.cwd().parents]
if (parent / 'utils' / 'data_loader.py').exists())
sys.path.insert(0, str(docs_root))
from utils.data_loader import load_sample_prices
prices = load_sample_prices()
returns = prices.pct_change().dropna()
assert prices.index.is_monotonic_increasing
assert returns.notna().all().all()
print(f'价格形状: {prices.shape}; 收益率形状: {returns.shape}')
print('检查通过:再回到课程正文,用本节方法替换这里的最小示例。')