# 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期貨合約代碼#訂閱實時數據,用于驅動OnQuote事件SubscribeQuote([g.code1,g.code0])#訂閱K線數據,用于驅動OnBar事件SubscribeBar(g.code1, BarType.Day)#登錄交易賬號,需在主頁用戶管理中設置賬號,并把證券測試替換成您的賬戶名稱context.myacc = Noneif context.accounts.has_key("回測期貨") :print "登錄交易賬號[回測期貨]"if context.accounts["回測期貨"].Login() :context.myacc = context.accounts["回測期貨"]#實時行情事件,當有新行情出現時調用該事件
def OnQuote(context, code) :dyndata1 = GetQuote(g.code1)dyndata0 = GetQuote(g.code0)tradingtime=GetQuote(g.code0).timeprint "tradingtime ",tradingtime