#!/usr/bin/env python
# coding:utf-8
from PoboAPI import *
import datetime
import time
import numpy as np
import pandas as pd
#日线级别
#开始时间,用于初始化一些参数
def OnStart(context):print("I\'m starting...")#设定一个全局变量品种,本策略交易50ETF期权g.code = "510050.SHSE"#持仓成本价g.costp = 0g.costc = 0#价格g.c1 = 0g.c2 = 0#是否开仓g.gc=0g.gp=0#登录交易账号,需在主页用户管理中设置账号,并把回测期权替换成您的账户名称context.myacc = Noneif "回测期权" in context.accounts :print("登录交易账号[回测期权]")if context.accounts["回测期权"].Login() :context.myacc = context.accounts["回测期权"]fee = PBObj();fee.OpenUnit = 1fee.CloseRate = 0.000023fee.CloseTodayRate = 0.000345fee.MiniFee = 0
def OnMarketQuotationInitialEx(context,exchange,daynight):if exchange!='SHSE':return
# #订阅实时数据,用于驱动OnQ