Writing a new custom provider I faced the problem that in order to enter a short position I need to specify SHORT to the broker. The OQ allows only Buy and Sell. So my question is - how the custom provider can understand that the Sell in fact means Short? One of the ways would be to check a position for the instrument and if no position exists then treat Sell ans Short. But it seems like there is no access from the provider to Portfolio nor Position.

I thought there is some way to access Portfolio from UserProvider. I thought that the need to set Short is required by many brokers. Up to now we have created 5 providers to different brokers and 3 of them required Short. We pass the needed info in the order as you suggested. Just thought there is a more elegant way I missed.

I don't really think it's a good idea to check some position in the provider. Not even sure what portfolio you can refer to since you can have long position in one subportfolio (Order strategy portfolio, Order.Portfolio) and short in the other and resulting can be either short or long, so what portfolio would you take then?

Usually it's the broker who does just this. He checks your global account position and then treats your order as sell or sell short or even as two orders (reverse from long to short). I guess if your broker requires to pass exactly sell or sell short, your strategy should decide what order it's sending?

Otherwise I think you can access Order.Portfolio in the provider and then check order instrument position in this portfolio.

In general I agree with you. Unfortunately most of the brokers are not so flexible as IB. My experience with more than 10 brokers shows that majority of them demand Short to be specified. From 5 providers we implemented only 2 of them were ok with Sell for short. And I'm talking about major brokers such as Sterling, RealTick (not to mention smaller ones). Of course in this situation it is up to the strategy to decide but most of our strategies and that is what we do by putting the words "Enter Short", "Exit Short" etc. in the Text field of the order. I just thought if there is a better way somebody might come across.

Well, if you want to make it a kind of semiautomatic in OQ2014 world, I would say you can get to the root strategy portfolio using portfolio.Parent and then check instrument position in this global portfolio. But again there is no guarantee that it's synchronized with the broker account.

On the other hand I know that many brokers require sell short, we have this situation with Chinese brokers. But they also separate sell and sell short on the position level, so that you can have both long and short position in your portfolio and the broker doesn't sum up these positions. Then of course it's your strategy who decides what you want to do and what position you want to open / close with sell or sell short.

Our Chinese partners use OQ strategy trees to solve this and keep long buy/sell positions in one sub-startegy / portfolio and short sell short/buy cover in another.

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum