True quantification - the nth level of open interest, the main force of the seller to follow the strategy

#!/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 = 0
    g.costc = 0
    #价格
    g.c1 = 0
    g.c2 = 0
    #是否开仓
    g.gc=0
    g.gp=0
    #登录交易账号,需在主页用户管理中设置账号,并把回测期权替换成您的账户名称
    context.myacc = None
    if "回测期权" in context.accounts :
        print("登录交易账号[回测期权]")
        if context.accounts["回测期权"].Login() :
            context.myacc = context.accounts["回测期权"]
    fee = PBObj();
    fee.OpenUnit = 1
    fee.CloseRate = 0.000023
    fee.CloseTodayRate = 0.000345
    fee.MiniFee = 0
def OnMarketQuotationInitialEx(context,exchange,daynight):
    if exchange!='SHSE':
        return 
#     #订阅实时数据,用于驱动OnQ

Guess you like

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