增加交易策略、交易指标、量化库代码等文件夹
This commit is contained in:
70
5.课程代码/2.Option_spread_strategy/使用文档/8/8_demo.ipynb
Normal file
70
5.课程代码/2.Option_spread_strategy/使用文档/8/8_demo.ipynb
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from black_76 import *"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 数据截取自\n",
|
||||
"f = 3559.2 # IF2311价格\n",
|
||||
"k = 3600\n",
|
||||
"r = 0.02\n",
|
||||
"t = 15/365\n",
|
||||
"v = 0.148 # 隐含波动率14.8%\n",
|
||||
"cp = 1\n",
|
||||
"price = 25.4 # 期权价格"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 从波动率计算价格和希腊值\n",
|
||||
"calculate_greeks(f, k, r, t, v, cp)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# 从价格计算波动率\n",
|
||||
"calculate_impv(price, f, k, r, t, cp)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
Reference in New Issue
Block a user