In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the solutions to the failure of hanging orders before the opening of VNPY. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In VNPY quantitative trading platform, hanging stop order (STOP Order) is a common way to initiate a transaction. A stop order does not start a transaction until the price reaches the predetermined point.
Futures trading at 9: 00 in the morning and 9: 00 in the night just opened for 10 minutes, which is often the most volatile period of time, with a lot of trading opportunities. However, the existence of VNPY obviously should have a stop order, but it will not be available at the opening time. It should be at the opening time that all pending orders are invalid. Although these pending orders are invalid within VNPY, they will also fail. The specific code has been read for a long time, but still can not find the specific reason.
A temporary fix is provided here.
Define a global policy variable stopOpenOrder, with a default value of False
Define a global variable status, with the default value of NA, and put it in the policy judgment transaction code. Once the order is triggered, update this to the hanging order direction.
Finally, the stop order price is also set as a global variable.
two。 Override stops single push function. Once billed, the stopOpenOrder becomes True.
Def onStopOrder (self, so):
"" stop single push ""
Self.writeCtaLog (blocked% s, variety:% s, status:% s, direction:% s, price:% s% (self.name, so.vtSymbol, so.status, so.orderType, so.price))
If so.offset = = OFFSET_OPEN:
Self.stopOpenOrder = True
Self.putEvent ()
3. Override OnTick function. If pos is empty and stopOpenOrder = = False, if status is buy or short, hang the order accordingly.
Def onTick (self, tick):
"" receive quotation TICK push (must be inherited by the user) ""
If self.pos = 0 and self.stopOpenOrder = = False:
If self.status = = "buy":
Self.buy (self.buyPrice, self.fixedSize, True)
Elif self.status = = "short":
Self.short (self.shortPrice, self.fixedSize, True)
Self.bg.updateTick (tick)
In the actual test, if the hanging order condition is met, but no hanging order is issued, the order will be hung automatically when the first tick arrives.
The solution to the failure of hanging orders before the opening of VNPY is shared here. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.