Exemple #1
0
	void context_menu::exec()
	{
		bool finished = false;
		menu().closed([&finished]()
		{
			finished = true;
		});
		iWidget = iParent != nullptr ?
			std::make_unique<popup_menu>(*iParent, iPosition, menu(), iStyle) :
			std::make_unique<popup_menu>(iPosition, menu(), iStyle);
		app::instance().keyboard().grab_keyboard(*iWidget);
		app::event_processing_context epc(app::instance(), "neogfx::context_menu");
		while (!finished)
		{
			app::instance().process_events(epc);
		}
	}
Exemple #2
0
void *setupExchange(void * inStruct)
{
    exchangeThread *et = (exchangeThread *) inStruct;
    if (!et)
        return NULL;
    pthread_mutex_lock(et->mutex);
    exchange * temp = new(exchange);
    int j = 0;
    
    std::stringstream query;
    
    std::cout <<  et->m_sExchange << " thread started" << std::endl;
    /* set the exchange info based on the data in the configuration file. */
    query << "/configuration/" << et->m_sExchange << "/name";
//std::cout << "requesting " << query.str() << ": " << "found " << XMLConfig->find(query.str())<< std::endl;
    
    temp->SetName(XMLConfig->find(query.str()));
    
    query.str("");
    query << "/configuration/" << et->m_sExchange << "/symbol";
	temp->SetSymbol(XMLConfig->find(query.str()));
	temp->SetExchangeID(et->exchangeID);
    query.str("");
    
    std::string host;
    std::string user;
    std::string password;
    std::string schema;
    query << "/configuration/" << et->m_sExchange << "/sources/database/host";
    host = XMLConfig->find(query.str());
    query.str("");
    query << "/configuration/" << et->m_sExchange << "/sources/database/user";
    user = XMLConfig->find(query.str());
    query.str("");
    query << "/configuration/" << et->m_sExchange << "/sources/database/password";
    password = XMLConfig->find(query.str());
    query.str("");
    query << "/configuration/" << et->m_sExchange << "/sources/database/schema";
    schema = XMLConfig->find(query.str());
    
    /* this is the etl store to the mysql database */
    mysql_exchange ms_exchange(temp, temp->GetExchangeID());
    ms_exchange.SetConnectionInfo(host, user, password, schema);
    query.str("");
    /* 
     if there is nasdaq seed data use it.
     This means that there is no data in the database as well,
     so we are going to go get the historicals and all of that data.
     */
    query << "/configuration/" << et->m_sExchange <<  "/sources/symbol_seed/file";
    if(XMLConfig->find(query.str()).length() > 1)
    {
        /*nasdaq has its own csv form to use, hence a different class */
        EquityParserConnector epc(temp);
        
        epc.CSVToEquityList(XMLConfig->find(query.str()));
        
        std::unordered_map<std::string, equity *> members = temp->GetMemberList();
        for(std::unordered_map<std::string, equity *>::iterator i = members.begin(); i != members.end(); i++)
        {
            
            j++;
//            if (j > 20)
//                break;
            yahoo_http_connector yhc;
            yhc.DownloadHistoricals((*i).second->GetSymbol(), (*i).second->GetSecurityID() , (*i).second->GetDailyList());
            std::cout << "Downloaded historicals for " << (*i).second->GetSymbol() << std::endl;
            

            
        }
        ms_exchange.WriteEquitiesToDatabase();
        ms_exchange.WriteQuotesToDatabase();
    }
    
    
    et->m_eExchange = temp;
    pthread_mutex_unlock((pthread_mutex_t *) et->mutex);
    pthread_exit(NULL);
    return NULL;
}