bool gen_csv() { TwsXml file; if( ! file.openFile(filep) ) { return false; } if( max_expiryp != NULL ) { struct tm tm_tmp; memset(&tm_tmp, 0, sizeof(struct tm)); if( ib_strptime( &tm_tmp, max_expiryp ) == -1 ) { fprintf( stderr, "error, " "max-expiry must be IB's format YYYYMMDD.\n" ); return false; } DEBUG_PRINTF("skipping expiries newer than: '%s'", max_expiryp ); } xmlNodePtr xn; int count_docs = 0; while( (xn = file.nextXmlNode()) != NULL ) { count_docs++; PacketHistData *phd = PacketHistData::fromXml( xn ); if( max_expiryp != NULL ) { const std::string &expiry = phd->getRequest().ibContract.expiry; if( !expiry.empty() && strcmp(max_expiryp, expiry.c_str() ) < 0 ) { goto cont; } } if( !no_convp ) { phd->dump( true /* printFormatDates */); } else { phd->dumpXml(); } cont: delete phd; } fprintf( stderr, "notice, %d xml docs parsed from file '%s'\n", count_docs, filep ); return true; }
int WorkTodo::read_req( const xmlNodePtr xn ) { int ret = 1; char* tmp = (char*) xmlGetProp( xn, (const xmlChar*) "type" ); if( tmp == NULL ) { fprintf(stderr, "Warning, no request type specified.\n"); ret = 0; } else if( strcmp( tmp, "contract_details") == 0 ) { PacketContractDetails *pcd = PacketContractDetails::fromXml(xn); _contractDetailsTodo->add(pcd->getRequest()); delete pcd; } else if ( strcmp( tmp, "historical_data") == 0 ) { PacketHistData *phd = PacketHistData::fromXml(xn); _histTodo->add( phd->getRequest() ); delete phd; } else if ( strcmp( tmp, "place_order") == 0 ) { PacketPlaceOrder *ppo = PacketPlaceOrder::fromXml(xn); _place_order_todo->add( ppo->getRequest() ); delete ppo; } else if ( strcmp( tmp, "market_data") == 0 ) { PacketMktData *pmd = PacketMktData::fromXml(xn); _market_data_todo->add( pmd->getRequest() ); delete pmd; // HACK always get contractDetails too PacketContractDetails *pcd = PacketContractDetails::fromXml(xn); _contractDetailsTodo->add(pcd->getRequest()); delete pcd; } else if ( strcmp( tmp, "account") == 0 ) { addSimpleRequest(GenericRequest::ACC_STATUS_REQUEST); } else if ( strcmp( tmp, "executions") == 0 ) { addSimpleRequest(GenericRequest::EXECUTIONS_REQUEST); } else if ( strcmp( tmp, "open_orders") == 0 ) { addSimpleRequest(GenericRequest::ORDERS_REQUEST); } else { fprintf(stderr, "Warning, unknown request type '%s' ignored.\n", tmp ); ret = 0; } free(tmp); return ret; }