API:https://www.joinquant.com/help/api/help#name:api
数据说明:https://www.joinquant.com/help/api/help#name:aboutData
策略程序框架
- initialize(context):整个回测、模型实盘中最开始执行一次
- process_initialize(context):每次模拟盘、回测程序启动时执行一次
- run_daily/run_weekly/run_monthly:
- before_trading_start(context):
- after_trading_end(context):
- on_strategy_end(context):
- after_code_changed(context):
- unschedule_all(context):
- on_event(context):
- handle_date(context)
对象
- g 全局变量
- context:信息总览,包含账户、时间等等
- Portfolio:总账户信息
- SubPortfolio:子账户信息
- Position:持仓信息
- Trade:交易记录
- Order:订单
- OrderStatus:
- OrderStyle:
- Event:
设置函数
- set_benchmark()
- set_order_cost:佣金/印花税
- set_slippage:设置滑点
- use_real_price:
- avoid_future_date:避免未来数据
- set_option('use_real_price',True)
交易函数
- order
- order_target
- order_value
- order_targe_value
- cancel_order
- get_open_orders
- get_orders
- get_trades:
- inout_cash:
获取数据函数
价格函数
get_price
get_bars
财务函数
get_fundamentals
get_fundamentals_continuously()
股东信息:
finance.run_query
宏观数据
macro.run_query
get_billboard_list():获取龙虎榜
get_locked_shares():限售、解禁数据
get_index_stocks:指数成分股
get_index_weights
get_industry_stocks
get_concept_stocks:
get_industries:获取行业列表
get_concepts:获取概念列表
get_industry:获取股票所处行业
其他函数
- record
- send_message:
- log
- write_file/read_file
- enable_profile