Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"I just wanted to say how happy I am with your service. I was able to download the API docs last week and I was able to replicate Interactive Brokers historical bar queries and realtime bar queries over the weekend. That was about one of the fastest integrations that I've ever done and it works perfectly!!!!" - Comment from Jason via Email
"Everything is working great ! Very impressive client. The news refreshes better and is more pertinent than the ******* feed I paid $ 100/month for. I Also like the charts a lot." - Comment from Leon
"Excellent datafeed !!!" - Comment from Arely
"Can I get another account from you? I am tired of ******* going down so often" - Comment from George
"I just wanted to let you know how fast and easy I found it to integrate IQFeed into our existing Java code using your JNI client. In my experience, such things almost never go so smoothly - great job!" - Comment from Nate
"Very impressed with the quality of your feed - ******* is a real donkey in comparison." - Comment from A.C. via Email
"You are much better than lawyers or the phone company because you answer the phone when I call! I just love your customer service." - Comment from Isreal
"I am very happy I changed. I love the product, but more so I am thrilled with Tech Support. You are knowledgeable, polite, pleasant and professional." - Comment from Pat
"It’s so nice to be working with real professionals!" - Comment from Len
"I have been using IQFeed now for a few years in MultiCharts and I have zero complaints. Very, very rare to have any data hiccups or anything at all go wrong." - Comment from Public Forum
Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »Archive (2017 and earlier) »IQFeed Developer Support »Question about days to query for historical
Author Topic: Question about days to query for historical (3 messages, Page 1 of 1)

brandon
-Interested User-
Posts: 19
Joined: Jan 4, 2006


Posted: Jan 8, 2006 02:34 PM          Msg. 1 of 3
I have written a function to return the amount of days for which to query the historical server given a number of trading days. For instance, if today is Monday and the market has been open or is open, and you want the past two days of data, it will return 4, as it will skip over weekends. Otherwise, if the market is NOT open, it will return 5, as it will only be able to retrieve Friday and Thursday.

This has been integrated with a holiday schedule checker (MarketOpen() function) to determine whether or not the market was closed on that day (Christmas, Easter, etc).

The function is below. I ask DTN developers to please let me know if this logic is correct:

* If day is a weekend, increase the number of days to query by 1.
* If the time of the CURRENT DAY is prior to the market opening (9:30 am), then increase the number of days to query by 1.

Is this correct? Please note the function below, and take a look at the TODO comments.


/*
* Get the actual amount of days to query the IQConnect server for 'days' trading days.
*/
int GetQueryDays(int days)
{
struct tm l_tm;
int cur_hour, cur_min, cur_day, cur_mon, cur_year, cur_wday;
time_t l_time = time(NULL);
int num_days = 0;
int i;

if (!days)
return 1;

localtime_r(&l_time, &l_tm);

cur_min = l_tm.tm_min;
cur_hour = l_tm.tm_hour;
cur_day = l_tm.tm_mday;
cur_mon = l_tm.tm_mon;
cur_year = l_tm.tm_year;
cur_wday = l_tm.tm_wday;

num_days = days;
i = 1;

/* First, check if we're in a trading day, and the request is only for one day. */
if (days == 1)
{
if (cur_wday != 0 && cur_wday != 6 && cur_hour <= 23 && cur_min <= 59)
{
if (cur_hour > 8)
{
/* TODO: > 30 may be buggy? It depends on when they roll-over for 1 minute bars. Check this later. */
if (cur_hour == 9 && cur_min > 30)
return 1; /* Just one day is needed. */
}
}
}

while (i <= days)
{
if (cur_wday == 0)
cur_wday = 6;
else
cur_wday -= 1;

if (cur_day == 1)
{
if (cur_mon == 0)
{
/* First day of January; we have to scroll-back a year. */
cur_year -= 1;
cur_mon = 11;
}
else
{
cur_mon -= 1;
}

cur_day = NumberOfDaysInMonth(cur_mon, cur_year);
}
else
cur_day -= 1;

if (Market_Open(cur_mon, cur_day, cur_wday, 11, 30))
i++;
else
num_days++;
}

/* If today is a weekend, or it's past midnight but before the market open, then add another day to the total. */
if (l_tm.tm_wday == 0 || l_tm.tm_wday == 6)
num_days++;
else if (l_tm.tm_hour >= 0 && l_tm.tm_hour <= 8)
num_days++;
else if (l_tm.tm_hour == 9 && l_tm.tm_min <= 30)
{
/* TODO: <= 30 may be buggy? It depends on when they roll-over for 1 minute bars. Check this later. */
num_days++;
}

return num_days;
}



Thanks in advance!

Brandon
Edited by brandon on Jan 8, 2006 at 02:35 PM

DTN_Steve_S
-DTN Guru-
Posts: 2093
Joined: Nov 21, 2005


Posted: Jan 9, 2006 03:39 PM          Msg. 2 of 3
/* TODO: <= 30 may be buggy? It depends on when they roll-over for 1 minute bars. Check this later. */ 

The History lookup is based on calendar days. So the rollover would be at midnight.

for example:
HT,MSFT,1; will return no data until MSFT trades on the current day.
This is true for tic and minute data (HT and HM requests)

Daily Data (HD requests) behave slightly different because the EOD files are processed in the evening and will contain the current day's data as soon as the process is completed (usually around 7PM CST) until this time, it will return the previous day's data.

brandon
-Interested User-
Posts: 19
Joined: Jan 4, 2006


Posted: Jan 10, 2006 01:15 PM          Msg. 3 of 3
Thank you!

- Brandon
 

 

Time: Sat May 18, 2024 9:43 PM CFBB v1.2.0 10 ms.
© AderSoftware 2002-2003