¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: eroor 322 errorMsg "Error processing request.-'bW' : cause - Duplicate ticker id"


 

Hi Liu,

The "counter" variable is initialized at a higher scope (not within the for-each loop).
This means that multiple parallel for-each executions are working against the same instance of that variable.
Depending on race conditions, this might lead to incorrect functioning of your logic.

Cheers,
Dmitry

On Thu, Jan 26, 2023 at 6:26 AM H Liu <liuhervey@...> wrote:
Hello

I am getting an duplicate ticker id error, however I already have a unique id for each request,

I have uploaded a screenshot of my snippet of code

when I comment out this code it works fine, I have tried commenting out contract.conid and using contract.tradingclass instead of contract.symbol but these did not solve the problem, the full message in debug shows?


? ? ? ? ? ? ? foreach (var strike in strikes)
? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ?foreach (var expire in expirations)
? ? ? ? ? ? ? ? ? ?{
? ? ? ? ? ? ? ? ? ? ? ?Contract contract = new Contract();

? ? ? ? ? ? ? ? ? ?contract.ConId = underlyingConId;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? contract.TradingClass = tradingClass;
? ? ? ? ? ? ? ? ? ? contract.Exchange = "SMART";
? ? ? ? ? ? ? ? ? ?contract.Currency = "USD";
? ? ? ? ? ? ? ? ? ?contract.SecType = "OPT";
? ? ? ? ? ? ? ? ? ?contract.Right = "CALL";
? ? ? ? ? ? ? ? ? ?contract.Multiplier = "100";

? ? ? ? ? ? ? ? ? ? contract.Strike = strike;
??
? ? ? ? ? ? ? ? ? ? ? ?contract.LastTradeDateOrContractMonth = expire;
? ? ? ? ? ? ? ? ? ? ? ?// Create a new TagValue List object (for API version 9.71)
? ? ? ? ? ? ? ? ? ? ? ?List<TagValue> mktDataOptions = new List<TagValue>();
? ? ? ? ? ? ? ? ? ?clientSocket.reqMarketDataType(3);
? ? ? ? ? ? ? ?clientSocket.reqMktData(reqId + counter, contract, "", false, false, mktDataOptions);?

? ? ? ? ? ? ? ? ? ? ? ?counter = counter + 1;
? ? ? ? ? ? ? ? ? ?}

Join [email protected] to automatically receive all group messages.