Re-create IB Stock Volume Chart

Discussion in 'Automated Trading' started by ArthurC, Feb 11, 2016.

  1. ArthurC

    ArthurC

    Hi All,

    I am trying to re-create the stock volume chart in IB to no avail, could anyone help me out?

    I use IB-Matlab to talk to API of IB, and so far I know that if I keep doing query of a stock with QuotesNumber set to 1, and I plot the volume info that's extracted from the output of the query, the volume keeps increasing because it's accumulative volume. So I take the difference between each volume value and plot it, the value become too small.

    For example, at time1 I do a query and get volume1, at time1+1min I do a query and get volume2. I suppose volume2-volume1 would give me the trading volume in that 1 minute difference, and would be the same as the 1-minute volume bar chart in IB's stock volume chart, but actually it's too small.

    Could anyone give me a hand?

    Arthur

    p.s.:

    I think the query in IB-Matlab is equivalent to reqMktData() in IB's function, and "QuotesNumber set to 1" is the same as setting the snapshot parameter of reqMktData() to True. When the snapshot is set to false, it "returns continues updates" according to IB documentation, but I am not sure what it means, just to let you know my understanding of reqMktData() so far.
     
  2. Unless you think it's "proprietary," you'd get better responses on this (or any) board by posting your code.
     
  3. ArthurC

    ArthurC

    Thank you for the advice, to cover more audience, let me spell out the mnemonic code here:
    - set time0 as current_time.
    - keep doing query of stockA and record the volume info.
    - when the current_time reaches time0+durationA, average all the volume data during durationA, save this as volumeA
    - set time0 as current_time and wait for another durationA and average all the volume data during durationA, save this as volumeB
    - do volumeDurationA= volumeB - volumeA, and this would be one volume bar, and this bar amount is much less than what IB's stock volume bar is (bar time duration is set equal).

    If anyone can re-create IB's stock volume, feel free to share actual or mnemonic code. Thank you!

    Arthur