{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"该Jupyter Notebook用于展示如何使用ScriptTraderApp模块,在CLI命令行下进行交易指令的调用"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from vnpy.app.script_trader import init_cli_trading\n",
"from vnpy.gateway.oes import OesGateway"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2019-07-02 17:30:22.289718\t成功连接到行情服务器\n",
"2019-07-02 17:30:22.427419\t成功连接到交易服务器\n",
"2019-07-02 17:30:26.294755\t合约信息查询成功\n",
"2019-07-02 17:30:26.327959\t撤单失败,订单号: 1000107。原因:无效的订单状态\n",
"2019-07-02 17:30:26.328936\t撤单失败,订单号: 1000115。原因:未找到委托信息\n",
"2019-07-02 17:30:26.328936\t撤单失败,订单号: 1000117。原因:无效的订单状态\n"
]
}
],
"source": [
"# 连接到服务器\n",
"setting = {\n",
" \"td_ord_server\": \"tcp://106.15.58.119:6101\",\n",
" \"td_rpt_server\": \"tcp://106.15.58.119:6301\",\n",
" \"td_qry_server\": \"tcp://106.15.58.119:6401\",\n",
" \"md_tcp_server\": \"tcp://139.196.228.232:5103\",\n",
" \"md_qry_server\": \"tcp://139.196.228.232:5203\",\n",
" \"username\": \"\",\n",
" \"password\": \"\",\n",
" \"hdd_serial\": \"\",\n",
" \"customize_ip\": \"\",\n",
" \"customize_mac\": \"\"\n",
"}\n",
"\n",
"engine = init_cli_trading([OesGateway])\n",
"engine.connect_gateway(setting, \"OES\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" exchange | \n",
" gateway_name | \n",
" history_data | \n",
" min_volume | \n",
" name | \n",
" net_position | \n",
" option_expiry | \n",
" option_strike | \n",
" option_type | \n",
" option_underlying | \n",
" pricetick | \n",
" product | \n",
" size | \n",
" stop_supported | \n",
" symbol | \n",
" vt_symbol | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 21国债⑺ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010107 | \n",
" 010107.SSE | \n",
"
\n",
" \n",
" 1 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 03国债⑶ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010303 | \n",
" 010303.SSE | \n",
"
\n",
" \n",
" 2 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 05国债⑷ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010504 | \n",
" 010504.SSE | \n",
"
\n",
" \n",
" 3 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 05国债⑿ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010512 | \n",
" 010512.SSE | \n",
"
\n",
" \n",
" 4 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 06国债⑼ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010609 | \n",
" 010609.SSE | \n",
"
\n",
" \n",
" 5 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 06国债⒆ | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010619 | \n",
" 010619.SSE | \n",
"
\n",
" \n",
" 6 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 07国债06 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010706 | \n",
" 010706.SSE | \n",
"
\n",
" \n",
" 7 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 07国债13 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 010713 | \n",
" 010713.SSE | \n",
"
\n",
" \n",
" 8 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 国开1401 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 018003 | \n",
" 018003.SSE | \n",
"
\n",
" \n",
" 9 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 国开1702 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 018006 | \n",
" 018006.SSE | \n",
"
\n",
" \n",
" 10 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 国开1801 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 018007 | \n",
" 018007.SSE | \n",
"
\n",
" \n",
" 11 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 国开1802 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 018008 | \n",
" 018008.SSE | \n",
"
\n",
" \n",
" 12 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 国开1803 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 018009 | \n",
" 018009.SSE | \n",
"
\n",
" \n",
" 13 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债02 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019002 | \n",
" 019002.SSE | \n",
"
\n",
" \n",
" 14 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债03 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019003 | \n",
" 019003.SSE | \n",
"
\n",
" \n",
" 15 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债07 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019007 | \n",
" 019007.SSE | \n",
"
\n",
" \n",
" 16 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债09 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019009 | \n",
" 019009.SSE | \n",
"
\n",
" \n",
" 17 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债12 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019012 | \n",
" 019012.SSE | \n",
"
\n",
" \n",
" 18 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债14 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019014 | \n",
" 019014.SSE | \n",
"
\n",
" \n",
" 19 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债18 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019018 | \n",
" 019018.SSE | \n",
"
\n",
" \n",
" 20 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债19 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019019 | \n",
" 019019.SSE | \n",
"
\n",
" \n",
" 21 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债23 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019023 | \n",
" 019023.SSE | \n",
"
\n",
" \n",
" 22 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债24 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019024 | \n",
" 019024.SSE | \n",
"
\n",
" \n",
" 23 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债26 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019026 | \n",
" 019026.SSE | \n",
"
\n",
" \n",
" 24 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债29 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019029 | \n",
" 019029.SSE | \n",
"
\n",
" \n",
" 25 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债31 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019031 | \n",
" 019031.SSE | \n",
"
\n",
" \n",
" 26 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债34 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019034 | \n",
" 019034.SSE | \n",
"
\n",
" \n",
" 27 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债37 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019037 | \n",
" 019037.SSE | \n",
"
\n",
" \n",
" 28 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债40 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019040 | \n",
" 019040.SSE | \n",
"
\n",
" \n",
" 29 | \n",
" Exchange.SSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 10国债41 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 10 | \n",
" False | \n",
" 019041 | \n",
" 019041.SSE | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 16289 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 越博动力 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300742 | \n",
" 300742.SZSE | \n",
"
\n",
" \n",
" 16290 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 天地数码 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300743 | \n",
" 300743.SZSE | \n",
"
\n",
" \n",
" 16291 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 欣锐科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300745 | \n",
" 300745.SZSE | \n",
"
\n",
" \n",
" 16292 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 汉嘉设计 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300746 | \n",
" 300746.SZSE | \n",
"
\n",
" \n",
" 16293 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 锐科激光 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300747 | \n",
" 300747.SZSE | \n",
"
\n",
" \n",
" 16294 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 金力永磁 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300748 | \n",
" 300748.SZSE | \n",
"
\n",
" \n",
" 16295 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 顶固集创 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300749 | \n",
" 300749.SZSE | \n",
"
\n",
" \n",
" 16296 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 宁德时代 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300750 | \n",
" 300750.SZSE | \n",
"
\n",
" \n",
" 16297 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 迈为股份 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300751 | \n",
" 300751.SZSE | \n",
"
\n",
" \n",
" 16298 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 隆利科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300752 | \n",
" 300752.SZSE | \n",
"
\n",
" \n",
" 16299 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 爱朋医疗 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300753 | \n",
" 300753.SZSE | \n",
"
\n",
" \n",
" 16300 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 华致酒行 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300755 | \n",
" 300755.SZSE | \n",
"
\n",
" \n",
" 16301 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 中山金马 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300756 | \n",
" 300756.SZSE | \n",
"
\n",
" \n",
" 16302 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 罗博特科 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300757 | \n",
" 300757.SZSE | \n",
"
\n",
" \n",
" 16303 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 七彩化学 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300758 | \n",
" 300758.SZSE | \n",
"
\n",
" \n",
" 16304 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 康龙化成 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300759 | \n",
" 300759.SZSE | \n",
"
\n",
" \n",
" 16305 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 迈瑞医疗 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300760 | \n",
" 300760.SZSE | \n",
"
\n",
" \n",
" 16306 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 立华股份 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300761 | \n",
" 300761.SZSE | \n",
"
\n",
" \n",
" 16307 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 上海瀚讯 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300762 | \n",
" 300762.SZSE | \n",
"
\n",
" \n",
" 16308 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 锦浪科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300763 | \n",
" 300763.SZSE | \n",
"
\n",
" \n",
" 16309 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 新诺威 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300765 | \n",
" 300765.SZSE | \n",
"
\n",
" \n",
" 16310 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 每日互动 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300766 | \n",
" 300766.SZSE | \n",
"
\n",
" \n",
" 16311 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 震安科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300767 | \n",
" 300767.SZSE | \n",
"
\n",
" \n",
" 16312 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 迪普科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300768 | \n",
" 300768.SZSE | \n",
"
\n",
" \n",
" 16313 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 德方纳米 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300769 | \n",
" 300769.SZSE | \n",
"
\n",
" \n",
" 16314 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 新媒股份 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300770 | \n",
" 300770.SZSE | \n",
"
\n",
" \n",
" 16315 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 智莱科技 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300771 | \n",
" 300771.SZSE | \n",
"
\n",
" \n",
" 16316 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 运达股份 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300772 | \n",
" 300772.SZSE | \n",
"
\n",
" \n",
" 16317 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 拉卡拉 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 100 | \n",
" Product.EQUITY | \n",
" 100 | \n",
" False | \n",
" 300773 | \n",
" 300773.SZSE | \n",
"
\n",
" \n",
" 16318 | \n",
" Exchange.SZSE | \n",
" OES | \n",
" False | \n",
" 100 | \n",
" 标准券 | \n",
" True | \n",
" None | \n",
" 0 | \n",
" None | \n",
" | \n",
" 0 | \n",
" Product.EQUITY | \n",
" 0 | \n",
" False | \n",
" 131990 | \n",
" 131990.SZSE | \n",
"
\n",
" \n",
"
\n",
"
16319 rows × 16 columns
\n",
"
"
],
"text/plain": [
" exchange gateway_name history_data min_volume name \\\n",
"0 Exchange.SSE OES False 100 21国债⑺ \n",
"1 Exchange.SSE OES False 100 03国债⑶ \n",
"2 Exchange.SSE OES False 100 05国债⑷ \n",
"3 Exchange.SSE OES False 100 05国债⑿ \n",
"4 Exchange.SSE OES False 100 06国债⑼ \n",
"5 Exchange.SSE OES False 100 06国债⒆ \n",
"6 Exchange.SSE OES False 100 07国债06 \n",
"7 Exchange.SSE OES False 100 07国债13 \n",
"8 Exchange.SSE OES False 100 国开1401 \n",
"9 Exchange.SSE OES False 100 国开1702 \n",
"10 Exchange.SSE OES False 100 国开1801 \n",
"11 Exchange.SSE OES False 100 国开1802 \n",
"12 Exchange.SSE OES False 100 国开1803 \n",
"13 Exchange.SSE OES False 100 10国债02 \n",
"14 Exchange.SSE OES False 100 10国债03 \n",
"15 Exchange.SSE OES False 100 10国债07 \n",
"16 Exchange.SSE OES False 100 10国债09 \n",
"17 Exchange.SSE OES False 100 10国债12 \n",
"18 Exchange.SSE OES False 100 10国债14 \n",
"19 Exchange.SSE OES False 100 10国债18 \n",
"20 Exchange.SSE OES False 100 10国债19 \n",
"21 Exchange.SSE OES False 100 10国债23 \n",
"22 Exchange.SSE OES False 100 10国债24 \n",
"23 Exchange.SSE OES False 100 10国债26 \n",
"24 Exchange.SSE OES False 100 10国债29 \n",
"25 Exchange.SSE OES False 100 10国债31 \n",
"26 Exchange.SSE OES False 100 10国债34 \n",
"27 Exchange.SSE OES False 100 10国债37 \n",
"28 Exchange.SSE OES False 100 10国债40 \n",
"29 Exchange.SSE OES False 100 10国债41 \n",
"... ... ... ... ... ... \n",
"16289 Exchange.SZSE OES False 100 越博动力 \n",
"16290 Exchange.SZSE OES False 100 天地数码 \n",
"16291 Exchange.SZSE OES False 100 欣锐科技 \n",
"16292 Exchange.SZSE OES False 100 汉嘉设计 \n",
"16293 Exchange.SZSE OES False 100 锐科激光 \n",
"16294 Exchange.SZSE OES False 100 金力永磁 \n",
"16295 Exchange.SZSE OES False 100 顶固集创 \n",
"16296 Exchange.SZSE OES False 100 宁德时代 \n",
"16297 Exchange.SZSE OES False 100 迈为股份 \n",
"16298 Exchange.SZSE OES False 100 隆利科技 \n",
"16299 Exchange.SZSE OES False 100 爱朋医疗 \n",
"16300 Exchange.SZSE OES False 100 华致酒行 \n",
"16301 Exchange.SZSE OES False 100 中山金马 \n",
"16302 Exchange.SZSE OES False 100 罗博特科 \n",
"16303 Exchange.SZSE OES False 100 七彩化学 \n",
"16304 Exchange.SZSE OES False 100 康龙化成 \n",
"16305 Exchange.SZSE OES False 100 迈瑞医疗 \n",
"16306 Exchange.SZSE OES False 100 立华股份 \n",
"16307 Exchange.SZSE OES False 100 上海瀚讯 \n",
"16308 Exchange.SZSE OES False 100 锦浪科技 \n",
"16309 Exchange.SZSE OES False 100 新诺威 \n",
"16310 Exchange.SZSE OES False 100 每日互动 \n",
"16311 Exchange.SZSE OES False 100 震安科技 \n",
"16312 Exchange.SZSE OES False 100 迪普科技 \n",
"16313 Exchange.SZSE OES False 100 德方纳米 \n",
"16314 Exchange.SZSE OES False 100 新媒股份 \n",
"16315 Exchange.SZSE OES False 100 智莱科技 \n",
"16316 Exchange.SZSE OES False 100 运达股份 \n",
"16317 Exchange.SZSE OES False 100 拉卡拉 \n",
"16318 Exchange.SZSE OES False 100 标准券 \n",
"\n",
" net_position option_expiry option_strike option_type \\\n",
"0 True None 0 None \n",
"1 True None 0 None \n",
"2 True None 0 None \n",
"3 True None 0 None \n",
"4 True None 0 None \n",
"5 True None 0 None \n",
"6 True None 0 None \n",
"7 True None 0 None \n",
"8 True None 0 None \n",
"9 True None 0 None \n",
"10 True None 0 None \n",
"11 True None 0 None \n",
"12 True None 0 None \n",
"13 True None 0 None \n",
"14 True None 0 None \n",
"15 True None 0 None \n",
"16 True None 0 None \n",
"17 True None 0 None \n",
"18 True None 0 None \n",
"19 True None 0 None \n",
"20 True None 0 None \n",
"21 True None 0 None \n",
"22 True None 0 None \n",
"23 True None 0 None \n",
"24 True None 0 None \n",
"25 True None 0 None \n",
"26 True None 0 None \n",
"27 True None 0 None \n",
"28 True None 0 None \n",
"29 True None 0 None \n",
"... ... ... ... ... \n",
"16289 True None 0 None \n",
"16290 True None 0 None \n",
"16291 True None 0 None \n",
"16292 True None 0 None \n",
"16293 True None 0 None \n",
"16294 True None 0 None \n",
"16295 True None 0 None \n",
"16296 True None 0 None \n",
"16297 True None 0 None \n",
"16298 True None 0 None \n",
"16299 True None 0 None \n",
"16300 True None 0 None \n",
"16301 True None 0 None \n",
"16302 True None 0 None \n",
"16303 True None 0 None \n",
"16304 True None 0 None \n",
"16305 True None 0 None \n",
"16306 True None 0 None \n",
"16307 True None 0 None \n",
"16308 True None 0 None \n",
"16309 True None 0 None \n",
"16310 True None 0 None \n",
"16311 True None 0 None \n",
"16312 True None 0 None \n",
"16313 True None 0 None \n",
"16314 True None 0 None \n",
"16315 True None 0 None \n",
"16316 True None 0 None \n",
"16317 True None 0 None \n",
"16318 True None 0 None \n",
"\n",
" option_underlying pricetick product size stop_supported \\\n",
"0 100 Product.EQUITY 10 False \n",
"1 100 Product.EQUITY 10 False \n",
"2 100 Product.EQUITY 10 False \n",
"3 100 Product.EQUITY 10 False \n",
"4 100 Product.EQUITY 10 False \n",
"5 100 Product.EQUITY 10 False \n",
"6 100 Product.EQUITY 10 False \n",
"7 100 Product.EQUITY 10 False \n",
"8 100 Product.EQUITY 10 False \n",
"9 100 Product.EQUITY 10 False \n",
"10 100 Product.EQUITY 10 False \n",
"11 100 Product.EQUITY 10 False \n",
"12 100 Product.EQUITY 10 False \n",
"13 100 Product.EQUITY 10 False \n",
"14 100 Product.EQUITY 10 False \n",
"15 100 Product.EQUITY 10 False \n",
"16 100 Product.EQUITY 10 False \n",
"17 100 Product.EQUITY 10 False \n",
"18 100 Product.EQUITY 10 False \n",
"19 100 Product.EQUITY 10 False \n",
"20 100 Product.EQUITY 10 False \n",
"21 100 Product.EQUITY 10 False \n",
"22 100 Product.EQUITY 10 False \n",
"23 100 Product.EQUITY 10 False \n",
"24 100 Product.EQUITY 10 False \n",
"25 100 Product.EQUITY 10 False \n",
"26 100 Product.EQUITY 10 False \n",
"27 100 Product.EQUITY 10 False \n",
"28 100 Product.EQUITY 10 False \n",
"29 100 Product.EQUITY 10 False \n",
"... ... ... ... ... ... \n",
"16289 100 Product.EQUITY 100 False \n",
"16290 100 Product.EQUITY 100 False \n",
"16291 100 Product.EQUITY 100 False \n",
"16292 100 Product.EQUITY 100 False \n",
"16293 100 Product.EQUITY 100 False \n",
"16294 100 Product.EQUITY 100 False \n",
"16295 100 Product.EQUITY 100 False \n",
"16296 100 Product.EQUITY 100 False \n",
"16297 100 Product.EQUITY 100 False \n",
"16298 100 Product.EQUITY 100 False \n",
"16299 100 Product.EQUITY 100 False \n",
"16300 100 Product.EQUITY 100 False \n",
"16301 100 Product.EQUITY 100 False \n",
"16302 100 Product.EQUITY 100 False \n",
"16303 100 Product.EQUITY 100 False \n",
"16304 100 Product.EQUITY 100 False \n",
"16305 100 Product.EQUITY 100 False \n",
"16306 100 Product.EQUITY 100 False \n",
"16307 100 Product.EQUITY 100 False \n",
"16308 100 Product.EQUITY 100 False \n",
"16309 100 Product.EQUITY 100 False \n",
"16310 100 Product.EQUITY 100 False \n",
"16311 100 Product.EQUITY 100 False \n",
"16312 100 Product.EQUITY 100 False \n",
"16313 100 Product.EQUITY 100 False \n",
"16314 100 Product.EQUITY 100 False \n",
"16315 100 Product.EQUITY 100 False \n",
"16316 100 Product.EQUITY 100 False \n",
"16317 100 Product.EQUITY 100 False \n",
"16318 0 Product.EQUITY 0 False \n",
"\n",
" symbol vt_symbol \n",
"0 010107 010107.SSE \n",
"1 010303 010303.SSE \n",
"2 010504 010504.SSE \n",
"3 010512 010512.SSE \n",
"4 010609 010609.SSE \n",
"5 010619 010619.SSE \n",
"6 010706 010706.SSE \n",
"7 010713 010713.SSE \n",
"8 018003 018003.SSE \n",
"9 018006 018006.SSE \n",
"10 018007 018007.SSE \n",
"11 018008 018008.SSE \n",
"12 018009 018009.SSE \n",
"13 019002 019002.SSE \n",
"14 019003 019003.SSE \n",
"15 019007 019007.SSE \n",
"16 019009 019009.SSE \n",
"17 019012 019012.SSE \n",
"18 019014 019014.SSE \n",
"19 019018 019018.SSE \n",
"20 019019 019019.SSE \n",
"21 019023 019023.SSE \n",
"22 019024 019024.SSE \n",
"23 019026 019026.SSE \n",
"24 019029 019029.SSE \n",
"25 019031 019031.SSE \n",
"26 019034 019034.SSE \n",
"27 019037 019037.SSE \n",
"28 019040 019040.SSE \n",
"29 019041 019041.SSE \n",
"... ... ... \n",
"16289 300742 300742.SZSE \n",
"16290 300743 300743.SZSE \n",
"16291 300745 300745.SZSE \n",
"16292 300746 300746.SZSE \n",
"16293 300747 300747.SZSE \n",
"16294 300748 300748.SZSE \n",
"16295 300749 300749.SZSE \n",
"16296 300750 300750.SZSE \n",
"16297 300751 300751.SZSE \n",
"16298 300752 300752.SZSE \n",
"16299 300753 300753.SZSE \n",
"16300 300755 300755.SZSE \n",
"16301 300756 300756.SZSE \n",
"16302 300757 300757.SZSE \n",
"16303 300758 300758.SZSE \n",
"16304 300759 300759.SZSE \n",
"16305 300760 300760.SZSE \n",
"16306 300761 300761.SZSE \n",
"16307 300762 300762.SZSE \n",
"16308 300763 300763.SZSE \n",
"16309 300765 300765.SZSE \n",
"16310 300766 300766.SZSE \n",
"16311 300767 300767.SZSE \n",
"16312 300768 300768.SZSE \n",
"16313 300769 300769.SZSE \n",
"16314 300770 300770.SZSE \n",
"16315 300771 300771.SZSE \n",
"16316 300772 300772.SZSE \n",
"16317 300773 300773.SZSE \n",
"16318 131990 131990.SZSE \n",
"\n",
"[16319 rows x 16 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 查询所有合约\n",
"engine.get_all_contracts(use_df=True)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" accountid | \n",
" available | \n",
" balance | \n",
" frozen | \n",
" gateway_name | \n",
" vt_accountid | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1888000315 | \n",
" 10011029372761 | \n",
" 10011029372761 | \n",
" 0 | \n",
" OES | \n",
" OES.1888000315 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" accountid available balance frozen gateway_name \\\n",
"0 1888000315 10011029372761 10011029372761 0 OES \n",
"\n",
" vt_accountid \n",
"0 OES.1888000315 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 查询资金\n",
"engine.get_all_accounts(use_df=True)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" direction | \n",
" exchange | \n",
" frozen | \n",
" gateway_name | \n",
" pnl | \n",
" price | \n",
" symbol | \n",
" volume | \n",
" vt_positionid | \n",
" vt_symbol | \n",
" yd_volume | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Direction.NET | \n",
" Exchange.SSE | \n",
" 0 | \n",
" OES | \n",
" 0 | \n",
" 4.1881 | \n",
" 600010 | \n",
" 296900 | \n",
" 600010.SSE.Direction.NET | \n",
" 600010.SSE | \n",
" 1000000 | \n",
"
\n",
" \n",
" 1 | \n",
" Direction.NET | \n",
" Exchange.SSE | \n",
" 0 | \n",
" OES | \n",
" 0 | \n",
" 32.0068 | \n",
" 600036 | \n",
" 2300 | \n",
" 600036.SSE.Direction.NET | \n",
" 600036.SSE | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" direction exchange frozen gateway_name pnl price symbol \\\n",
"0 Direction.NET Exchange.SSE 0 OES 0 4.1881 600010 \n",
"1 Direction.NET Exchange.SSE 0 OES 0 32.0068 600036 \n",
"\n",
" volume vt_positionid vt_symbol yd_volume \n",
"0 296900 600010.SSE.Direction.NET 600010.SSE 1000000 \n",
"1 2300 600036.SSE.Direction.NET 600036.SSE 0 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 查询持仓\n",
"engine.get_all_positions(use_df=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# 查询活动委托\n",
"engine.get_all_active_orders(use_df=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# 订阅行情\n",
"engine.subscribe([\"600036.SSE\"])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ask_price_1 | \n",
" ask_price_2 | \n",
" ask_price_3 | \n",
" ask_price_4 | \n",
" ask_price_5 | \n",
" ask_volume_1 | \n",
" ask_volume_2 | \n",
" ask_volume_3 | \n",
" ask_volume_4 | \n",
" ask_volume_5 | \n",
" ... | \n",
" limit_down | \n",
" limit_up | \n",
" low_price | \n",
" name | \n",
" open_interest | \n",
" open_price | \n",
" pre_close | \n",
" symbol | \n",
" volume | \n",
" vt_symbol | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 34.6 | \n",
" 34.62 | \n",
" 34.63 | \n",
" 34.64 | \n",
" 34.65 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" ... | \n",
" 0 | \n",
" 0 | \n",
" 33.85 | \n",
" | \n",
" 0 | \n",
" 34.57 | \n",
" 0.0 | \n",
" 600036 | \n",
" 1900 | \n",
" 600036.SSE | \n",
"
\n",
" \n",
"
\n",
"
1 rows × 36 columns
\n",
"
"
],
"text/plain": [
" ask_price_1 ask_price_2 ask_price_3 ask_price_4 ask_price_5 \\\n",
"0 34.6 34.62 34.63 34.64 34.65 \n",
"\n",
" ask_volume_1 ask_volume_2 ask_volume_3 ask_volume_4 ask_volume_5 ... \\\n",
"0 0 0 0 0 0 ... \n",
"\n",
" limit_down limit_up low_price name open_interest open_price \\\n",
"0 0 0 33.85 0 34.57 \n",
"\n",
" pre_close symbol volume vt_symbol \n",
"0 0.0 600036 1900 600036.SSE \n",
"\n",
"[1 rows x 36 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 查询行情\n",
"engine.get_tick(\"600036.SSE\", use_df=True)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OES.1000124\n"
]
}
],
"source": [
"# 委托下单\n",
"vt_orderid = engine.buy(\"600036.SSE\", 32, 1000)\n",
"print(vt_orderid)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"OrderData(gateway_name='OES', symbol='600036', exchange=, orderid='1000124', type=, direction=, offset=, price=32, volume=1000, traded=1000, status=, time=datetime.datetime(2019, 4, 30, 17, 31, 56, 965000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800))))"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 查询特定委托\n",
"engine.get_order(vt_orderid)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# 委托撤单\n",
"engine.cancel_order(vt_orderid)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}