Skip to content

Commit

Permalink
修复了vn.ctp中的ReqOrderInsert函数bug,发布ctpdemo
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxy123 committed Apr 24, 2015
1 parent 880c64a commit da1fb95
Show file tree
Hide file tree
Showing 116 changed files with 9,378 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# vn.py
基于python的开源交易平台开发框架

## 2015/4/24项目状态##
发布了基于vn.ctp的Demo,在vn.demo/ctpdemo文件夹下,可用于CTP柜台期货公司的手动交易。

## 2015/4/20项目状态##
发布了用于展示如何使用vn.py框架开发的vn.demo,使用了vn.event和vn.lts模块,可以用于华宝证券LTS柜台的手动交易。

Expand Down
Binary file modified vn.ctp/vnctptd/test/vnctptd.pyd
Binary file not shown.
32 changes: 29 additions & 3 deletions vn.ctp/vnctptd/vnctptd/vnctptd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6925,14 +6925,13 @@ int TdApi::reqTradingAccountPasswordUpdate(dict req, int nRequestID)

int TdApi::reqOrderInsert(dict req, int nRequestID)
{
//手动处理
CThostFtdcInputOrderField myreq = CThostFtdcInputOrderField();
memset(&myreq, 0, sizeof(myreq));
getChar(req, "ContingentCondition", &myreq.ContingentCondition);
getChar(req, "CombOffsetFlag", myreq.CombOffsetFlag);
getChar(req, "UserID", myreq.UserID);
getChar(req, "UserID", myreq.UserID);
getDouble(req, "LimitPrice", &myreq.LimitPrice);
getInt(req, "UserForceClose", &myreq.UserForceClose);
getChar(req, "Direction", &myreq.Direction);
getInt(req, "IsSwapOrder", &myreq.IsSwapOrder);
getInt(req, "VolumeTotalOriginal", &myreq.VolumeTotalOriginal);
getChar(req, "OrderPriceType", &myreq.OrderPriceType);
Expand All @@ -6950,6 +6949,33 @@ int TdApi::reqOrderInsert(dict req, int nRequestID)
getChar(req, "InvestorID", myreq.InvestorID);
getChar(req, "VolumeCondition", &myreq.VolumeCondition);
getInt(req, "RequestID", &myreq.RequestID);

//处理Direction
if (req.has_key("Direction"))
{
object o1 = req["Direction"];
extract<string> x1(o1);
if (x1.check())
{
string s1 = x1();
const char *buffer1 = s1.c_str();
myreq.Direction = *buffer1;
}
}

//处理CombOffsetFlag
if (req.has_key("CombOffsetFlag"))
{
object o2 = req["CombOffsetFlag"];
extract<string> x2(o2);
if (x2.check())
{
string s2 = x2();
const char *buffer2 = s2.c_str();
myreq.CombOffsetFlag[0] = *buffer2;
}
}

int i = this->api->ReqOrderInsert(&myreq, nRequestID);
return i;
};
Expand Down
34 changes: 34 additions & 0 deletions vn.demo/ctpdemo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#vn.demo介绍
该demo主要用于展示如何使用vn.py框架开发交易平台,使用了vn.event和vn.lts模块。

##如何使用
常规用户可以直接运行exe文件夹下的demoMain.exe。

对开发有兴趣的用户需要根据vnpy.org的教程3安装相关的开发环境,然后通过demoMain.py和demoMain.pyw(无cmd界面)运行。

##实现功能
demo的实现参考了盈佳和尔易的LTS交易平台,功能如下:

1. 行情、持仓、账户、成交、报单的监控
2. 平台的日志记录
3. 下单交易,实现了LTS提供的所有订单类型和交易类型
4. 双击报单监控中的单元格撤单,以及下单交易组件一键全撤

##文件说明

- demoApi.py主要包含了程序的底层接口,对vn.lts中的API进行了简化封装
- demoEngine.py主要包含了程序的中间层,负责调用底层接口
- demoUi.py主要包含了用于数据监控和主动函数调用相关的GUI组件
- demoMain.py包含了程序的主函数入口,双击运行
- demoMain.pyw功能和demoMain.py一样,双击时会自动调用pythonw.exe运行(无cmd界面)

##nuitka编译说明
要执行nuikta编译,请在本文件夹下打开cmd,并输入以下命令:

nuitka --standalone --windows-disable-console --icon=C:\vn.demo\vnpy.ico demoMain.py

其中C:\vn.demo\vnpy.ico需要修改为用户vn.demo文件夹的路径。




Loading

0 comments on commit da1fb95

Please sign in to comment.