IBPY get correct historical volume data












0















I am trying to get historical data from IBPY.
I get it, but the volume is extremely low to the point it's useless.
I would like to know how to get the correct historical volume estimation.



I'm executing the following code:



from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
from time import sleep, strftime

def historical_data_handler(msg):
print(msg)

connection = Connection.create(port=7496, clientId=999)
connection.register(historical_data_handler, message.historicalData)
connection.connect()

req = Contract()
req.m_secType = "STK"
req.m_symbol = "TSLA"
req.m_currency = "USD"
req.m_exchange = "AMEX"
endtime = strftime('%Y%m%d %H:%M:%S')
connection.reqHistoricalData(1,req,endtime,"1 D","1 hour","TRADES",1,1)

sleep(5)
connection.disconnect()


and this is the output:



<historicalData reqId=1, date=20181123  16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>


The data arrives, but the volumes of each row are impossibly low (~22 for hourly bars).



On their website:
https://interactivebrokers.github.io/tws-api/historical_bars.html#hd_what_to_show



it is stated that:




Note: IB's historical data feed is filtered for some types of trades
which generally occur away from the NBBO such as combos, block trades,
and derivatives. For that reason the historical data volume will be
lower than an unfiltered historical data feed




However, the retrieved volumes are so low they are useless.



I suppose I'm not the first to need historical volume data, and there is probably a way to get it.
Can you please tell me how?
Thanks!










share|improve this question























  • Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

    – misantroop
    Nov 24 '18 at 11:40











  • Try changing exchange to SMART.

    – brian
    Nov 27 '18 at 3:34
















0















I am trying to get historical data from IBPY.
I get it, but the volume is extremely low to the point it's useless.
I would like to know how to get the correct historical volume estimation.



I'm executing the following code:



from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
from time import sleep, strftime

def historical_data_handler(msg):
print(msg)

connection = Connection.create(port=7496, clientId=999)
connection.register(historical_data_handler, message.historicalData)
connection.connect()

req = Contract()
req.m_secType = "STK"
req.m_symbol = "TSLA"
req.m_currency = "USD"
req.m_exchange = "AMEX"
endtime = strftime('%Y%m%d %H:%M:%S')
connection.reqHistoricalData(1,req,endtime,"1 D","1 hour","TRADES",1,1)

sleep(5)
connection.disconnect()


and this is the output:



<historicalData reqId=1, date=20181123  16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>


The data arrives, but the volumes of each row are impossibly low (~22 for hourly bars).



On their website:
https://interactivebrokers.github.io/tws-api/historical_bars.html#hd_what_to_show



it is stated that:




Note: IB's historical data feed is filtered for some types of trades
which generally occur away from the NBBO such as combos, block trades,
and derivatives. For that reason the historical data volume will be
lower than an unfiltered historical data feed




However, the retrieved volumes are so low they are useless.



I suppose I'm not the first to need historical volume data, and there is probably a way to get it.
Can you please tell me how?
Thanks!










share|improve this question























  • Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

    – misantroop
    Nov 24 '18 at 11:40











  • Try changing exchange to SMART.

    – brian
    Nov 27 '18 at 3:34














0












0








0








I am trying to get historical data from IBPY.
I get it, but the volume is extremely low to the point it's useless.
I would like to know how to get the correct historical volume estimation.



I'm executing the following code:



from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
from time import sleep, strftime

def historical_data_handler(msg):
print(msg)

connection = Connection.create(port=7496, clientId=999)
connection.register(historical_data_handler, message.historicalData)
connection.connect()

req = Contract()
req.m_secType = "STK"
req.m_symbol = "TSLA"
req.m_currency = "USD"
req.m_exchange = "AMEX"
endtime = strftime('%Y%m%d %H:%M:%S')
connection.reqHistoricalData(1,req,endtime,"1 D","1 hour","TRADES",1,1)

sleep(5)
connection.disconnect()


and this is the output:



<historicalData reqId=1, date=20181123  16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>


The data arrives, but the volumes of each row are impossibly low (~22 for hourly bars).



On their website:
https://interactivebrokers.github.io/tws-api/historical_bars.html#hd_what_to_show



it is stated that:




Note: IB's historical data feed is filtered for some types of trades
which generally occur away from the NBBO such as combos, block trades,
and derivatives. For that reason the historical data volume will be
lower than an unfiltered historical data feed




However, the retrieved volumes are so low they are useless.



I suppose I'm not the first to need historical volume data, and there is probably a way to get it.
Can you please tell me how?
Thanks!










share|improve this question














I am trying to get historical data from IBPY.
I get it, but the volume is extremely low to the point it's useless.
I would like to know how to get the correct historical volume estimation.



I'm executing the following code:



from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
from time import sleep, strftime

def historical_data_handler(msg):
print(msg)

connection = Connection.create(port=7496, clientId=999)
connection.register(historical_data_handler, message.historicalData)
connection.connect()

req = Contract()
req.m_secType = "STK"
req.m_symbol = "TSLA"
req.m_currency = "USD"
req.m_exchange = "AMEX"
endtime = strftime('%Y%m%d %H:%M:%S')
connection.reqHistoricalData(1,req,endtime,"1 D","1 hour","TRADES",1,1)

sleep(5)
connection.disconnect()


and this is the output:



<historicalData reqId=1, date=20181123  16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 16:30:00, open=333.21, high=333.33, low=331.04, close=332.92, volume=22, count=21, WAP=332.233, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 17:00:00, open=332.93, high=334.2, low=327.0, close=328.2, volume=42, count=39, WAP=329.755, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 18:00:00, open=329.0, high=330.37, low=327.96, close=327.96, volume=17, count=17, WAP=329.375, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>
<historicalData reqId=1, date=20181123 19:00:00, open=328.5, high=328.6, low=326.07, close=326.07, volume=25, count=25, WAP=327.498, hasGaps=False>


The data arrives, but the volumes of each row are impossibly low (~22 for hourly bars).



On their website:
https://interactivebrokers.github.io/tws-api/historical_bars.html#hd_what_to_show



it is stated that:




Note: IB's historical data feed is filtered for some types of trades
which generally occur away from the NBBO such as combos, block trades,
and derivatives. For that reason the historical data volume will be
lower than an unfiltered historical data feed




However, the retrieved volumes are so low they are useless.



I suppose I'm not the first to need historical volume data, and there is probably a way to get it.
Can you please tell me how?
Thanks!







algorithmic-trading interactive-brokers ibpy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 18:24









IlansIlans

14




14













  • Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

    – misantroop
    Nov 24 '18 at 11:40











  • Try changing exchange to SMART.

    – brian
    Nov 27 '18 at 3:34



















  • Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

    – misantroop
    Nov 24 '18 at 11:40











  • Try changing exchange to SMART.

    – brian
    Nov 27 '18 at 3:34

















Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

– misantroop
Nov 24 '18 at 11:40





Are you subscribed to all the data? IbPy hasn't been supported for a very long time, if you're using a newer API version there would be issues.

– misantroop
Nov 24 '18 at 11:40













Try changing exchange to SMART.

– brian
Nov 27 '18 at 3:34





Try changing exchange to SMART.

– brian
Nov 27 '18 at 3:34












1 Answer
1






active

oldest

votes


















0














Volume is reported in hundreds. For example 22 is 2,200 shares.



For a reference see the Trader Workstation API Reference Guide or online here.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451438%2fibpy-get-correct-historical-volume-data%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Volume is reported in hundreds. For example 22 is 2,200 shares.



    For a reference see the Trader Workstation API Reference Guide or online here.






    share|improve this answer




























      0














      Volume is reported in hundreds. For example 22 is 2,200 shares.



      For a reference see the Trader Workstation API Reference Guide or online here.






      share|improve this answer


























        0












        0








        0







        Volume is reported in hundreds. For example 22 is 2,200 shares.



        For a reference see the Trader Workstation API Reference Guide or online here.






        share|improve this answer













        Volume is reported in hundreds. For example 22 is 2,200 shares.



        For a reference see the Trader Workstation API Reference Guide or online here.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 23 '18 at 19:38









        Brian O'DonnellBrian O'Donnell

        1,148920




        1,148920






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451438%2fibpy-get-correct-historical-volume-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...