I have some code that can successfully get the time/sales data for a few stocks. I am trying to use time/sales to get 1 day of data for 500 stocks plus get real-time updates.
The following code fragment works with 5 stocks, but with 500 it has two errors: 1) it doesn't get more data, and 2) I get a message box saying winsig cannot communicate with my application, and asks me to retry or switch-to.
Here is the code fragments:
for (l=0; l<490; l++) {
AxNext();
}
void CMainDlg::AxNext()
{
if (ax_symbol_list.IsEmpty()) return;
ax_symbol = ax_symbol_list.GetHead();
ax_symbol_list.RemoveHead();
TimeSalesFilter f;
f.sSymbol = S2B(ax_symbol);
f.bQuotes = TRUE;
f.bTrades = TRUE;
f.lNumDays = 1;
f.bFilterPrice = FALSE;
f.bFilterVolume = FALSE;
f.bFilterQuoteExchanges = FALSE;
f.bFilterTradeExchanges = FALSE;
f.dMaxPrice = 0;
f.dMinPrice = 0;
f.lVolume = 0;
f.sQuoteExchangesList = S2B(" ");
f.sTradeExchangesList = S2B(" ");
m_hHistory2 = (*m_piHooks)->GetRequestTimeSales(&f);
ASSERT(m_hHistory2<4096);
ax_handle_symbol[m_hHistory2]=ax_symbol;
ax_handle_cnt[m_hHistory2]=0;
printf("new handle %d %s",m_hHistory2,ax_symbol);
ASSERT(m_hHistory2);
}
void CNdxDlg::ES_OnTimeSalesChanged(long l) {
long lNumBars;
long lNumRtBars;
TimeSalesData baritem;
lNumBars = 0;
lNumRtBars = (*m_piHooks)->GetGetNumTimeSalesRtBars(l);
lNumBars = (*m_piHooks)->GetGetNumTimeSalesBars(l);
if (lNumBars==0 || lNumBars>ax_handle_cnt[l]) {
ax_handle_cnt[l]=lNumBars;
return;
}
int date,sec;
int first_date=0,first_time=0,last_date=0,last_time=0;
baritem = (TimeSalesData)((*m_piHooks)->GetGetTimeSalesBar(l, -(lNumBars-1)));
ConvertTime(baritem.dtTime,date,sec);
first_date=date;
first_time=sec; //seconds since midnight
if (sec>9*3600+32*60) {
return;
}
SYSTEMTIME dt;
GetLocalTime(&dt);
for (long i = -(lNumBars-1); i <= 0; i++) {
baritem = (TimeSalesData)((*m_piHooks)->GetGetTimeSalesBar(l, i));
ConvertTime(baritem.dtTime,date,sec);
last_date=date;
last_time=sec;
}
printf("%d:%d:%d.%d %s read %d bars %d-%d %d:%d:%d to %d-%d %d:%d:%d",
dt.wHour,dt.wMinute,dt.wSecond,dt.wMilliseconds,ax _handle_symbol[l].GetBuffer(0),
lNumBars,
first_date/32%16,first_date%32,first_time/3600,first_time/60%60,first_time%60,
last_date/32%16,last_date%32,last_time/3600,last_time/60%60,last_time%60);
(*m_piHooks)->ReleaseTimeSales(l);
if (ax_handle_symbol[l].GetLength()==0) {
int iii=0;
}
}
The following code fragment works with 5 stocks, but with 500 it has two errors: 1) it doesn't get more data, and 2) I get a message box saying winsig cannot communicate with my application, and asks me to retry or switch-to.
Here is the code fragments:
for (l=0; l<490; l++) {
AxNext();
}
void CMainDlg::AxNext()
{
if (ax_symbol_list.IsEmpty()) return;
ax_symbol = ax_symbol_list.GetHead();
ax_symbol_list.RemoveHead();
TimeSalesFilter f;
f.sSymbol = S2B(ax_symbol);
f.bQuotes = TRUE;
f.bTrades = TRUE;
f.lNumDays = 1;
f.bFilterPrice = FALSE;
f.bFilterVolume = FALSE;
f.bFilterQuoteExchanges = FALSE;
f.bFilterTradeExchanges = FALSE;
f.dMaxPrice = 0;
f.dMinPrice = 0;
f.lVolume = 0;
f.sQuoteExchangesList = S2B(" ");
f.sTradeExchangesList = S2B(" ");
m_hHistory2 = (*m_piHooks)->GetRequestTimeSales(&f);
ASSERT(m_hHistory2<4096);
ax_handle_symbol[m_hHistory2]=ax_symbol;
ax_handle_cnt[m_hHistory2]=0;
printf("new handle %d %s",m_hHistory2,ax_symbol);
ASSERT(m_hHistory2);
}
void CNdxDlg::ES_OnTimeSalesChanged(long l) {
long lNumBars;
long lNumRtBars;
TimeSalesData baritem;
lNumBars = 0;
lNumRtBars = (*m_piHooks)->GetGetNumTimeSalesRtBars(l);
lNumBars = (*m_piHooks)->GetGetNumTimeSalesBars(l);
if (lNumBars==0 || lNumBars>ax_handle_cnt[l]) {
ax_handle_cnt[l]=lNumBars;
return;
}
int date,sec;
int first_date=0,first_time=0,last_date=0,last_time=0;
baritem = (TimeSalesData)((*m_piHooks)->GetGetTimeSalesBar(l, -(lNumBars-1)));
ConvertTime(baritem.dtTime,date,sec);
first_date=date;
first_time=sec; //seconds since midnight
if (sec>9*3600+32*60) {
return;
}
SYSTEMTIME dt;
GetLocalTime(&dt);
for (long i = -(lNumBars-1); i <= 0; i++) {
baritem = (TimeSalesData)((*m_piHooks)->GetGetTimeSalesBar(l, i));
ConvertTime(baritem.dtTime,date,sec);
last_date=date;
last_time=sec;
}
printf("%d:%d:%d.%d %s read %d bars %d-%d %d:%d:%d to %d-%d %d:%d:%d",
dt.wHour,dt.wMinute,dt.wSecond,dt.wMilliseconds,ax _handle_symbol[l].GetBuffer(0),
lNumBars,
first_date/32%16,first_date%32,first_time/3600,first_time/60%60,first_time%60,
last_date/32%16,last_date%32,last_time/3600,last_time/60%60,last_time%60);
(*m_piHooks)->ReleaseTimeSales(l);
if (ax_handle_symbol[l].GetLength()==0) {
int iii=0;
}
}
Comment