void from_xml( PlaceOrder* po, const xmlNodePtr node ) { char* tmp; for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE ) { if( strcmp((char*)p->name, "contract") == 0 ) { conv_xml2ib( &po->contract, p); } else if( strcmp((char*)p->name, "order") == 0 ) { conv_xml2ib( &po->order, p); } } } GET_ATTR_LONG( po, orderId ); GET_ATTR_LONGLONG( po, time_sent ); }
void from_xml( ExecutionsRequest *eR, const xmlNodePtr node ) { for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE && strcmp((char*)p->name, "executionFilter") == 0 ) { conv_xml2ib( &eR->executionFilter, p); } } }
void from_xml( ContractDetailsRequest *cdr, const xmlNodePtr node ) { for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE && strcmp((char*)p->name, "reqContract") == 0 ) { IB::Contract c; conv_xml2ib( &c, p); cdr->initialize(c); } } }
void conv_xml2ib( IB::ContractDetails* cd, const xmlNodePtr node ) { char* tmp; GET_ATTR_STRING( cd, marketName ); GET_ATTR_STRING( cd, tradingClass ); GET_ATTR_DOUBLE( cd, minTick ); GET_ATTR_STRING( cd, orderTypes ); GET_ATTR_STRING( cd, validExchanges ); GET_ATTR_LONG( cd, priceMagnifier ); GET_ATTR_INT( cd, underConId ); GET_ATTR_STRING( cd, longName ); GET_ATTR_STRING( cd, contractMonth ); GET_ATTR_STRING( cd, industry ); GET_ATTR_STRING( cd, category ); GET_ATTR_STRING( cd, subcategory ); GET_ATTR_STRING( cd, timeZoneId ); GET_ATTR_STRING( cd, tradingHours ); GET_ATTR_STRING( cd, liquidHours ); #if TWSAPI_IB_VERSION_NUMBER >= 967 GET_ATTR_STRING( cd, evRule ); GET_ATTR_DOUBLE( cd, evMultiplier ); #endif // BOND values GET_ATTR_STRING( cd, cusip ); GET_ATTR_STRING( cd, ratings ); GET_ATTR_STRING( cd, descAppend ); GET_ATTR_STRING( cd, bondType ); GET_ATTR_STRING( cd, couponType ); GET_ATTR_BOOL( cd, callable ); GET_ATTR_BOOL( cd, putable ); GET_ATTR_DOUBLE( cd, coupon ); GET_ATTR_BOOL( cd, convertible ); GET_ATTR_STRING( cd, maturity ); GET_ATTR_STRING( cd, issueDate ); GET_ATTR_STRING( cd, nextOptionDate ); GET_ATTR_STRING( cd, nextOptionType ); GET_ATTR_BOOL( cd, nextOptionPartial ); GET_ATTR_STRING( cd, notes ); for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type != XML_ELEMENT_NODE ) { continue; } if( strcmp((char*) p->name, "summary") == 0 ) { conv_xml2ib( &cd->summary, p ); } #if TWSAPI_IB_VERSION_NUMBER >= 967 else if(p->name && (strcmp((char*) p->name, "secIdList") == 0)) { GET_CHILD_TAGVALUELIST( cd->secIdList ); } #endif } }
void from_xml( MktDataRequest* mdr, const xmlNodePtr node ) { char* tmp; for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE && strcmp((char*)p->name, "reqContract") == 0 ) { conv_xml2ib( &mdr->ibContract, p); } } GET_ATTR_STRING( mdr, genericTicks ); GET_ATTR_BOOL( mdr, snapshot ); }
void from_xml( HistRequest *hR, const xmlNodePtr node ) { char* tmp; for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE && strcmp((char*)p->name, "reqContract") == 0 ) { conv_xml2ib( &hR->ibContract, p); } } GET_ATTR_STRING( hR, endDateTime ); GET_ATTR_STRING( hR, durationStr ); GET_ATTR_STRING( hR, barSizeSetting ); GET_ATTR_STRING( hR, whatToShow ); GET_ATTR_INT( hR, useRTH ); GET_ATTR_INT( hR, formatDate ); }
PacketContractDetails * PacketContractDetails::fromXml( xmlNodePtr root ) { PacketContractDetails *pcd = new PacketContractDetails(); for( xmlNodePtr p = root->children; p!= NULL; p=p->next) { if( p->type == XML_ELEMENT_NODE ) { if( strcmp((char*)p->name, "query") == 0 ) { pcd->request = new ContractDetailsRequest(); from_xml(pcd->request, p); } if( strcmp((char*)p->name, "response") == 0 ) { for( xmlNodePtr q = p->children; q!= NULL; q=q->next) { if( q->type == XML_ELEMENT_NODE && strcmp((char*)q->name, "ContractDetails") == 0 ) { IB::ContractDetails cd; conv_xml2ib(&cd, q); pcd->cdList->push_back(cd); } } } } } return pcd; }
void conv_xml2ib( IB::Order* o, const xmlNodePtr node ) { char* tmp; GET_ATTR_LONG( o, orderId ); GET_ATTR_LONG( o, clientId ); GET_ATTR_LONG( o, permId ); GET_ATTR_STRING( o, action ); GET_ATTR_LONG( o, totalQuantity ); GET_ATTR_STRING( o, orderType ); GET_ATTR_DOUBLE( o, lmtPrice ); GET_ATTR_DOUBLE( o, auxPrice ); GET_ATTR_STRING( o, tif ); GET_ATTR_STRING( o, ocaGroup ); GET_ATTR_INT( o, ocaType ); GET_ATTR_STRING( o, orderRef ); GET_ATTR_BOOL( o, transmit ); GET_ATTR_LONG( o, parentId ); GET_ATTR_BOOL( o, blockOrder ); GET_ATTR_BOOL( o, sweepToFill ); GET_ATTR_INT( o, displaySize ); GET_ATTR_INT( o, triggerMethod ); GET_ATTR_BOOL( o, outsideRth ); GET_ATTR_BOOL( o, hidden ); GET_ATTR_STRING( o, goodAfterTime ); GET_ATTR_STRING( o, goodTillDate ); GET_ATTR_STRING( o, rule80A ); GET_ATTR_BOOL( o, allOrNone ); GET_ATTR_INT( o, minQty ); GET_ATTR_DOUBLE( o, percentOffset ); GET_ATTR_BOOL( o, overridePercentageConstraints ); GET_ATTR_DOUBLE( o, trailStopPrice ); #if TWSAPI_IB_VERSION_NUMBER >= 967 GET_ATTR_DOUBLE( o, trailingPercent ); #endif GET_ATTR_STRING( o, faGroup ); GET_ATTR_STRING( o, faProfile ); GET_ATTR_STRING( o, faMethod ); GET_ATTR_STRING( o, faPercentage ); GET_ATTR_STRING( o, openClose ); tmp = (char*) xmlGetProp( node, (xmlChar*) "origin" ); if(tmp) { int orderOriginInt = atoi( tmp ); free(tmp); o->origin = (IB::Origin) orderOriginInt; } GET_ATTR_INT( o, shortSaleSlot ); GET_ATTR_STRING( o, designatedLocation ); GET_ATTR_INT( o, exemptCode ); GET_ATTR_DOUBLE( o, discretionaryAmt ); GET_ATTR_BOOL( o, eTradeOnly ); GET_ATTR_BOOL( o, firmQuoteOnly ); GET_ATTR_DOUBLE( o, nbboPriceCap ); GET_ATTR_BOOL( o, optOutSmartRouting ); GET_ATTR_INT( o, auctionStrategy ); GET_ATTR_DOUBLE( o, startingPrice ); GET_ATTR_DOUBLE( o, stockRefPrice ); GET_ATTR_DOUBLE( o, delta ); GET_ATTR_DOUBLE( o, stockRangeLower ); GET_ATTR_DOUBLE( o, stockRangeUpper ); GET_ATTR_DOUBLE( o, volatility ); GET_ATTR_INT( o, volatilityType ); GET_ATTR_STRING( o, deltaNeutralOrderType ); GET_ATTR_DOUBLE( o, deltaNeutralAuxPrice ); GET_ATTR_LONG( o, deltaNeutralConId ); GET_ATTR_STRING( o, deltaNeutralSettlingFirm ); GET_ATTR_STRING( o, deltaNeutralClearingAccount ); GET_ATTR_STRING( o, deltaNeutralClearingIntent ); #if TWSAPI_IB_VERSION_NUMBER >= 968 GET_ATTR_STRING( o, deltaNeutralOpenClose ); GET_ATTR_BOOL( o, deltaNeutralShortSale ); GET_ATTR_INT( o, deltaNeutralShortSaleSlot ); GET_ATTR_STRING( o, deltaNeutralDesignatedLocation ); #endif GET_ATTR_BOOL( o, continuousUpdate ); GET_ATTR_INT( o, referencePriceType ); GET_ATTR_DOUBLE( o, basisPoints ); GET_ATTR_INT( o, basisPointsType ); GET_ATTR_INT( o, scaleInitLevelSize ); GET_ATTR_INT( o, scaleSubsLevelSize ); GET_ATTR_DOUBLE( o, scalePriceIncrement ); #if TWSAPI_IB_VERSION_NUMBER >= 967 GET_ATTR_DOUBLE( o, scalePriceAdjustValue ); GET_ATTR_INT( o, scalePriceAdjustInterval ); GET_ATTR_DOUBLE( o, scaleProfitOffset ); GET_ATTR_BOOL( o, scaleAutoReset ); GET_ATTR_INT( o, scaleInitPosition ); GET_ATTR_INT( o, scaleInitFillQty ); GET_ATTR_BOOL( o, scaleRandomPercent ); #endif GET_ATTR_STRING( o, hedgeType ); GET_ATTR_STRING( o, hedgeParam ); GET_ATTR_STRING( o, account ); GET_ATTR_STRING( o, settlingFirm ); GET_ATTR_STRING( o, clearingAccount ); GET_ATTR_STRING( o, clearingIntent ); GET_ATTR_STRING( o, algoStrategy ); GET_ATTR_BOOL( o, whatIf ); GET_ATTR_BOOL( o, notHeld ); for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type != XML_ELEMENT_NODE ) { continue; } if( strcmp((char*) p->name, "algoParams") == 0 ) { GET_CHILD_TAGVALUELIST( o->algoParams ); } else if( strcmp((char*) p->name, "smartComboRoutingParams") == 0 ) { GET_CHILD_TAGVALUELIST( o->smartComboRoutingParams ); } #if TWSAPI_IB_VERSION_NUMBER >= 967 else if( strcmp((char*) p->name, "orderComboLegs") == 0 ) { o->orderComboLegs = IB::Order::OrderComboLegListSPtr( new IB::Order::OrderComboLegList() ); for( xmlNodePtr q = p->children; q!= NULL; q=q->next) { IB::OrderComboLegSPtr oCL( new IB::OrderComboLeg()); if( q->type != XML_ELEMENT_NODE || (strcmp((char*) q->name, "orderComboLeg") != 0)) { continue; } conv_xml2ib( oCL.get(), q ); o->orderComboLegs->push_back(oCL); } } #endif } }
void conv_xml2ib( IB::Contract* c, const xmlNodePtr node ) { char* tmp; GET_ATTR_LONG( c, conId ); GET_ATTR_STRING( c, symbol ); GET_ATTR_STRING( c, secType ); GET_ATTR_STRING( c, expiry ); GET_ATTR_DOUBLE( c, strike ); GET_ATTR_STRING( c, right ); GET_ATTR_STRING( c, multiplier ); GET_ATTR_STRING( c, exchange ); GET_ATTR_STRING( c, primaryExchange ); GET_ATTR_STRING( c, currency ); GET_ATTR_STRING( c, localSymbol ); GET_ATTR_BOOL( c, includeExpired ); GET_ATTR_STRING( c, secIdType ); GET_ATTR_STRING( c, secId ); GET_ATTR_STRING( c, comboLegsDescrip ); for( xmlNodePtr p = node->children; p!= NULL; p=p->next) { if( p->type != XML_ELEMENT_NODE ) { continue; } if( strcmp((char*) p->name, "comboLegs") == 0 ) { #if TWSAPI_IB_VERSION_NUMBER <= 966 if( c->comboLegs != NULL ) { /* see comment for underComp below */ delete c->comboLegs; } c->comboLegs = new IB::Contract::ComboLegList(); #else c->comboLegs = IB::Contract::ComboLegListSPtr( new IB::Contract::ComboLegList() ); #endif for( xmlNodePtr q = p->children; q!= NULL; q=q->next) { if( q->type != XML_ELEMENT_NODE || (strcmp((char*) q->name, "comboLeg") != 0)) { continue; } IB::ComboLeg *cl = new IB::ComboLeg(); conv_xml2ib( cl, q ); #if TWSAPI_IB_VERSION_NUMBER <= 966 c->comboLegs->push_back(cl); #else c->comboLegs->push_back(IB::ComboLegSPtr(cl)); #endif } } else if( strcmp((char*) p->name, "underComp") == 0 ) { if( c->underComp != NULL ) { /* This can only happen if the caller gave us an uninitialized contract (programming error) or if the xml wrongly contains more than one underComp tag. For the second case we have to avoid a memleak here */ delete c->underComp; } c->underComp = new IB::UnderComp(); conv_xml2ib( c->underComp, p ); } } }