Home arrow Support arrow QpDevKit - Sample1 Code
QpDevKit - Sample1 Code PDF Print E-mail

Sample Code: Shows how to read in the new Fundamentals data

You can download the sample1 code by Clicking the Link to the Right: QpDevKit22

 

/**************************************************************************
* File: main.c
* Purpose: Shows how to read in the new Fundamentals data
**************************************************************************/
#include
#include
#include
#pragma comment( lib, "qpdll.lib" )
void main()
{

HKEY hKey; //Handle to Quotes Plus Setup Key

char cpDataDir[512]; //Quotes Plus Data Directory
char cpSymbol[8]; //Ticker Symbol

int iError; //Error Code

int iCount; //Return count

int j;

DWORD dwType, dwSize; //Registry value type and size

Master_Rec MasterRec; //Quotes Plus Master Record

QP_EARNINGS_EST_CON qpEEC; //Earnings Estimates Consensus Record

EPSRANK qpRankTable[10];

QP_ANALYST_RECOMMENDATION qpAnaRec; //Analyst Recommendations Record

QP_EXPECTED_EARNINGS qpExpEarnRec; //Expected Earning Record

QP_EARNINGS_ESTIMATES qpEarnEstRec; //Earnings Estimates Record

QP_ZACKS_DATA qpZacksData; //Zacks Fundamentals

QP_ZACKS_EPS qpZacksEps[20]; //Zacks Eps record

QP_NAME_CHANGES qpNameChg; // Name Change record

//----------Get the data directory from the registry------
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\Quotes Plus\\Setup",
0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS )
{
MessageBox( NULL, "Unable To Open Quotes Plus Setup Key!", NULL,
MB_OK | MB_ICONSTOP | MB_TASKMODAL );
return; //Exit Application
}
if( RegQueryValueEx( hKey, "DataDir", 0, &dwType, 0, &dwSize )
!= ERROR_SUCCESS )
{
RegCloseKey( hKey );
return;
}
if( RegQueryValueEx( hKey, "DataDir", 0, &dwType, (LPBYTE)cpDataDir,
&dwSize ) != ERROR_SUCCESS )
{
RegCloseKey( hKey );
return;
}

RegCloseKey( hKey );

//Initialize Quotes Plus Dll
if( R2_InitReadStock( cpDataDir, TRUE, NULL, FALSE ) != 0 )
return;

//------------Open Master Files and Zacks Data Files----------
if( R2_Open_Files( MASTER_FILE, cpDataDir ) != 0 )
{
R2_Done();
return;
}
if( R2_Open_Files( ZACKS_DATA, cpDataDir ) != 0 )
{
R2_Close_Files( MASTER_FILE );
R2_Done();
return;
}
if( R2_Open_Files( EPS_RANK_TABLE, cpDataDir ) != 0 )
{
R2_Close_Files( ZACKS_DATA );
R2_Close_Files( MASTER_FILE );
R2_Done();
return;
}
if( R2_Open_Files( NAME_CHG_FILE, cpDataDir ) != 0 )
{
R2_Close_Files( EPS_RANK_TABLE );
R2_Close_Files( ZACKS_DATA );
R2_Close_Files( MASTER_FILE );
R2_Done();
return;
}

memset( &qpRankTable , 0 , sizeof(qpRankTable) );

iCount = R2_QP_ReadEpsRank( "GM", qpRankTable, 10 );

for ( j=0 ; j
{
printf( "EPS Rank for GM %d , %d\n" , qpRankTable[j].lDate , qpRankTable[j].ucRank );
}

//Go through all of the symbols in the master file
iError = R2_QP_ReadMaster( QP_TOP, QP_SYMBOL, "", &MasterRec );
while( iError == 0 )
{
//Copy Symbol into storage
memcpy( cpSymbol, MasterRec.symbol, sizeof( MasterRec.symbol ) );
cpSymbol[sizeof( MasterRec.symbol )] = 0; //NULL Terminate

printf( "%s\n", cpSymbol );
//*********************Read in zacks data***********************
if( R2_QP_ReadEEC( cpSymbol, &qpEEC ) == 0 )
{ //Record Found

//Display or process data
printf( "Loaded Earnings Estimates Consensus For: %s\n",
cpSymbol );
}
if( R2_QP_ReadAnaRec( cpSymbol, &qpAnaRec ) == 0 )
{ //Record Found
//Display or process data
printf( "Loaded Analyst Recommendations For: %s\n",
cpSymbol );
}
if( R2_QP_ReadExpEarn( cpSymbol, &qpExpEarnRec ) == 0 )
{ //Record Found
//Display or process data
printf( "Loaded Expected Earnings For: %s\n", cpSymbol );
}
if( R2_QP_ReadEarnEst( cpSymbol, &qpEarnEstRec ) == 0 )
{ //Record Found
//Display or process data
printf( "Loaded Earnings Estimates For: %s\n", cpSymbol );
}
/*NOTE: These next two are the replacement for the Market Guide
data in the previous release*/
if( R2_QP_ReadZacksData( cpSymbol, &qpZacksData ) == 0 )
{ //Reocrd Found
//Display or process data
printf( "Loaded Zacks Data For: %s\n", cpSymbol );
}
if( R2_QP_ReadZacksEPS( cpSymbol, qpZacksEps ) == 0 )
{ //Record Found
//Display or process data
printf( "Loaded Zacks Eps Data For: %s\n", cpSymbol );
}

if( R2_QP_ReadNameChg( QP_EQUAL, /*Navigation Identifier*/
QP_NEWSYMBOL, /*QP_OLDSYMBOL or QP_NEWSYMBOL */
cpSymbol , /*Ticker Symbol*/
&qpNameChg /*Pointer to a QP_NAME_CHANGES*/ ) == 0 )
{
printf( "Loaded Name Change Data: %s\n", cpSymbol );
}


iError = R2_QP_ReadMaster( QP_NEXT, QP_SYMBOL, "", &MasterRec );
}

R2_Close_Files( MASTER_FILE );
R2_Close_Files( ZACKS_DATA );
R2_Close_Files( NAME_CHG_FILE );

R2_Done();
}

 

 

 

 
< Prev   Next >