示例#1
0
bool gen_hist_job()
{
	TwsXml file;
	if( ! file.openFile(filep) ) {
		return false;
	}

	time_t t_begin = min_begin_date( endDateTimep, durationStrp );
	DEBUG_PRINTF("skipping expiries before: '%s'",
		time_t_local(t_begin).c_str() );

	xmlNodePtr xn;
	int count_docs = 0;
	/* NOTE We are dumping single HistRequests but we should build and dump
	   a HistTodo object */
	while( (xn = file.nextXmlNode()) != NULL ) {
		count_docs++;
		PacketContractDetails *pcd = PacketContractDetails::fromXml( xn );

		int myProp_reqMaxContractsPerSpec = -1;
		for( size_t i = 0; i < pcd->constList().size(); i++ ) {

			const IB::ContractDetails &cd = pcd->constList()[i];
			IB::Contract c = cd.summary;
// 			DEBUG_PRINTF("contract, %s %s", c.symbol.c_str(), c.expiry.c_str());

			if( exp_mode != EXP_KEEP ) {
				c.includeExpired = get_inc_exp(c.secType.c_str());
			}
			if( myProp_reqMaxContractsPerSpec > 0 && (size_t)myProp_reqMaxContractsPerSpec <= i ) {
				break;
			}

			if( skip_expiry(c.expiry, t_begin) ) {
// 				DEBUG_PRINTF("skipping expiry: '%s'", c.expiry.c_str());
				continue;
			}

			for( char **wts = wts_list; *wts != NULL; wts++ ) {
				HistRequest hR;
				hR.initialize( c, endDateTimep, durationStrp, barSizeSettingp,
				               *wts, useRTHp, formatDate() );

				PacketHistData phd;
				phd.record( 0, hR );
				phd.dumpXml();
			}
		}
		delete pcd;
	}
	fprintf( stderr, "notice, %d xml docs parsed from file '%s'\n",
		count_docs, filep );

	return true;
}
示例#2
0
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;
}
示例#3
0
int WorkTodo::read_file( const char *fileName )
{
	int retVal = -1;
	
	TwsXml file;
	if( ! file.openFile(fileName) ) {
		return retVal;
	}
	retVal = 0;
	xmlNodePtr xn;
	while( (xn = file.nextXmlNode()) != NULL ) {
		assert( xn->type == XML_ELEMENT_NODE  );
		if( strcmp((char*)xn->name, "request") == 0 ) {
			retVal += read_req( xn );
		} else {
			fprintf(stderr, "Warning, unknown request tag '%s' ignored.\n",
				xn->name );
		}
	}
	
	return retVal;
}