🔴
入学要求
💯
能力测试
🛣️
课程安排
🕹️
研究资源

练习

Exercise 1: 期货合约与现货市场

问题背景

2016年某玉米种植者选择在现货市场出售产品,请通过以下数据分析该决策是否明智:

数据准备

import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt

# 基础参数设置
bushels = 15000
spot_symbol = 'CORN'  # ETF代码
futures_symbol = 'ZC=F'  # 芝加哥期货交易所玉米期货示例代码

# 获取现货价格数据(2016年数据可能受限,需确认数据可用性)
spot_data = yf.download(spot_symbol, start='2016-06-01', end='2016-09-15')
spot_prices = spot_data['Close']

# 获取期货价格数据(实际需验证合约代码)
futures_data = yf.download(futures_symbol, start='2016-06-01', end='2016-09-15')
futures_prices = futures_data['Close']

# 关键日期标记
sale_date = '2016-09-14'
entry_date = '2016-06-01'

# 可视化价格走势
plt.figure(figsize=(12,6))
spot_prices.plot(label='Spot Price')
futures_prices.plot(label='Futures Price')
plt.axvline(pd.to_datetime(sale_date), color='r', linestyle='--', label='Settlement Date')
plt.legend()
plt.show()

分析要求

  1. 计算现货市场销售收入(注意单位转换)
  1. 计算期货合约锁定收益(需验证合约乘数)
  1. 比较两种方式的收益差异
  1. 绘制现金流对比图(选做)

Exercise 2: 持有成本模型

理论价格模拟

a. 期货溢价情景

构建理论价格模型,参数设定:

代码框架

import numpy as np

N = 100
cost_of_carry = 0.01
np.random.seed(42)

# 初始化序列容器
spot_series = np.zeros(N)
futures_series = np.zeros(N)

# 初始值设置
spot_series[0] = 1000
futures_series[0] = spot_series[0] * np.exp(cost_of_carry * N)

# 动态模拟过程
for t in range(1, N):
    spot_series[t] = spot_series[t-1] * (1 + np.random.normal(0, 0.02))  # 2%日波动
    remaining_days =
    futures_series[t] =

# 可视化结果

b. 现货溢价情景

调整持有成本率为负值(-0.01/日),重构价格序列

分析要求

  1. 补全价格生成循环逻辑
  1. 比较不同成本率下期现收敛特征
  1. 解释两种市场结构的形成机制

(注:期货合约实际交易需考虑合约规格、展期规则等复杂因素,本练习为简化模型)