Skip to content

Commit

Permalink
Merge pull request #2 from Edanflame/main
Browse files Browse the repository at this point in the history
[Mod] 修复拒单时错误撮合
  • Loading branch information
vnpy committed Feb 20, 2022
2 parents 2ad3a56 + 04d4b31 commit 60df4a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
# 1.0.0版本

1. 将模块的图标文件信息,改为完整路径字符串
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -7,7 +7,7 @@
<p align="center">
<img src ="https://img.shields.io/badge/version-1.0.0-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/platform-windows|linux|macos-yellow.svg"/>
<img src ="https://img.shields.io/badge/python-3.7-blue.svg" />
<img src ="https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg" />
<img src ="https://img.shields.io/github/license/vnpy/vnpy.svg?color=orange"/>
</p>

Expand All @@ -17,7 +17,7 @@ PaperAccount是用于本地仿真交易的功能模块,用户可以通过其UI

## 安装

安装需要基于2.8.0版本以上的[VN Studio](https://www.vnpy.com)
安装需要基于3.0.0版本以上的[VN Studio](https://www.vnpy.com)

直接使用pip命令:

Expand All @@ -28,5 +28,5 @@ pip install vnpy_paperaccount
下载解压后在cmd中运行

```
python setup.py install
```
pip install -e .
```
2 changes: 1 addition & 1 deletion vnpy_paperaccount/__init__.py
Expand Up @@ -43,4 +43,4 @@ class PaperAccountApp(BaseApp):
display_name = "模拟交易"
engine_class = PaperEngine
widget_name = "PaperManager"
icon_name = "paper.ico"
icon_name = str(app_path.joinpath("ui", "paper.ico"))
7 changes: 3 additions & 4 deletions vnpy_paperaccount/engine.py
Expand Up @@ -190,7 +190,7 @@ def send_order(self, req: OrderRequest, gateway_name: str) -> str:
self.put_event(EVENT_POSITION, copy(updated_position))

# Cross order immediately with last tick data
if self.instant_trade:
if self.instant_trade and order.status != Status.REJECTED:
tick = self.ticks.get(order.vt_symbol, None)
if tick:
self.cross_order(order, tick)
Expand Down Expand Up @@ -296,6 +296,7 @@ def check_order_valid(self, order: OrderData, contract: ContractData) -> Optiona

if order.volume > available:
order.status = Status.REJECTED
self.write_log("委托被拒单,可平仓位不足")
else:
short_position.frozen += order.volume
return short_position
Expand All @@ -305,13 +306,11 @@ def check_order_valid(self, order: OrderData, contract: ContractData) -> Optiona

if order.volume > available:
order.status = Status.REJECTED
self.write_log("委托被拒单,可平仓位不足")
else:
long_position.frozen += order.volume
return long_position

if order.status == Status.REJECTED:
self.write_log(f"委托被拒单,可平仓位不足")

def cross_order(self, order: OrderData, tick: TickData):
""""""
contract = self.main_engine.get_contract(order.vt_symbol)
Expand Down

0 comments on commit 60df4a4

Please sign in to comment.