True Quantification - Short Volatility Put Option Strategy

# coding:utf-8
#!/usr/bin/env python
# EmuCounter2
from PoboAPI import *
import datetime
import numpy as np

#开始时间,用于初始化一些参数
def OnStart(context) :
    print "system starting..."
    #设定全局变量品种
    g.code1 = "m1901-C-3300.DCE" #豆粕1901C3300期权合约代码
    g.code0 = "m1901.DCE"  #豆粕1901期货合约代码
    #登录交易账号,需在主页用户管理中设置账号,并把证券测试替换成您的账户名称
    context.myacc = None
    if context.accounts.has_key("回测期货") :
        print "登录交易账号[回测期货]"
        if context.accounts["回测期货"].Login() :
            context.myacc = context.accounts["回测期货"]
            
def OnMarketQuotationInitialEx(context,exchange,daynight):
    if exchange !='DCE' or daynight != 'night':
        return 
    #订阅实时数据,用于驱动OnQuote事件
    SubscribeQuote([g.code1,g.code0])
  
#实时行情事件,当有新行情出现时调用该事件
def OnQuote(context, code) :
    
    dyndata1 = GetQuote(g.code1)
    dyndata0 = GetQuote(g.code0)
  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324323151&siteId=291194637