check_strategy - 检查策略内容

check_strategy 是 PTrade 中用于检查策略内容的接口。

原型

check_strategy(strategy_content=None, strategy_path=None)

释义

check_strategy 是 PTrade 中用于检查策略内容的接口。

研究:支持;回测:不支持;模拟:官方目录未明确;实盘:不支持。

参数

参数 是否必填 官方原始定义
strategy_content strategy_content=None
strategy_path strategy_path=None

返回值

策略内容涉及升级过程中变动的API和Python库信息(list)。

接收到的数据如下:

{

"api_change_list": [

"margincash_open",

"get_history",

"get_fundamentals",

"get_etf_info",

"get_individual_transaction",

"get_individual_transcation",

"check_limit",

"get_price",

"get_snapshot",

"on_trade_response",

"set_parameters",

示例

check_strategy(strategy_content="""

import arch

import cvxopt

import keras

import pulp

import pykalman

import tensorflow

import walrus

def initialize(context):

g.security = "600570.SS"

set_universe(g.security)

pos={}

pos["sid"] = "600570.SS"

pos["amount"] = "1000"

pos["enable_amount"] = "600"

pos["cost_basis"] = "55"

set_yesterday_position([pos])

run_interval(context, interval_handle, seconds=10)

def interval_handle(context):

pass

def before_trading_start(context, data):

get_history(100, frequency="1d", field=["close"], security_list=g.security)

get_fundamentals(g.security, "balance_statement", "total_assets")

get_etf_info("510020.SS")

get_individual_transaction()

get_individual_transcation()

check_limit(g.security)

get_price(g.security, start_date="20150101", end_date="20150131", frequency="1d")

get_snapshot(g.security)

set_parameters(holiday_not_do_before="1")

get_user_name(False)

get_instruments(g.security)

get_all_orders()

get_trades()

get_margin_assert()

get_enslo_security_info()

get_hks_unit_amount("02899.XHKG-SS", "1")

get_individual_entrust()

get_tick_direction([g.security])

get_margin_contractreal()

详细说明

check_strategy(strategy_content=None, strategy_path=None)

使用场景

该函数在研究模块可用

接口说明

该接口用于检查策略内容是否涉及升级过程中变动的API和Python库。

注意事项

每次版本升级后应当将使用的策略内容统一检查一遍。

strategy_content和strategy_path都传入时仅对strategy_content入参内容进行检查。

如果传入strategy_path,需要将对应策略文件上传至研究,且必须是utf-8编码的文本文件。

如果日志打印策略内容涉及升级过程变动,需根据告警信息参考API接口说明调整策略内容。

参数详细说明

strategy_content: 策略内容(str)。

strategy_path: 策略路径(str)。

返回值

策略内容涉及升级过程中变动的API和Python库信息(list)。

接收到的数据如下:

{

"api_change_list": [

"margincash_open",

"get_history",

"get_fundamentals",

"get_etf_info",

"get_individual_transaction",

"get_individual_transcation",

"check_limit",

"get_price",

"get_snapshot",

"on_trade_response",

"set_parameters",

"set_yesterday_position",

"marginsec_open",

"order_market",

"margin_trade",

"get_user_name",

"debt_to_stock_order",

"get_instruments",

"get_margincash_open_amount",

"get_all_orders",

"run_interval",

"get_trades",

"margincash_close",

"marginsec_close",

"get_margin_assert",

"ipo_stocks_order",

"get_enslo_security_info",

"get_hks_unit_amount",

"get_individual_entrust",

"get_tick_direction",

"get_margin_contractreal",

"get_gear_price",

"get_stock_status"],

"package_change_list": [

"walrus",

"keras",

"pykalman",

"arch",

"cvxopt",

"pulp"],

}