1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
int main( int argc, char** argv )
{
if ( argc != 2 )
{
std::cout << "usage: " << argv[ 0 ]
<< " FILE." << std::endl;
return 0;
}
std::string file = argv[ 1 ];
try
{
FIX::SessionSettings settings( file );
CKApplication application(30);
//CKApplication * t1 = new CKApplication(30);
FIX::FileStoreFactory storeFactory( settings );
FIX::SocketInitiator initiator( application, storeFactory, settings );
application.setSessionSetting(settings);
std::string symbol;
std::string symbol1;
//application.setHeader();
initiator.start();
Sleep(10000);
/* char action;
while(true){
std::cout << std::endl
<< "1) Market data Request" << std::endl
<< "4) Quit" << std::endl
<< "Action: ";
std::cin >> action;
if(action == '1')
while(application.LoginStatus && application.subscribestatus)
{
// application.Trading_Session();
//Sleep(30000);
application.subscribe();
}
else if (action == '2')
exit(0);
else
break;
}*/
std::ifstream fin;
fin.open("CurrencyPairs.txt");
if(!fin)
{
std::cout<<"File not found"<<endl;
return 0;
}
unsigned uiThreadID;
HANDLE hThread;
while(!fin.eof())
{
fin>> symbol;
application.Create_CSV(symbol);
//application.subscribe (symbol);
hThread = (HANDLE)_beginthreadex(NULL,0,CKApplication::subscribe,&application,0, &uiThreadID);
}
unsigned uiThreadID1;
HANDLE hThread1;
hThread1 = (HANDLE)_beginthreadex(NULL,0,CKApplication::run_market_data,NULL,CREATE_SUSPENDED, &uiThreadID1);
if(hThread1 == 0)
std::cout<<"Failed to create thread"<<std::endl;
unsigned uiThreadID2;
HANDLE hThread2;
hThread2 = (HANDLE)_beginthreadex(NULL,0,CKApplication::run_market_data,NULL,CREATE_SUSPENDED, &uiThreadID2);
if(hThread2 == 0)
std::cout<<"Failed to create thread"<<std::endl;
ResumeThread(hThread1);
ResumeThread(hThread2);
Sleep(1000);
WaitForSingleObject(hThread, INFINITE);
WaitForSingleObject(hThread1, INFINITE);
while(true);
return 0;
}
catch ( std::exception & e )
{
std::cout << e.what();
return 1;
}
}
|