# coding:utf-8
#!/usr/bin/env python
from PoboAPI import *
import datetime
import numpy as np
#50ETF 和 50ETF期权的对冲交易,当ETF隐含波动率较高时就买50ETF并做空50ETF看涨期权#开始时间,用于初始化一些参数
def OnStart(context) :print("system starting...")#设定一个全局变量品种g.code0 = "510050.SHSE" #证券品种为50ETF#登录交易账号,需在主页用户管理中设置账号,并把证券测试替换成您的账户名称context.myaccOPT = None #初始化期权账户if "回测期权" in context.accounts :print("登录交易账号[回测期权]")if context.accounts["回测期权"].Login() :context.myaccOPT = context.accounts["回测期权"]context.myaccSTC = None #初始化股票账户if "回测证券" in context.accounts :print("登录交易账号[回测证券]")if context.accounts["回测证券"].Login() :context.myaccSTC = context.accounts["回测证券"] def OnMarketQuotationInitialEx(context,exchange,daynight):if exchange!='SHSE':r