From ede33a2506f7f75cea37ed070c39de4c8e7dc1c5 Mon Sep 17 00:00:00 2001 From: LimingFang Date: Fri, 9 Aug 2019 13:59:42 +0800 Subject: [PATCH] script md update 89 --- docs/script_trader.md | 12 ++++++------ vnpy/app/script_trader/engine.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/script_trader.md b/docs/script_trader.md index 889352c3..4c2e36ed 100644 --- a/docs/script_trader.md +++ b/docs/script_trader.md @@ -10,7 +10,7 @@ ScriptTrader模块提供了交互式的量化分析和程序化交易功能, ## Jupyter模式 ### 加载启动 -Jupyter模式是基于脚本引擎(ScriptEngine)驱动的。首先打开Jupyter notebook后,然后加载组件、初始化脚本引擎。其中: +Jupyter模式是基于脚本引擎(ScriptEngine)驱动的。首先打开Jupyter notebook后,然后加载组件、初始化脚本引擎。其中: ``` from vnpy.app.script_trader import init_cli_trading from vnpy.gateway.ctp import CtpGateway @@ -241,10 +241,10 @@ trades = engine.get_trades(vt_orderid = your_vt_orderid,use_df = True) ### 交易委托 以委托买入为例,engine.buy()函数入参包括: -- vt_symbol:本地合约代码(字符串格式) -- price:报单价格(字符串格式); -- volume:报单数量(字符串格式); -- order_type:OrderType枚举常量,默认为限价单(OrderType.LIMIT),同时支持停止单(OrderType.STOP)、FAK(OrderType.FAK)、FOK(OrderType.FOK)、市价单(OrderType.MARKET),不同交易所支持报单方式不完全一致。 +- vt_symbol:本地合约代码(字符串格式) +- price:报单价格(浮点数类型); +- volume:报单数量(浮点数类型); +- order_type:OrderType枚举常量,默认为限价单(OrderType.LIMIT),同时支持停止单(OrderType.STOP)、FAK(OrderType.FAK)、FOK(OrderType.FOK)、市价单(OrderType.MARKET),不同交易所支持报单方式不完全一致。 ``` engine.buy(vt_symbol = "rb1910.SHFE",price = "3200",volume = "1",order_type=OrderType.LIMIT) ``` @@ -277,4 +277,4 @@ engine.send_email(msg = "Your Msg") - email.username:填写邮箱地址即可,如xxxx@qq.com。 - email.password:对于QQ邮箱,此处不是邮箱密码,而是开通SMTP后系统生成的一个授权码。 - email.sendert:email.username。 -- email.receiver:接受邮件的邮箱地址,比如xxxx@outlook.com。 \ No newline at end of file +- email.receiver:接受邮件的邮箱地址,比如xxxx@outlook.com。 diff --git a/vnpy/app/script_trader/engine.py b/vnpy/app/script_trader/engine.py index 7b730cd6..f9cfc08b 100644 --- a/vnpy/app/script_trader/engine.py +++ b/vnpy/app/script_trader/engine.py @@ -141,19 +141,19 @@ class ScriptEngine(BaseEngine): ) self.main_engine.subscribe(req, contract.gateway_name) - def buy(self, vt_symbol: str, price: str, volume: str, order_type: OrderType = OrderType.LIMIT) -> str: + def buy(self, vt_symbol: str, price: float, volume: float, order_type: OrderType = OrderType.LIMIT) -> str: """""" return self.send_order(vt_symbol, price, volume, Direction.LONG, Offset.OPEN, order_type) - def sell(self, vt_symbol: str, price: str, volume: str, order_type: OrderType = OrderType.LIMIT) -> str: + def sell(self, vt_symbol: str, price: float, volume: float, order_type: OrderType = OrderType.LIMIT) -> str: """""" return self.send_order(vt_symbol, price, volume, Direction.SHORT, Offset.CLOSE, order_type) - def short(self, vt_symbol: str, price: str, volume: str, order_type: OrderType = OrderType.LIMIT) -> str: + def short(self, vt_symbol: str, price: float, volume: float, order_type: OrderType = OrderType.LIMIT) -> str: """""" return self.send_order(vt_symbol, price, volume, Direction.SHORT, Offset.OPEN, order_type) - def cover(self, vt_symbol: str, price: str, volume: str, order_type: OrderType = OrderType.LIMIT) -> str: + def cover(self, vt_symbol: str, price: float, volume: float, order_type: OrderType = OrderType.LIMIT) -> str: """""" return self.send_order(vt_symbol, price, volume, Direction.LONG, Offset.CLOSE, order_type)