API Support Forum
OEC API > API Support > Problem with double quote for the same symbol
Author Topic: Problem with double quote for the same symbol
(3 messages, Page 1 of 1)
Moderators: VPfau
VGishvaliner
Posts: 2
Joined: Oct 31, 2016


Posted: Oct 31, 2016 @ 02:31 PM             Msg. 1 of 3
Hello guys,

I have a question please.
Is it possible to get the same quote more then one time if I use the method "SubscribeTicks" for the same symbol more then one time?
sometimes I get for example for the ES the following quotes:

symbol, price, quantity
ESZ6, 2120.25, 74
ESZ6, 2120.25, 74
ESZ6, 2120.25, 74
ESZ6, 2120.25, 3
ESZ6, 2120.25, 3
ESZ6, 2120.25, 3
ESZ6, 2120.25, 121
ESZ6, 2120.25, 121
ESZ6, 2120.25, 121

so it is allways 3 times because i subscribed 3 times?
how can I avoid it?

I used the "Unsubscribe" just before the "SubscribeTicks" but it doesn't help.
what can I do to solve it?
Thanks a head I need to solve it ASAP.

example of test:

public void TestSubscribeTwice(string symbol)
{
feedOec.SubscribeTick("ESZ6");
feedOec.SubscribeTick("ESZ6");
}


my code:

public void SubscribeTick(string symbol)
{
if (string.IsNullOrEmpty(symbol)) return;
if (!Contracts.ContainsKey(symbol))
{
throw new ArgumentException("Symbol not found");
}
oecClient1.Unsubscribe(Contracts[symbol]);
oecClient1.SubscribeTicks(Contracts[symbol], DateTime.UtcNow);
}

public void UnsubscribeTick(string symbol)
{
if (string.IsNullOrEmpty(symbol)) return;
if (!Contracts.ContainsKey(symbol))
{
throw new ArgumentException("Symbol not found");
}
oecClient1.Unsubscribe(Contracts[symbol]);
}
NShine
Posts: 36
Joined:


Posted: Nov 01, 2016 @ 09:33 AM             Msg. 2 of 3
Hello

You will want to keep track of the Subscription object returned by the SubscribeTicks method. With this, you can call CancelSubscription(Subscription). The Unsubscribe(Contract) method you are using will only remove quote data.

If you want to see actual code implementing this, please refer to the Advanced API Example project we provide in our Samples at https://gainfutures.com/onelink/documentation.
NShine
Posts: 36
Joined:


Posted: Nov 02, 2016 @ 08:55 AM             Msg. 3 of 3
Also, if you don't care about history and only need the current price (quote) data, you can utilize our Subscribe(Contract) method. Multiple subscriptions to this method will not result in duplicate packets. Ticks are associated with charts, so they may not be what you are looking for. Again, the Advanced API Example is a great resource for this.