{ "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
exchangegateway_namehistory_datamin_volumenamenet_positionoption_expiryoption_strikeoption_typeoption_underlyingpricetickproductsizestop_supportedsymbolvt_symbol
0Exchange.SSEOESFalse10021国债⑺TrueNone0None100Product.EQUITY10False010107010107.SSE
1Exchange.SSEOESFalse10003国债⑶TrueNone0None100Product.EQUITY10False010303010303.SSE
2Exchange.SSEOESFalse10005国债⑷TrueNone0None100Product.EQUITY10False010504010504.SSE
3Exchange.SSEOESFalse10005国债⑿TrueNone0None100Product.EQUITY10False010512010512.SSE
4Exchange.SSEOESFalse10006国债⑼TrueNone0None100Product.EQUITY10False010609010609.SSE
5Exchange.SSEOESFalse10006国债⒆TrueNone0None100Product.EQUITY10False010619010619.SSE
6Exchange.SSEOESFalse10007国债06TrueNone0None100Product.EQUITY10False010706010706.SSE
7Exchange.SSEOESFalse10007国债13TrueNone0None100Product.EQUITY10False010713010713.SSE
8Exchange.SSEOESFalse100国开1401TrueNone0None100Product.EQUITY10False018003018003.SSE
9Exchange.SSEOESFalse100国开1702TrueNone0None100Product.EQUITY10False018006018006.SSE
10Exchange.SSEOESFalse100国开1801TrueNone0None100Product.EQUITY10False018007018007.SSE
11Exchange.SSEOESFalse100国开1802TrueNone0None100Product.EQUITY10False018008018008.SSE
12Exchange.SSEOESFalse100国开1803TrueNone0None100Product.EQUITY10False018009018009.SSE
13Exchange.SSEOESFalse10010国债02TrueNone0None100Product.EQUITY10False019002019002.SSE
14Exchange.SSEOESFalse10010国债03TrueNone0None100Product.EQUITY10False019003019003.SSE
15Exchange.SSEOESFalse10010国债07TrueNone0None100Product.EQUITY10False019007019007.SSE
16Exchange.SSEOESFalse10010国债09TrueNone0None100Product.EQUITY10False019009019009.SSE
17Exchange.SSEOESFalse10010国债12TrueNone0None100Product.EQUITY10False019012019012.SSE
18Exchange.SSEOESFalse10010国债14TrueNone0None100Product.EQUITY10False019014019014.SSE
19Exchange.SSEOESFalse10010国债18TrueNone0None100Product.EQUITY10False019018019018.SSE
20Exchange.SSEOESFalse10010国债19TrueNone0None100Product.EQUITY10False019019019019.SSE
21Exchange.SSEOESFalse10010国债23TrueNone0None100Product.EQUITY10False019023019023.SSE
22Exchange.SSEOESFalse10010国债24TrueNone0None100Product.EQUITY10False019024019024.SSE
23Exchange.SSEOESFalse10010国债26TrueNone0None100Product.EQUITY10False019026019026.SSE
24Exchange.SSEOESFalse10010国债29TrueNone0None100Product.EQUITY10False019029019029.SSE
25Exchange.SSEOESFalse10010国债31TrueNone0None100Product.EQUITY10False019031019031.SSE
26Exchange.SSEOESFalse10010国债34TrueNone0None100Product.EQUITY10False019034019034.SSE
27Exchange.SSEOESFalse10010国债37TrueNone0None100Product.EQUITY10False019037019037.SSE
28Exchange.SSEOESFalse10010国债40TrueNone0None100Product.EQUITY10False019040019040.SSE
29Exchange.SSEOESFalse10010国债41TrueNone0None100Product.EQUITY10False019041019041.SSE
...................................................
16289Exchange.SZSEOESFalse100越博动力TrueNone0None100Product.EQUITY100False300742300742.SZSE
16290Exchange.SZSEOESFalse100天地数码TrueNone0None100Product.EQUITY100False300743300743.SZSE
16291Exchange.SZSEOESFalse100欣锐科技TrueNone0None100Product.EQUITY100False300745300745.SZSE
16292Exchange.SZSEOESFalse100汉嘉设计TrueNone0None100Product.EQUITY100False300746300746.SZSE
16293Exchange.SZSEOESFalse100锐科激光TrueNone0None100Product.EQUITY100False300747300747.SZSE
16294Exchange.SZSEOESFalse100金力永磁TrueNone0None100Product.EQUITY100False300748300748.SZSE
16295Exchange.SZSEOESFalse100顶固集创TrueNone0None100Product.EQUITY100False300749300749.SZSE
16296Exchange.SZSEOESFalse100宁德时代TrueNone0None100Product.EQUITY100False300750300750.SZSE
16297Exchange.SZSEOESFalse100迈为股份TrueNone0None100Product.EQUITY100False300751300751.SZSE
16298Exchange.SZSEOESFalse100隆利科技TrueNone0None100Product.EQUITY100False300752300752.SZSE
16299Exchange.SZSEOESFalse100爱朋医疗TrueNone0None100Product.EQUITY100False300753300753.SZSE
16300Exchange.SZSEOESFalse100华致酒行TrueNone0None100Product.EQUITY100False300755300755.SZSE
16301Exchange.SZSEOESFalse100中山金马TrueNone0None100Product.EQUITY100False300756300756.SZSE
16302Exchange.SZSEOESFalse100罗博特科TrueNone0None100Product.EQUITY100False300757300757.SZSE
16303Exchange.SZSEOESFalse100七彩化学TrueNone0None100Product.EQUITY100False300758300758.SZSE
16304Exchange.SZSEOESFalse100康龙化成TrueNone0None100Product.EQUITY100False300759300759.SZSE
16305Exchange.SZSEOESFalse100迈瑞医疗TrueNone0None100Product.EQUITY100False300760300760.SZSE
16306Exchange.SZSEOESFalse100立华股份TrueNone0None100Product.EQUITY100False300761300761.SZSE
16307Exchange.SZSEOESFalse100上海瀚讯TrueNone0None100Product.EQUITY100False300762300762.SZSE
16308Exchange.SZSEOESFalse100锦浪科技TrueNone0None100Product.EQUITY100False300763300763.SZSE
16309Exchange.SZSEOESFalse100新诺威TrueNone0None100Product.EQUITY100False300765300765.SZSE
16310Exchange.SZSEOESFalse100每日互动TrueNone0None100Product.EQUITY100False300766300766.SZSE
16311Exchange.SZSEOESFalse100震安科技TrueNone0None100Product.EQUITY100False300767300767.SZSE
16312Exchange.SZSEOESFalse100迪普科技TrueNone0None100Product.EQUITY100False300768300768.SZSE
16313Exchange.SZSEOESFalse100德方纳米TrueNone0None100Product.EQUITY100False300769300769.SZSE
16314Exchange.SZSEOESFalse100新媒股份TrueNone0None100Product.EQUITY100False300770300770.SZSE
16315Exchange.SZSEOESFalse100智莱科技TrueNone0None100Product.EQUITY100False300771300771.SZSE
16316Exchange.SZSEOESFalse100运达股份TrueNone0None100Product.EQUITY100False300772300772.SZSE
16317Exchange.SZSEOESFalse100拉卡拉TrueNone0None100Product.EQUITY100False300773300773.SZSE
16318Exchange.SZSEOESFalse100标准券TrueNone0None0Product.EQUITY0False131990131990.SZSE
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
accountidavailablebalancefrozengateway_namevt_accountid
0188800031510011029372761100110293727610OESOES.1888000315
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
directionexchangefrozengateway_namepnlpricesymbolvolumevt_positionidvt_symbolyd_volume
0Direction.NETExchange.SSE0OES04.1881600010296900600010.SSE.Direction.NET600010.SSE1000000
1Direction.NETExchange.SSE0OES032.00686000362300600036.SSE.Direction.NET600036.SSE0
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ask_price_1ask_price_2ask_price_3ask_price_4ask_price_5ask_volume_1ask_volume_2ask_volume_3ask_volume_4ask_volume_5...limit_downlimit_uplow_pricenameopen_interestopen_pricepre_closesymbolvolumevt_symbol
034.634.6234.6334.6434.6500000...0033.85034.570.06000361900600036.SSE
\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 }