C++ SDK - How to get last volume buy or sell info

brijesin
@sujith kindly check the kite chart picture. the volume trade shows red(sell) and green(buy). is it possible to get this information via c++


api?

***code kitews.hpp

Tick.volumeTraded = _getNum(packet, 16, 19);
Tick.totalBuyQuantity = _getNum(packet, 20, 23);
Tick.totalSellQuantity = _getNum(packet, 24, 27);

e.g. the above variables give me
volumeTraded:50
totalBuyQuantity:101130
totalSellQuantity:100737

But i don't know if it was sell or buy until i keep a counter again to store previous tBQ and tSQ.
  • sujith
    You can go through this article to know more about the colors of volume bar.
  • sujith
    sujith edited March 2021
    Total buy quantity and total sell quantity are the total buy order and sell order quantity pending at the exchange. It doesn't mean those many are executed.
  • brijesin
    thank you @sujith for kind help. it's really useful.

    is it possible to get the total buy order and sell order quantity pending at the exchange via C++ or any other kite API?
  • sujith
    You can use Websockets API or Quote API.
  • sujith
    You can refer to the documentation here.
  • brijesin
    thanks a ton @sujith. I'm still not clear on the answer. let me explain the problem again -

    I printed the data via C++ API. here is the snippet of 1 instrument. I get the last trade numbers(lastTradeno - 300, 6, 20 and 19) and get accumulated number of total buy(totalbuyno) and total sell(totalsellno). But i'm not clearly getting the signal if the lastTradeno was buy or it was sell?

    1 eq:758529 lprice:74.3 lastTradeno:300 totalbuyno:2729793 totalsellno:3865616
    1 eq:758529 lprice:74.35 lastTradeno:6 totalbuyno:2729793 totalsellno:3865616
    1 eq:758529 lprice:74.35 lastTradeno:20 totalbuyno:2729793 totalsellno:3865616
    1 eq:758529 lprice:74.35 lastTradeno:19 totalbuyno:2727063 totalsellno:3868289

    websocket
    ******************************
    Tick.mode = (packetSize == 44) ? MODE_QUOTE : MODE_FULL;
    Tick.lastPrice = _getNum(packet, 4, 7) / divisor;
    Tick.lastTradedQuantity = _getNum(packet, 8, 11);
    Tick.averageTradePrice = _getNum(packet, 12, 15) / divisor;
    Tick.volumeTraded = _getNum(packet, 16, 19);
    Tick.totalBuyQuantity = _getNum(packet, 20, 23);
    Tick.totalSellQuantity = _getNum(packet, 24, 27);
    Tick.OHLC.open = _getNum(packet, 28, 31) / divisor;
    Tick.OHLC.high = _getNum(packet, 32, 35) / divisor;
    Tick.OHLC.low = _getNum(packet, 36, 39) / divisor;
    Tick.OHLC.close = _getNum(packet, 40, 43) / divisor;

    quote
    ************************************
    Bytes Type
    0 - 4 int32 instrument_token
    4 - 8 int32 Last traded price (If mode is ltp, the packet ends here)
    8 - 12 int32 Last traded quantity
    12 - 16 int32 Average traded price
    16 - 20 int32 Volume traded for the day
    20 - 24 int32 Total buy quantity
    24 - 28 int32 Total sell quantity
    28 - 32 int32 Open price of the day
    32 - 36 int32 High price of the day
    36 - 40 int32 Low price of the day
    40 - 44 int32 Close price (If mode is quote, the packet ends here)
    44 - 48 int32 Last traded timestamp
    48 - 52 int32 Open Interest
    52 - 56 int32 Open Interest Day High
    56 - 60 int32 Open Interest Day Low
    60 - 64 int32 Exchange timestamp
    64 - 184 []byte Market depth entries
  • rakeshr
    @brijesin
    But i'm not clearly getting the signal if the lastTradeno was buy or it was sell?
    A trade happens, when there is buy and sell(one user sells and the other buys the same). So, here last trade number basically means, the number of shares/units of a contract that were traded in the last tick. You can go through this thread to understand more about this.
Sign In or Register to comment.