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 cannot believe what a difference it makes trading with ProphetX!" - Comment from Bruce in Los Angeles
"I just wanted to tell you what a fine job you have been doing. While *******, from what I hear, has been down and out, off and on, IQ feed has held like a champ this week." - Comment from Shirin
"If someone needs the best quality data and backfill beyond what their broker provides at a rate that is the best in the industry, I highly recommend IQFeed." - Comment from Josh via Public Forum
"Boy, probably spent a thousand hours trying to get ******* API to work right. And now two hours to have something running with IQFeed. Hmmm, guess I was pretty stupid to fight rather than switch all this time. And have gotten more customer service from you guys already than total from them… in five years." - Comment from Jim
"It’s so nice to be working with real professionals!" - Comment from Len
"DTN feed was the only feed that consistently matched Bloomberg feed for BID/ASK data verification work these past years......DTN feed is a must for my supply & demand based trading using Cumulative Delta" - 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
"IQ feed is brilliant. The support is mind-bending. What service!" - Comment from Public Forum Post
"With HUGE volume on AAPL and RIMM for 2 days, everyone in a trading room was whining about freezes, crashes and lag with *******, RealTick, TS and Cyber. InvestorRT with IQFeed was rock solid. I mean SOLID!" - Comment from Public IRC Chat
"I use IQ Feed, Great stuff as far as data analysis information, storage and retrieval is concerned." - 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: Wed May 8, 2024 7:35 AM CFBB v1.2.0 17 ms.
© AderSoftware 2002-2003