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)




"Very impressed with the quality of your feed - ******* is a real donkey in comparison." - Comment from A.C. via Email
"My broker in Davenport suggested I give you a try as he uses your service and says its the best." - Comment from Bill via RT Chat
"I started a trial a few weeks back before the market went wild. DTN.IQ didn’t miss anything and beat my other provider. I decided to stay with you because of the great service through all the volatility." - Comment from Mike
"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
"There is no doubt that IQFeed is the best data provider. I am very satisfied with your services. And IQFeed is the only one that I would recommend to my friends. Now, most of them are using your product in China." - Comment from Zhezhe
"And by the way, have to say this. I love the IQFeed software. It's rock solid and it has a really nice API." - Comment from Thomas via RT Chat
"Thank God for your Data Feed as the only Zippers I see are on my pants (LOL), and no more 200 pip spikes to mess up charts." - Comment from Spiro via Email
"IQ feed is brilliant. The support is mind-bending. What service!" - Comment from Public Forum Post
"Previously I was using *******. IQFeed is WAY more economical, and for my charting needs is just as good, if not better." - Comment from Public Forum Post
"I "bracket trade" all major news releases and I have not found one lag or glitch with DTN.IQ feed. I am very comfortable with their feed under all typical news conditions (Fed releases, employment numbers, etc)." - 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: Sun May 5, 2024 8:38 PM CFBB v1.2.0 12 ms.
© AderSoftware 2002-2003