not getting null response for some instrument tokens

revanth1425
what is the best time to collect the instrument tokens
  • sujith
    Hi @revanth1425,
    You can fetch instruments csv anytime. It is very large file, so make sure you don't make multiple calls in a day. I would suggest fetch it and store it. It changes every day morning at around 7:30AM.
  • revanth1425
    I subscribe for two instruments and not able to get the length of the second packet it showing error
  • sujith
    sujith edited February 2017
    Hi @revanth1425,
    Please take a look at example for websocket usage.
  • revanth1425
    NSData *data=[NSKeyedArchiver archivedDataWithRootObject:message];

    if(data.length > 247)
    {
    id packets = [message subdataWithRange:NSMakeRange(0,2)];
    int packetsNumber = CFSwapInt16BigToHost(*(int*)([packets bytes]));
    NSLog(@ number of packets %i,packetsNumber);

    id packetsLng1 = [message subdataWithRange:NSMakeRange(2,4)];
    int packetsLength1 = CFSwapInt16BigToHost(*(int*)([packetsLng1 bytes]));
    NSLog(@ packet length1 %i,packetsLength1);

    id packetQuote = [message subdataWithRange:NSMakeRange(4,4+packetsLength1)];
    // int packetsQuoteValue = CFSwapInt16BigToHost(*(int*)([packetQuote bytes]));
    // NSLog(@ quote1 %i,packetsQuoteValue);


    id data4 = [packetQuote subdataWithRange:NSMakeRange(0, 4)];
    int32_t value = CFSwapInt32BigToHost(*(int32_t*)([data4 bytes]));
    NSLog(@ instrument token1 %d,value);


    id packetsLng2 = [message subdataWithRange:NSMakeRange(4+packetsLength1,4+packetsLength1+2)];
    int packetsLength2 = CFSwapInt16BigToHost(*(int*)([packetsLng2 bytes]));
    NSLog(@ packet length2 %d,packetsLength2);
    //
    id packetQuote2 = [message subdataWithRange:NSMakeRange(4+packetsLength1+2,4+packetsLength1+2+packetsLength2)];
    int packetsQuoteValue2 = CFSwapInt16BigToHost(*(int*)([packetQuote2 bytes]));
    NSLog(@ quote1 %i,packetsQuoteValue2);




    Message is the response data and i am taking subdatas and getting lengths it is working fine for first packet length but getting error when it comes to the second packet length.I followed the documentation for getting the packet lengths
  • sujith
    @revanth1425,
    Please take a look at parsing binary bytes for ticks here.
Sign In or Register to comment.