CTP行情C#接口,RE行情插件 (含源码)

Discussion in 'RightEdge' started by 马不停蹄, Apr 22, 2012.

  1. CTPBridge.dll
    将非托管C++库转换为托管库,供.Net程序调用,仅实现了与行情相关的接口。参照源码,实现交易接口应该只是体力活。

    CSharpTest
    C#测试实例,跟上期技术官方提供的例子一致。

    CtpMdPlugin.dll
    RightEdge插件, RE 2010 build42 测试通过。请将CTPBridge.dll、CtpMdPlugin.dll、thostmduserapi.dll 拷贝到?:\Program Files\Yye Software\RightEdge 2010\Plugins目录下,重启RE,就可以加载插件了

    为了简便起见,没有写自定义配置对话框,将RE自己对话框的Port用着经纪公司代码了,真正的Port请直接写在ServerAddress末尾,形如 tcp://asp-sim2-md1.financial-trading-platform.com:26213

    在OnRtnDepthMarketData()事件中,如果使用行情源的时间戳,并且watchlist里symbol较多的话,RE会drop掉部分kick,并提示这些kick数据out of order。猜测是,RE内部会判断tick数据的时间先后,把即使后接收到但时间戳较小的数据丢弃了,但是RE可能并没有判断这个时间戳较小的tick的Symbol Name,其实应该跟时间戳较大的已经不一样了,其时间戳跟相同Symbol Name的上一tick数据比,还是大的。
    如果使用DateTime.Now则不会掉数据,但跟行情软件显示的图形会略有出入。

    添加Symbol到watchlist的时候,注意郑州品种年份为一位数,比如白糖1209,代码为SR209,而不是SR1209,否则收不到数据。

    下载地址
    http://ishare.iask.sina.com.cn/f/24071164.html
     
  2. 雷锋做到底,送佛到西天,把交易接口也做出来啊,嘿嘿
     
  3. 需要时间,敬请期待
     
  4. LZ能否做一个NT的CTP接口,万分期待
     
  5. 这个要支持的
     
  6. 支持原创
     
  7. fisher大侠这方面经验丰富,大家一定有很多共同语言交流!
     
  8. CTP行情交易接口.Net封装新版出炉,在原来基础上进行了些修改,增加了完整的交易接口支持。

    struct.h头文件修改自海风版C#接口的struct.cs文件,非常感谢。CTP里面的结构类型非常多,所以这个struct.cs文件的工作量非常大,而且海风为每一个类型都进行了注释,(VStudio里面编程的时候,IntelliSense就可以自动提示),真的很不容易,再谢海风一次。

    下载地址:
    http://ishare.iask.sina.com.cn/f/24114170.html
     
  9. 其实,可以写个程序自动生成。。。
     
  10. fromhere
    其实,可以写个程序自动生成。。。

    你为什么不写一个造福大众呢?
     
  11. 对NT不熟悉,从没用过,可以麻烦NT版的兄弟们做一个。
     
  12. 我这边生成头文件很简单,Copy Paste,正则表达式查找替换,几分钟就完成了,无需脚本 :D ,仅在处理虚函数、events、delegate时使用了辅助脚本。我是指海风那边从官方头文件生成托管结构类型工作量大,包括了所有非托管结构至托管的转换以及枚举类型和注释的处理。
     
  13. tick数据狂掉,非常晕。这是在debug模式下打印出来的信息,"Out of order tick"行是RightEdge自己的输出,其余为CTP行情插件打印的行情信息,连接的是浙商期货的前端。

    cu1207 : Time = 14:30:00.000, LasPrice = 57620
    ru1209 : Time = 14:30:00.000, LasPrice = 26790
    cu1207 : Time = 14:30:00.500, LasPrice = 57620
    ru1209 : Time = 14:30:00.500, LasPrice = 26790
    zn1207 : Time = 14:30:00.500, LasPrice = 15510
    IF1205 : Time = 14:30:02.500, LasPrice = 2631.6
    m1209 : Time = 14:30:01.000, LasPrice = 3394
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    Out of order tick diff: 00:00:11
    m1209 : Time = 14:30:01.000, LasPrice = 3394
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    cu1207 : Time = 14:30:01.000, LasPrice = 57620
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    ru1209 : Time = 14:30:01.000, LasPrice = 26795
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    Out of order tick diff: 00:00:01
    IF1205 : Time = 14:30:03.000, LasPrice = 2631.6
    cu1207 : Time = 14:30:01.500, LasPrice = 57620
    Out of order tick diff: 00:00:02
    Out of order tick diff: 00:00:02
    Out of order tick diff: 00:00:02
    Out of order tick diff: 00:00:02

    明显是中金所的服务器时间偏快,而且其他交易所数据也并非完全是按照顺序传来,导致RE丢弃部分tick数据。
    RE在处理tick数据上有些纰漏,它会保存最近一次tick的时间并进行比较,但是并没有保存和比较该tick的名称,这样较快的数据源就屏蔽了较慢源的数据。
     
  14. 在选项里将 Maximum Live Data Backlog 改大一点试试行不行
     
  15. 系统交易要求所有tick数据必须 in order.

    http://www.rightedgesystems.com/forums/Topic14329-12-1.aspx

    When running a system, the ticks need to all be in order, even for different symbols. A tick for one symbol updates the time for all the symbols, and hence may send out a new bar for other symbols. If a tick comes in with an earlier time it can't be added back to the bar that was already sent out.

    If the difference in time between the ticks is less than 0.5 seconds, RightEdge will modify the time of the "out of order tick" so it is the same timestamp as the latest tick received. That way it can still be processed by the system without causing errors due to being out of order. To avoid dropping ticks, you can do the same thing in your plugin but with a larger time difference tolerance.

    Thanks,
    Daniel
     
  16. 楼主现在找到更好的解决办法了吗?
     
  17. 没有好的办法,就使用DateTime.Now吧,就是中金所的时间偏差了一点点,基本在1秒左右。
     
  18. 值得学习学习
     
  19. CTP送来的行情TICK数据,对任一合约而言,都是按时间顺序的,根本不需要再过滤。
    对于不同的合约,比较TICK数据的先后次序,有多大意义吗?
     
  20. 既然看到了,怎么能不支持。。。。。。。。。。。。。虽感谢楼主。