#!/usr/bin/env python
# coding:utf-8
from PoboAPI import *
import datetime
import time
import numpy as np
from copy import *
#开始时间,用于初始化一些参数
def OnStart(context) :
context.myacc = None
#登录交易账号
if context.accounts["回测期权"].Login() :
context.myacc = context.accounts["回测期权"]
#每天行情初始化的,获取当前的50etf对应的平值期权
def OnMarketQuotationInitialEx(context, exchange,daynight):
#过滤掉非上交所的信号
if exchange != 'SHSE':
return
#获取期权标的
g.code = '510050.SHSE'
klinedata = GetHisData2(g.code,BarType.Day)
lastclose = klinedata[-1].close
#获取当月平价认购期权
g.atmopc = GetAtmOptionContract(g.code,0,lastclose,0)
#订阅日K线用来驱动onbar事件
SubscribeBar(g.atmopc,BarType.Day)
#获取期权合约,包括call和put合约
def Getop(code):
dyndata = GetQuote(code)
#获取标的价格并计算实值期权价格
now1 = dyndata.now
now50 = round(now1,1) + 0.05
#计算期权合约的到期年月
cutime = GetCurr
True Quantification - Implied Volatility Calculation
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324323843&siteId=291194637
Ranking