Merge pull request #2016 from LimingFang/dev

script md update
This commit is contained in:
vn.py 2019-08-10 11:22:32 +08:00 committed by GitHub
commit 4cd5772d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -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_typeOrderType枚举常量默认为限价单(OrderType.LIMIT)同时支持停止单OrderType.STOP、FAKOrderType.FAK、FOKOrderType.FOK、市价单OrderType.MARKET不同交易所支持报单方式不完全一致。
- vt_symbol本地合约代码(字符串格式)
- price报单价格(浮点数类型);
- volume报单数量(浮点数类型);
- order_typeOrderType枚举常量默认为限价单OrderType.LIMIT同时支持停止单OrderType.STOP、FAKOrderType.FAK、FOKOrderType.FOK、市价单OrderType.MARKET不同交易所支持报单方式不完全一致。
```
engine.buy(vt_symbol = "rb1910.SHFE",price = "3200",volume = "1",order_type=OrderType.LIMIT)
```

View File

@ -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)