Python IB API Reqhistoricaldata












0















I want the callback.historical_data to return data from 9:30 AM, but instead it starts at 4 AM.



I'm using the IB API and Python. Please see my code below.



contract_Details = create.create_contract('BA', 'STK', 'SMART', 'USD')
tickerId = 9004
tws.reqHistoricalData(tickerId,
contract_Details,
"20181231 16:00:00",
"1 D",
"30 secs",
"BID",
0,
1)
pd.set_option('display.height', 2102)
pd.set_option('display.max_rows', 2102)
data= pd.DataFrame(callback.historical_Data,
columns = ["reqId", "date", "open",
"high", "low", "close",
"volume", "count", "WAP",
"hasGaps"])


The data:



data[:2102]
reqId date open high low close volume count WAP hasGaps
0 9004 20181231 04:00:00 310.35 317.05 310.35 317.05 -1 -1 -1.0 False
1 9004 20181231 04:00:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
2 9004 20181231 04:01:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
3 9004 20181231 04:01:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
4 9004 20181231 04:02:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
5 9004 20181231 04:02:30 317.05 317.11 317.05 317.11 -1 -1 -1.0 False
6 9004 20181231 04:03:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
7 9004 20181231 04:03:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
8 9004 20181231 04:04:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
9 9004 20181231 04:04:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
10 9004 20181231 04:05:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
11 9004 20181231 04:05:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
12 9004 20181231 04:06:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
13 9004 20181231 04:06:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
14 9004 20181231 04:07:00 317.11 317.25 317.11 317.25 -1 -1 -1.0 False
15 9004 20181231 04:07:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
16 9004 20181231 04:08:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
17 9004 20181231 04:08:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
18 9004 20181231 04:09:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
19 9004 20181231 04:09:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
20 9004 20181231 04:10:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
21 9004 20181231 04:10:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
22 9004 20181231 04:11:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
23 9004 20181231 04:11:30 317.25 317.26 317.25 317.26 -1 -1 -1.0 False
24 9004 20181231 04:12:00 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
25 9004 20181231 04:12:30 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
26 9004 20181231 04:13:00 317.26 317.31 317.26 317.26 -1 -1 -1.0 False
27 9004 20181231 04:13:30 317.26 317.35 317.25 317.35 -1 -1 -1.0 False
28 9004 20181231 04:14:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
29 9004 20181231 04:14:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
30 9004 20181231 04:15:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
31 9004 20181231 04:15:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False


I don't want it to start at 4 AM but at 9:30 AM when the market opens.










share|improve this question

























  • I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

    – Chandra
    Jan 3 at 2:26


















0















I want the callback.historical_data to return data from 9:30 AM, but instead it starts at 4 AM.



I'm using the IB API and Python. Please see my code below.



contract_Details = create.create_contract('BA', 'STK', 'SMART', 'USD')
tickerId = 9004
tws.reqHistoricalData(tickerId,
contract_Details,
"20181231 16:00:00",
"1 D",
"30 secs",
"BID",
0,
1)
pd.set_option('display.height', 2102)
pd.set_option('display.max_rows', 2102)
data= pd.DataFrame(callback.historical_Data,
columns = ["reqId", "date", "open",
"high", "low", "close",
"volume", "count", "WAP",
"hasGaps"])


The data:



data[:2102]
reqId date open high low close volume count WAP hasGaps
0 9004 20181231 04:00:00 310.35 317.05 310.35 317.05 -1 -1 -1.0 False
1 9004 20181231 04:00:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
2 9004 20181231 04:01:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
3 9004 20181231 04:01:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
4 9004 20181231 04:02:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
5 9004 20181231 04:02:30 317.05 317.11 317.05 317.11 -1 -1 -1.0 False
6 9004 20181231 04:03:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
7 9004 20181231 04:03:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
8 9004 20181231 04:04:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
9 9004 20181231 04:04:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
10 9004 20181231 04:05:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
11 9004 20181231 04:05:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
12 9004 20181231 04:06:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
13 9004 20181231 04:06:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
14 9004 20181231 04:07:00 317.11 317.25 317.11 317.25 -1 -1 -1.0 False
15 9004 20181231 04:07:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
16 9004 20181231 04:08:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
17 9004 20181231 04:08:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
18 9004 20181231 04:09:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
19 9004 20181231 04:09:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
20 9004 20181231 04:10:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
21 9004 20181231 04:10:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
22 9004 20181231 04:11:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
23 9004 20181231 04:11:30 317.25 317.26 317.25 317.26 -1 -1 -1.0 False
24 9004 20181231 04:12:00 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
25 9004 20181231 04:12:30 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
26 9004 20181231 04:13:00 317.26 317.31 317.26 317.26 -1 -1 -1.0 False
27 9004 20181231 04:13:30 317.26 317.35 317.25 317.35 -1 -1 -1.0 False
28 9004 20181231 04:14:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
29 9004 20181231 04:14:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
30 9004 20181231 04:15:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
31 9004 20181231 04:15:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False


I don't want it to start at 4 AM but at 9:30 AM when the market opens.










share|improve this question

























  • I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

    – Chandra
    Jan 3 at 2:26
















0












0








0








I want the callback.historical_data to return data from 9:30 AM, but instead it starts at 4 AM.



I'm using the IB API and Python. Please see my code below.



contract_Details = create.create_contract('BA', 'STK', 'SMART', 'USD')
tickerId = 9004
tws.reqHistoricalData(tickerId,
contract_Details,
"20181231 16:00:00",
"1 D",
"30 secs",
"BID",
0,
1)
pd.set_option('display.height', 2102)
pd.set_option('display.max_rows', 2102)
data= pd.DataFrame(callback.historical_Data,
columns = ["reqId", "date", "open",
"high", "low", "close",
"volume", "count", "WAP",
"hasGaps"])


The data:



data[:2102]
reqId date open high low close volume count WAP hasGaps
0 9004 20181231 04:00:00 310.35 317.05 310.35 317.05 -1 -1 -1.0 False
1 9004 20181231 04:00:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
2 9004 20181231 04:01:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
3 9004 20181231 04:01:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
4 9004 20181231 04:02:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
5 9004 20181231 04:02:30 317.05 317.11 317.05 317.11 -1 -1 -1.0 False
6 9004 20181231 04:03:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
7 9004 20181231 04:03:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
8 9004 20181231 04:04:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
9 9004 20181231 04:04:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
10 9004 20181231 04:05:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
11 9004 20181231 04:05:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
12 9004 20181231 04:06:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
13 9004 20181231 04:06:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
14 9004 20181231 04:07:00 317.11 317.25 317.11 317.25 -1 -1 -1.0 False
15 9004 20181231 04:07:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
16 9004 20181231 04:08:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
17 9004 20181231 04:08:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
18 9004 20181231 04:09:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
19 9004 20181231 04:09:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
20 9004 20181231 04:10:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
21 9004 20181231 04:10:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
22 9004 20181231 04:11:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
23 9004 20181231 04:11:30 317.25 317.26 317.25 317.26 -1 -1 -1.0 False
24 9004 20181231 04:12:00 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
25 9004 20181231 04:12:30 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
26 9004 20181231 04:13:00 317.26 317.31 317.26 317.26 -1 -1 -1.0 False
27 9004 20181231 04:13:30 317.26 317.35 317.25 317.35 -1 -1 -1.0 False
28 9004 20181231 04:14:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
29 9004 20181231 04:14:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
30 9004 20181231 04:15:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
31 9004 20181231 04:15:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False


I don't want it to start at 4 AM but at 9:30 AM when the market opens.










share|improve this question
















I want the callback.historical_data to return data from 9:30 AM, but instead it starts at 4 AM.



I'm using the IB API and Python. Please see my code below.



contract_Details = create.create_contract('BA', 'STK', 'SMART', 'USD')
tickerId = 9004
tws.reqHistoricalData(tickerId,
contract_Details,
"20181231 16:00:00",
"1 D",
"30 secs",
"BID",
0,
1)
pd.set_option('display.height', 2102)
pd.set_option('display.max_rows', 2102)
data= pd.DataFrame(callback.historical_Data,
columns = ["reqId", "date", "open",
"high", "low", "close",
"volume", "count", "WAP",
"hasGaps"])


The data:



data[:2102]
reqId date open high low close volume count WAP hasGaps
0 9004 20181231 04:00:00 310.35 317.05 310.35 317.05 -1 -1 -1.0 False
1 9004 20181231 04:00:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
2 9004 20181231 04:01:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
3 9004 20181231 04:01:30 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
4 9004 20181231 04:02:00 317.05 317.05 317.05 317.05 -1 -1 -1.0 False
5 9004 20181231 04:02:30 317.05 317.11 317.05 317.11 -1 -1 -1.0 False
6 9004 20181231 04:03:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
7 9004 20181231 04:03:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
8 9004 20181231 04:04:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
9 9004 20181231 04:04:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
10 9004 20181231 04:05:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
11 9004 20181231 04:05:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
12 9004 20181231 04:06:00 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
13 9004 20181231 04:06:30 317.11 317.11 317.11 317.11 -1 -1 -1.0 False
14 9004 20181231 04:07:00 317.11 317.25 317.11 317.25 -1 -1 -1.0 False
15 9004 20181231 04:07:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
16 9004 20181231 04:08:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
17 9004 20181231 04:08:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
18 9004 20181231 04:09:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
19 9004 20181231 04:09:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
20 9004 20181231 04:10:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
21 9004 20181231 04:10:30 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
22 9004 20181231 04:11:00 317.25 317.25 317.25 317.25 -1 -1 -1.0 False
23 9004 20181231 04:11:30 317.25 317.26 317.25 317.26 -1 -1 -1.0 False
24 9004 20181231 04:12:00 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
25 9004 20181231 04:12:30 317.26 317.26 317.26 317.26 -1 -1 -1.0 False
26 9004 20181231 04:13:00 317.26 317.31 317.26 317.26 -1 -1 -1.0 False
27 9004 20181231 04:13:30 317.26 317.35 317.25 317.35 -1 -1 -1.0 False
28 9004 20181231 04:14:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
29 9004 20181231 04:14:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
30 9004 20181231 04:15:00 317.35 317.35 317.35 317.35 -1 -1 -1.0 False
31 9004 20181231 04:15:30 317.35 317.35 317.35 317.35 -1 -1 -1.0 False


I don't want it to start at 4 AM but at 9:30 AM when the market opens.







python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 4:27









Ishaan Javali

1,3643821




1,3643821










asked Jan 1 at 22:36









ChandraChandra

11




11













  • I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

    – Chandra
    Jan 3 at 2:26





















  • I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

    – Chandra
    Jan 3 at 2:26



















I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

– Chandra
Jan 3 at 2:26







I figured it out, this can be closed. tws.reqHistoricalData(tickerId, contract_Details, "20181231 16:00:00", "1 D", "30 secs", "BID", 1, 1). Instead of the last 2 parameters being 0,1 the API reference says if I do 1,1 it will return data from market open to market close.

– Chandra
Jan 3 at 2:26














0






active

oldest

votes











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%2f53999484%2fpython-ib-api-reqhistoricaldata%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f53999484%2fpython-ib-api-reqhistoricaldata%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

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter