API Support Forum
OEC API > Market Data > SubscribeTicks() also causes OnPriceChanged()
Author Topic: SubscribeTicks() also causes OnPriceChanged()
(5 messages, Page 1 of 1)
Moderators: VPfau
DBrubaker673
Posts: 55
Joined: Jul 18, 2007


Posted: Mar 17, 2009 @ 06:23 AM             Msg. 1 of 5
Because of the limit of 5 Ticks subscriptions and 50 Price subscriptions, I need to subscribe to Ticks on some symbols (and grab them in the OnTicksReceived() event) and subscribe to Prices on other symbols (and grab them in OnPriceChanged()).

To my surprise, subcribing to Ticks is enough to also cause occasional OnPriceChanged() events to be thrown. I've verified in the Subscription that only Tick, not Price, is subscribed.

Is this behavior intentional? I guess my workaround is to maintain my own dictionary of which symbols are subscribed how?

On a related issue, there are many SubscribeXXXX methods but only 2 UnsubscribeXXXX methods. Should I assume that Unsubscribe() will unsubscribe from both Ticks and Prices in the same call?

Thanks,
Dale

Dale
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 17, 2009 @ 08:21 AM             Msg. 2 of 5
1. You can see OnPriceChanged event for contracts that are automatically subscribed by the API. Any contract with your account has positions or fills is automatically subscribed.

You may have maintain your list of subscription, if you need to filter these subscriptions out.

2. for all Ticks and Bars subscriptions there is CancelSubscription call. You should not use Unsubscribe for Tick subscriptions and also should not use CancelSubscription for Price/DOM subscriptions.
DBrubaker673
Posts: 55
Joined: Jul 18, 2007


Posted: Mar 17, 2009 @ 09:27 AM             Msg. 3 of 5
Serge,

That helps. My only other comment is that it would be helpful if these automatic subscriptions would be reflected by a Price type in the Subscription in SubscriptionsList for the symbol. At present they seem to be invisible.

Thanks,
Dale

Dale
jlanawalt
Posts: 88
Joined: Feb 12, 2009


Posted: Mar 26, 2009 @ 07:09 PM             Msg. 4 of 5
It has not seemed "invisible" to me.

I can use our software and place a market order for may elecronic corn and close our software, and then open the CppCOMSample project which I've modified to iterate and print the list of subscriptions with each subscribe and (added) unsubscribe action. When I subscribe for bars for C6H0 it shows me that I've already got a subscription to ZCHK9 and CK9 both of type Price.
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: Mar 30, 2009 @ 04:15 PM             Msg. 5 of 5
Yes, automatic subscriptions are listed in the OECClient.Subscriptions collection, but you could not unsubscribe them.