# coding:utf-8
#!/usr/bin/env python
from PoboAPI import *
import datetime
import time
import numpy as np
#开始时间,用于初始化一些参数
def OnStart(context) :
print "I\'m starting..."
#登录交易账号,需在主页用户管理中设置账号,并把证券测试替换成您的账户名称
context.myacc = None
if context.accounts.has_key("回测期权") :
print "登录交易账号[回测期权]"
if context.accounts["回测期权"].Login() :
context.myacc = context.accounts["回测期权"]
def OnMarketQuotationInitialEx(context,exchange,daynight):
if exchange != 'SHSE':
return
#设定一个全局变量品种
g.code = "510050.SHSE"
#订阅实时数据,用于驱动OnQuote事件
SubscribeQuote(g.code)
#订阅K线数据,用于驱动OnBar事件
SubscribeBar(g.code, BarType.Day)
def Getop(code):#获取期权合约代码
dyndata = GetQuote(code)
now1 = dyndata.now
#获取行权价格
now50 = round(now1,1) + 0.05
#根据当前时间决定合约月份
cutime = GetCur
True Quantification - Relying on the Moving Average to Buy Option Strategy
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324322828&siteId=291194637
Ranking