SmartQuant Discussion
http://www.smartquant.com/forums/

Accessing position from a custom provider
http://www.smartquant.com/forums/viewtopic.php?f=60&t=10984
Page 1 of 1

Author:  edwardgonen [ Thu Aug 13, 2015 11:11 am ]
Post subject:  Accessing position from a custom provider

Hi,

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.

Any ideas?

Ed

Author:  Dr. Anton Fokin [ Thu Aug 13, 2015 5:34 pm ]
Post subject:  Re: Accessing position from a custom provider

Hi,

I think you can use Order.Fileds ObjectTable to pass any information to the broker along with the order.

Regards,
Anton

Author:  Dr. Anton Fokin [ Thu Aug 13, 2015 5:35 pm ]
Post subject:  Re: Accessing position from a custom provider

By the way are you working with OQ or OQ2014?

Regards,
Anton

Author:  edwardgonen [ Thu Aug 13, 2015 6:01 pm ]
Post subject:  Re: Accessing position from a custom provider

Ok,

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.

It is OQ.

E

Author:  Dr. Anton Fokin [ Thu Aug 13, 2015 6:17 pm ]
Post subject:  Re: Accessing position from a custom provider

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.

Regards,
Anton

Author:  edwardgonen [ Thu Aug 13, 2015 7:07 pm ]
Post subject:  Re: Accessing position from a custom provider

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.

probably not. Thanks a lot.

best regards
e

Author:  Dr. Anton Fokin [ Thu Aug 13, 2015 7:25 pm ]
Post subject:  Re: Accessing position from a custom provider

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.

Regards,
Anton

Author:  edwardgonen [ Thu Aug 13, 2015 7:39 pm ]
Post subject:  Re: Accessing position from a custom provider

Thanks. It's been a pleasure to hear from you as always during the last 7 (!) years :). Hope everything is well on your side. Keep in touch.
Ed

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/