Giter VIP home page Giter VIP logo

Comments (4)

vnpy avatar vnpy commented on May 12, 2024

在策略的Class里,创建一个类成员,比如self.lastOrder。

然后onOrder函数里,使用self.lastOrder = order缓存下来。

在onTick里就可以随意调用了。

from vnpy.

 avatar commented on May 12, 2024

` # CTA委托类型映射
if self.lastOrder != None and self.lastOrder.direction == u'多' and self.lastOrder.offset == u'开仓':
self.orderType = u'买开'
elif self.lastOrder != None and self.lastOrder.direction == u'多' and self.lastOrder.offset == u'平仓':
self.orderType = u'买平'
elif self.lastOrder != None and self.lastOrder.direction == u'空' and self.lastOrder.offset == u'开仓':
self.orderType = u'卖开'
elif self.lastOrder != None and self.lastOrder.direction == u'空' and self.lastOrder.offset == u'平仓':
self.orderType = u'卖平'

    if  self.lastOrder != None and self.lastOrder.status == u'未成交':
        self.cancelOrder(self.lastOrder.vtOrderID)

    elif self.lastOrder != None and self.lastOrder.status == u'已撤销':

        self.sendOrder(self.orderType, self.bar.close-10, 1)`

把代码放到onTick里面,极个别会出现不成交的撤销不了的情况,请看一下原因,谢谢

from vnpy.

vnpy avatar vnpy commented on May 12, 2024

撤销不了的委托,在OrderMonitor里面,显示的状态是什么?

from vnpy.

 avatar commented on May 12, 2024

http://zhishui.oss-cn-hangzhou.aliyuncs.com/capture%20image.png

from vnpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.