Exemplo n.º 1
0
 def position(cls, account, contract, position, avgCost):
     """ generated source for method position """
     msg = " ---- Position begin ----\n" \
           + "account = " + str(account) + "\n" \
           + cls.contractMsg(contract) \
           + "position = " + Util.IntMaxString(position) + "\n" \
           + "avgCost = " + Util.DoubleMaxString(avgCost) + "\n" + \
           " ---- Position end ----\n"
     return msg
Exemplo n.º 2
0
 def __eq__(self, p_other):
     """ generated source for method equals """
     if self is p_other:
         return True
     if p_other is None:
         return False
     l_theOther = p_other
     if Util.StringCompare(self.m_tag, l_theOther.m_tag) != 0 or Util.StringCompare(self.m_value, l_theOther.m_value) != 0:
         return False
     return True
Exemplo n.º 3
0
 def __eq__(self, p_other):
     if self is p_other:
         return True
     if p_other is None:
         return False
     l_theOther = p_other
     if (Util.StringCompare(self.m_tag, l_theOther.m_tag) != 0)\
             or (Util.StringCompare(self.m_value, l_theOther.m_value) != 0):
         return False
     return True
Exemplo n.º 4
0
 def __eq__(self, p_other):
     if self is p_other:
         return True
     if p_other is None or not isinstance(p_other, (Contract)):
         return False
     l_theOther = p_other
     if (self.m_conId != l_theOther.m_conId):
         return False
     if (Util.StringCompare(self.m_secType, l_theOther.m_secType) != 0):
         return False
     if (Util.StringCompare(self.m_symbol, l_theOther.m_symbol) != 0) or (Util.StringCompare(self.m_exchange, l_theOther.m_exchange) != 0) or (Util.StringCompare(self.m_primaryExch, l_theOther.m_primaryExch) != 0) or (Util.StringCompare(self.m_currency, l_theOther.m_currency) != 0):
         return False
     if not Util.NormalizeString(self.m_secType) == "BOND":
         if (self.m_strike != l_theOther.m_strike):
             return False
         if (Util.StringCompare(self.m_expiry, l_theOther.m_expiry) != 0) or (Util.StringCompare(self.m_right, l_theOther.m_right) != 0) or (Util.StringCompare(self.m_multiplier, l_theOther.m_multiplier) != 0) or (Util.StringCompare(self.m_localSymbol, l_theOther.m_localSymbol) != 0):
             return False
     if (Util.StringCompare(self.m_secIdType, l_theOther.m_secIdType) != 0):
         return False
     if (Util.StringCompare(self.m_secId, l_theOther.m_secId) != 0):
         return False
     if not Util.VectorEqualsUnordered(self.m_comboLegs, l_theOther.m_comboLegs):
         return False
     if (self.m_underComp != l_theOther.m_underComp):
         if self.m_underComp is None or l_theOther.m_underComp is None:
             return False
         if not self.m_underComp == l_theOther.m_underComp:
             return False
     return True
Exemplo n.º 5
0
 def commissionReport(cls, commissionReport):
     """ generated source for method commissionReport """
     msg = "commission report:" \
           + " execId=" + str(commissionReport.m_execId) \
           + " commission=" + Util.DoubleMaxString(commissionReport.m_commission) \
           + " currency=" + str(commissionReport.m_currency) \
           + " realizedPNL=" + Util.DoubleMaxString(commissionReport.m_realizedPNL) \
           + " yield=" + Util.DoubleMaxString(commissionReport.m_yield) \
           + " yieldRedemptionDate=" \
           + Util.IntMaxString(commissionReport.m_yieldRedemptionDate)
     return msg
Exemplo n.º 6
0
 def __eq__(self, p_other):
     if self is p_other:
         return True
     else:
         if p_other is None:
             return False
     l_theOther = p_other
     if (self.m_conId != l_theOther.m_conId) or (self.m_ratio != l_theOther.m_ratio) or (self.m_openClose != l_theOther.m_openClose) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot):
         return False
     if (Util.StringCompareIgnCase(self.m_action, l_theOther.m_action) != 0) or (Util.StringCompareIgnCase(self.m_exchange, l_theOther.m_exchange) != 0) or (Util.StringCompareIgnCase(self.m_designatedLocation, l_theOther.m_designatedLocation) != 0):
         return False
     return True
Exemplo n.º 7
0
 def openOrder(cls, orderId, contract, order, orderState):
     """ generated source for method openOrder """
     msg = "open order: orderId=" + orderId + " action=" + order.m_action + " quantity=" + order.m_totalQuantity + " symbol=" + contract.m_symbol + " exchange=" + contract.m_exchange + " secType=" + contract.m_secType + " type=" + order.m_orderType + " lmtPrice=" + Util.DoubleMaxString(order.m_lmtPrice) + " auxPrice=" + Util.DoubleMaxString(order.m_auxPrice) + " TIF=" + order.m_tif + " localSymbol=" + contract.m_localSymbol + " client Id=" + order.m_clientId + " parent Id=" + order.m_parentId + " permId=" + order.m_permId + " outsideRth=" + order.m_outsideRth + " hidden=" + order.m_hidden + " discretionaryAmt=" + order.m_discretionaryAmt + " displaySize=" + order.m_displaySize + " triggerMethod=" + order.m_triggerMethod + " goodAfterTime=" + order.m_goodAfterTime + " goodTillDate=" + order.m_goodTillDate + " faGroup=" + order.m_faGroup + " faMethod=" + order.m_faMethod + " faPercentage=" + order.m_faPercentage + " faProfile=" + order.m_faProfile + " shortSaleSlot=" + order.m_shortSaleSlot + " designatedLocation=" + order.m_designatedLocation + " exemptCode=" + order.m_exemptCode + " ocaGroup=" + order.m_ocaGroup + " ocaType=" + order.m_ocaType + " rule80A=" + order.m_rule80A + " allOrNone=" + order.m_allOrNone + " minQty=" + Util.IntMaxString(order.m_minQty) + " percentOffset=" + Util.DoubleMaxString(order.m_percentOffset) + " eTradeOnly=" + order.m_eTradeOnly + " firmQuoteOnly=" + order.m_firmQuoteOnly + " nbboPriceCap=" + Util.DoubleMaxString(order.m_nbboPriceCap) + " optOutSmartRouting=" + order.m_optOutSmartRouting + " auctionStrategy=" + order.m_auctionStrategy + " startingPrice=" + Util.DoubleMaxString(order.m_startingPrice) + " stockRefPrice=" + Util.DoubleMaxString(order.m_stockRefPrice) + " delta=" + Util.DoubleMaxString(order.m_delta) + " stockRangeLower=" + Util.DoubleMaxString(order.m_stockRangeLower) + " stockRangeUpper=" + Util.DoubleMaxString(order.m_stockRangeUpper) + " volatility=" + Util.DoubleMaxString(order.m_volatility) + " volatilityType=" + order.m_volatilityType + " deltaNeutralOrderType=" + order.m_deltaNeutralOrderType + " deltaNeutralAuxPrice=" + Util.DoubleMaxString(order.m_deltaNeutralAuxPrice) + " deltaNeutralConId=" + order.m_deltaNeutralConId + " deltaNeutralSettlingFirm=" + order.m_deltaNeutralSettlingFirm + " deltaNeutralClearingAccount=" + order.m_deltaNeutralClearingAccount + " deltaNeutralClearingIntent=" + order.m_deltaNeutralClearingIntent + " continuousUpdate=" + order.m_continuousUpdate + " referencePriceType=" + order.m_referencePriceType + " trailStopPrice=" + Util.DoubleMaxString(order.m_trailStopPrice) + " trailingPercent=" + Util.DoubleMaxString(order.m_trailingPercent) + " scaleInitLevelSize=" + Util.IntMaxString(order.m_scaleInitLevelSize) + " scaleSubsLevelSize=" + Util.IntMaxString(order.m_scaleSubsLevelSize) + " scalePriceIncrement=" + Util.DoubleMaxString(order.m_scalePriceIncrement) + " scalePriceAdjustValue=" + Util.DoubleMaxString(order.m_scalePriceAdjustValue) + " scalePriceAdjustInterval=" + Util.IntMaxString(order.m_scalePriceAdjustInterval) + " scaleProfitOffset=" + Util.DoubleMaxString(order.m_scaleProfitOffset) + " scaleAutoReset=" + order.m_scaleAutoReset + " scaleInitPosition=" + Util.IntMaxString(order.m_scaleInitPosition) + " scaleInitFillQty=" + Util.IntMaxString(order.m_scaleInitFillQty) + " scaleRandomPercent=" + order.m_scaleRandomPercent + " hedgeType=" + order.m_hedgeType + " hedgeParam=" + order.m_hedgeParam + " account=" + order.m_account + " settlingFirm=" + order.m_settlingFirm + " clearingAccount=" + order.m_clearingAccount + " clearingIntent=" + order.m_clearingIntent + " notHeld=" + order.m_notHeld + " whatIf=" + order.m_whatIf
     if "BAG" == contract.m_secType:
         if contract.m_comboLegsDescrip != None:
             msg += " comboLegsDescrip=" + contract.m_comboLegsDescrip
         msg += " comboLegs={"
         if contract.m_comboLegs != None:
             while i < len(contract.m_comboLegs):
                 msg += " leg " + (i + 1) + ": "
                 msg += "conId=" + comboLeg.m_conId
                 msg += " ratio=" + comboLeg.m_ratio
                 msg += " action=" + comboLeg.m_action
                 msg += " exchange=" + comboLeg.m_exchange
                 msg += " openClose=" + comboLeg.m_openClose
                 msg += " shortSaleSlot=" + comboLeg.m_shortSaleSlot
                 msg += " designatedLocation=" + comboLeg.m_designatedLocation
                 msg += " exemptCode=" + comboLeg.m_exemptCode
                 if order.m_orderComboLegs != None and len(contract.m_comboLegs) == len(order.m_orderComboLegs):
                     msg += " price=" + Util.DoubleMaxString(orderComboLeg.m_price)
                 msg += ";"
                 i += 1
         msg += "}"
         if order.m_basisPoints != Double.MAX_VALUE:
             msg += " basisPoints=" + Util.DoubleMaxString(order.m_basisPoints)
             msg += " basisPointsType=" + Util.IntMaxString(order.m_basisPointsType)
     if contract.m_underComp != None:
         msg += " underComp.conId =" + underComp.m_conId + " underComp.delta =" + underComp.m_delta + " underComp.price =" + underComp.m_price
     if not Util.StringIsEmpty(order.m_algoStrategy):
         msg += " algoStrategy=" + order.m_algoStrategy
         msg += " algoParams={"
         if order.m_algoParams != None:
             while i < len(algoParams):
                 if i > 0:
                     msg += ","
                 msg += param.m_tag + "=" + param.m_value
                 i += 1
         msg += "}"
     if "BAG" == contract.m_secType:
         msg += " smartComboRoutingParams={"
         if order.m_smartComboRoutingParams != None:
             while i < len(smartComboRoutingParams):
                 if i > 0:
                     msg += ","
                 msg += param.m_tag + "=" + param.m_value
                 i += 1
         msg += "}"
     orderStateMsg = " status=" + orderState.m_status + " initMargin=" + orderState.m_initMargin + " maintMargin=" + orderState.m_maintMargin + " equityWithLoan=" + orderState.m_equityWithLoan + " commission=" + Util.DoubleMaxString(orderState.m_commission) + " minCommission=" + Util.DoubleMaxString(orderState.m_minCommission) + " maxCommission=" + Util.DoubleMaxString(orderState.m_maxCommission) + " commissionCurrency=" + orderState.m_commissionCurrency + " warningText=" + orderState.m_warningText
     return msg + orderStateMsg
Exemplo n.º 8
0
 def __eq__(self, p_other):
     if self is p_other:
         return True
     if p_other is None:
         return False
     l_theOther = p_other
     if (self.m_permId == l_theOther.m_permId):
         return True
     if (self.m_orderId != l_theOther.m_orderId) or (self.m_clientId != l_theOther.m_clientId) or (self.m_totalQuantity != l_theOther.m_totalQuantity) or (self.m_lmtPrice != l_theOther.m_lmtPrice) or (self.m_auxPrice != l_theOther.m_auxPrice) or (self.m_ocaType != l_theOther.m_ocaType) or (self.m_transmit != l_theOther.m_transmit) or (self.m_parentId != l_theOther.m_parentId) or (self.m_blockOrder != l_theOther.m_blockOrder) or (self.m_sweepToFill != l_theOther.m_sweepToFill) or (self.m_displaySize != l_theOther.m_displaySize) or (self.m_triggerMethod != l_theOther.m_triggerMethod) or (self.m_outsideRth != l_theOther.m_outsideRth) or (self.m_hidden != l_theOther.m_hidden) or (self.m_overridePercentageConstraints != l_theOther.m_overridePercentageConstraints) or (self.m_allOrNone != l_theOther.m_allOrNone) or (self.m_minQty != l_theOther.m_minQty) or (self.m_percentOffset != l_theOther.m_percentOffset) or (self.m_trailStopPrice != l_theOther.m_trailStopPrice) or (self.m_origin != l_theOther.m_origin) or (self.m_shortSaleSlot != l_theOther.m_shortSaleSlot) or (self.m_discretionaryAmt != l_theOther.m_discretionaryAmt) or (self.m_eTradeOnly != l_theOther.m_eTradeOnly) or (self.m_firmQuoteOnly != l_theOther.m_firmQuoteOnly) or (self.m_nbboPriceCap != l_theOther.m_nbboPriceCap) or (self.m_auctionStrategy != l_theOther.m_auctionStrategy) or (self.m_startingPrice != l_theOther.m_startingPrice) or (self.m_stockRefPrice != l_theOther.m_stockRefPrice) or (self.m_delta != l_theOther.m_delta) or (self.m_stockRangeLower != l_theOther.m_stockRangeLower) or (self.m_stockRangeUpper != l_theOther.m_stockRangeUpper) or (self.m_volatility != l_theOther.m_volatility) or (self.m_volatilityType != l_theOther.m_volatilityType) or (self.m_continuousUpdate != l_theOther.m_continuousUpdate) or (self.m_referencePriceType != l_theOther.m_referencePriceType) or (self.m_deltaNeutralAuxPrice != l_theOther.m_deltaNeutralAuxPrice) or (self.m_basisPoints != l_theOther.m_basisPoints) or (self.m_basisPointsType != l_theOther.m_basisPointsType) or (self.m_scaleInitLevelSize != l_theOther.m_scaleInitLevelSize) or (self.m_scaleSubsLevelSize != l_theOther.m_scaleSubsLevelSize) or (self.m_scalePriceIncrement != l_theOther.m_scalePriceIncrement) or (self.m_whatIf != l_theOther.m_whatIf) or (self.m_notHeld != l_theOther.m_notHeld):
         return False
     if (Util.StringCompare(self.m_action, l_theOther.m_action) != 0) or (Util.StringCompare(self.m_orderType, l_theOther.m_orderType) != 0) or (Util.StringCompare(self.m_tif, l_theOther.m_tif) != 0) or (Util.StringCompare(self.m_ocaGroup, l_theOther.m_ocaGroup) != 0) or (Util.StringCompare(self.m_orderRef, l_theOther.m_orderRef) != 0) or (Util.StringCompare(self.m_goodAfterTime, l_theOther.m_goodAfterTime) != 0) or (Util.StringCompare(self.m_goodTillDate, l_theOther.m_goodTillDate) != 0) or (Util.StringCompare(self.m_rule80A, l_theOther.m_rule80A) != 0) or (Util.StringCompare(self.m_faGroup, l_theOther.m_faGroup) != 0) or (Util.StringCompare(self.m_faProfile, l_theOther.m_faProfile) != 0) or (Util.StringCompare(self.m_faMethod, l_theOther.m_faMethod) != 0) or (Util.StringCompare(self.m_faPercentage, l_theOther.m_faPercentage) != 0) or (Util.StringCompare(self.m_openClose, l_theOther.m_openClose) != 0) or (Util.StringCompare(self.m_designatedLocation, l_theOther.m_designatedLocation) != 0) or (Util.StringCompare(self.m_deltaNeutralOrderType, l_theOther.m_deltaNeutralOrderType) != 0) or (Util.StringCompare(self.m_account, l_theOther.m_account) != 0) or (Util.StringCompare(self.m_settlingFirm, l_theOther.m_settlingFirm) != 0) or (Util.StringCompare(self.m_clearingAccount, l_theOther.m_clearingAccount) != 0) or (Util.StringCompare(self.m_clearingIntent, l_theOther.m_clearingIntent) != 0) or (Util.StringCompare(self.m_algoStrategy, l_theOther.m_algoStrategy) != 0):
         return False
     if not Util.VectorEqualsUnordered(self.m_algoParams, l_theOther.m_algoParams):
         return False
     return True
Exemplo n.º 9
0
 def __eq__(self, p_other):
     """ generated source for method equals """
     if self == p_other:
         return True
     elif p_other == None:
         return False
     l_theOther = p_other
     if self.m_conId != l_theOther.m_conId or self.m_ratio != l_theOther.m_ratio or self.m_openClose != l_theOther.m_openClose or self.m_shortSaleSlot != l_theOther.m_shortSaleSlot or self.m_exemptCode != l_theOther.m_exemptCode:
         return False
     if Util.StringCompareIgnCase(
             self.m_action,
             l_theOther.m_action) != 0 or Util.StringCompareIgnCase(
                 self.m_exchange,
                 l_theOther.m_exchange) != 0 or Util.StringCompareIgnCase(
                     self.m_designatedLocation,
                     l_theOther.m_designatedLocation) != 0:
         return False
     return True
Exemplo n.º 10
0
 def __eq__(self, other):
     if (self == other):
         return True
     if other is None:
         return False
     state = other
     if (self.m_commission != state.m_commission) or (
             self.m_minCommission != state.m_minCommission) or (
                 self.m_maxCommission != state.m_maxCommission):
         return False
     if (Util.StringCompare(self.m_status, state.m_status) != 0) or (
             Util.StringCompare(self.m_initMargin, state.m_initMargin) != 0
     ) or (Util.StringCompare(self.m_maintMargin, state.m_maintMargin) !=
           0) or (Util.StringCompare(
               self.m_equityWithLoan, state.m_equityWithLoan) != 0) or (
                   Util.StringCompare(self.m_commissionCurrency,
                                      state.m_commissionCurrency) != 0):
         return False
     return True
Exemplo n.º 11
0
 def __eq__(self, p_other):
     """ generated source for method equals """
     if self is p_other:
         return True
     elif p_other is None:
         return False
     if (self.m_conId !=
             p_other.m_conId) or (self.m_ratio != p_other.m_ratio) or (
                 self.m_openClose != p_other.m_openClose) or (
                     self.m_shortSaleSlot != p_other.m_shortSaleSlot) or (
                         self.m_exemptCode != p_other.m_exemptCode):
         return False
     if (Util.StringCompareIgnCase(self.m_action, p_other.m_action) !=
             0) or (Util.StringCompareIgnCase(self.m_exchange,
                                              p_other.m_exchange) !=
                    0) or (Util.StringCompareIgnCase(
                        self.m_designatedLocation,
                        p_other.m_designatedLocation) != 0):
         return False
     return True
Exemplo n.º 12
0
 def __eq__(self, other):
     """ generated source for method equals """
     if self == other:
         return True
     if other is None:
         return False
     state = other
     if self.m_commission != state.m_commission or self.m_minCommission != state.m_minCommission or self.m_maxCommission != state.m_maxCommission:
         return False
     if Util.StringCompare(
             self.m_status, state.m_status) != 0 or Util.StringCompare(
                 self.m_initMargin,
                 state.m_initMargin) != 0 or Util.StringCompare(
                     self.m_maintMargin,
                     state.m_maintMargin) != 0 or Util.StringCompare(
                         self.m_equityWithLoan,
                         state.m_equityWithLoan) != 0 or Util.StringCompare(
                             self.m_commissionCurrency,
                             state.m_commissionCurrency) != 0:
         return False
     return True
Exemplo n.º 13
0
	def __eq__(self, p_other):
		""" generated source for method equals """
		if self is p_other:
			return True
		if p_other is None:
			return False
		l_theOther = p_other
		if self.m_permId == l_theOther.m_permId:
			return True
		if self.m_orderId != l_theOther.m_orderId or self.m_clientId != l_theOther.m_clientId or self.m_totalQuantity != l_theOther.m_totalQuantity or self.m_lmtPrice != l_theOther.m_lmtPrice or self.m_auxPrice != l_theOther.m_auxPrice or self.m_ocaType != l_theOther.m_ocaType or self.m_transmit != l_theOther.m_transmit or self.m_parentId != l_theOther.m_parentId or self.m_blockOrder != l_theOther.m_blockOrder or self.m_sweepToFill != l_theOther.m_sweepToFill or self.m_displaySize != l_theOther.m_displaySize or self.m_triggerMethod != l_theOther.m_triggerMethod or self.m_outsideRth != l_theOther.m_outsideRth or self.m_hidden != l_theOther.m_hidden or self.m_overridePercentageConstraints != l_theOther.m_overridePercentageConstraints or self.m_allOrNone != l_theOther.m_allOrNone or self.m_minQty != l_theOther.m_minQty or self.m_percentOffset != l_theOther.m_percentOffset or self.m_trailStopPrice != l_theOther.m_trailStopPrice or self.m_trailingPercent != l_theOther.m_trailingPercent or self.m_origin != l_theOther.m_origin or self.m_shortSaleSlot != l_theOther.m_shortSaleSlot or self.m_discretionaryAmt != l_theOther.m_discretionaryAmt or self.m_eTradeOnly != l_theOther.m_eTradeOnly or self.m_firmQuoteOnly != l_theOther.m_firmQuoteOnly or self.m_nbboPriceCap != l_theOther.m_nbboPriceCap or self.m_optOutSmartRouting != l_theOther.m_optOutSmartRouting or self.m_auctionStrategy != l_theOther.m_auctionStrategy or self.m_startingPrice != l_theOther.m_startingPrice or self.m_stockRefPrice != l_theOther.m_stockRefPrice or self.m_delta != l_theOther.m_delta or self.m_stockRangeLower != l_theOther.m_stockRangeLower or self.m_stockRangeUpper != l_theOther.m_stockRangeUpper or self.m_volatility != l_theOther.m_volatility or self.m_volatilityType != l_theOther.m_volatilityType or self.m_continuousUpdate != l_theOther.m_continuousUpdate or self.m_referencePriceType != l_theOther.m_referencePriceType or self.m_deltaNeutralAuxPrice != l_theOther.m_deltaNeutralAuxPrice or self.m_deltaNeutralConId != l_theOther.m_deltaNeutralConId or self.m_deltaNeutralShortSale != l_theOther.m_deltaNeutralShortSale or self.m_deltaNeutralShortSaleSlot != l_theOther.m_deltaNeutralShortSaleSlot or self.m_basisPoints != l_theOther.m_basisPoints or self.m_basisPointsType != l_theOther.m_basisPointsType or self.m_scaleInitLevelSize != l_theOther.m_scaleInitLevelSize or self.m_scaleSubsLevelSize != l_theOther.m_scaleSubsLevelSize or self.m_scalePriceIncrement != l_theOther.m_scalePriceIncrement or self.m_scalePriceAdjustValue != l_theOther.m_scalePriceAdjustValue or self.m_scalePriceAdjustInterval != l_theOther.m_scalePriceAdjustInterval or self.m_scaleProfitOffset != l_theOther.m_scaleProfitOffset or self.m_scaleAutoReset != l_theOther.m_scaleAutoReset or self.m_scaleInitPosition != l_theOther.m_scaleInitPosition or self.m_scaleInitFillQty != l_theOther.m_scaleInitFillQty or self.m_scaleRandomPercent != l_theOther.m_scaleRandomPercent or self.m_whatIf != l_theOther.m_whatIf or self.m_notHeld != l_theOther.m_notHeld or self.m_exemptCode != l_theOther.m_exemptCode:
			return False
		if Util.StringCompare(self.m_action, l_theOther.m_action) != 0 or Util.StringCompare(self.m_orderType, l_theOther.m_orderType) != 0 or Util.StringCompare(self.m_tif, l_theOther.m_tif) != 0 or Util.StringCompare(self.m_activeStartTime, l_theOther.m_activeStartTime) != 0 or Util.StringCompare(self.m_activeStopTime, l_theOther.m_activeStopTime) != 0 or Util.StringCompare(self.m_ocaGroup, l_theOther.m_ocaGroup) != 0 or Util.StringCompare(self.m_orderRef, l_theOther.m_orderRef) != 0 or Util.StringCompare(self.m_goodAfterTime, l_theOther.m_goodAfterTime) != 0 or Util.StringCompare(self.m_goodTillDate, l_theOther.m_goodTillDate) != 0 or Util.StringCompare(self.m_rule80A, l_theOther.m_rule80A) != 0 or Util.StringCompare(self.m_faGroup, l_theOther.m_faGroup) != 0 or Util.StringCompare(self.m_faProfile, l_theOther.m_faProfile) != 0 or Util.StringCompare(self.m_faMethod, l_theOther.m_faMethod) != 0 or Util.StringCompare(self.m_faPercentage, l_theOther.m_faPercentage) != 0 or Util.StringCompare(self.m_openClose, l_theOther.m_openClose) != 0 or Util.StringCompare(self.m_designatedLocation, l_theOther.m_designatedLocation) != 0 or Util.StringCompare(self.m_deltaNeutralOrderType, l_theOther.m_deltaNeutralOrderType) != 0 or Util.StringCompare(self.m_deltaNeutralSettlingFirm, l_theOther.m_deltaNeutralSettlingFirm) != 0 or Util.StringCompare(self.m_deltaNeutralClearingAccount, l_theOther.m_deltaNeutralClearingAccount) != 0 or Util.StringCompare(self.m_deltaNeutralClearingIntent, l_theOther.m_deltaNeutralClearingIntent) != 0 or Util.StringCompare(self.m_deltaNeutralOpenClose, l_theOther.m_deltaNeutralOpenClose) != 0 or Util.StringCompare(self.m_deltaNeutralDesignatedLocation, l_theOther.m_deltaNeutralDesignatedLocation) != 0 or Util.StringCompare(self.m_hedgeType, l_theOther.m_hedgeType) != 0 or Util.StringCompare(self.m_hedgeParam, l_theOther.m_hedgeParam) != 0 or Util.StringCompare(self.m_account, l_theOther.m_account) != 0 or Util.StringCompare(self.m_settlingFirm, l_theOther.m_settlingFirm) != 0 or Util.StringCompare(self.m_clearingAccount, l_theOther.m_clearingAccount) != 0 or Util.StringCompare(self.m_clearingIntent, l_theOther.m_clearingIntent) != 0 or Util.StringCompare(self.m_algoStrategy, l_theOther.m_algoStrategy) != 0 or Util.StringCompare(self.m_scaleTable, l_theOther.m_scaleTable) != 0:
			return False
		if not Util.VectorEqualsUnordered(self.m_algoParams, l_theOther.m_algoParams):
			return False
		if not Util.VectorEqualsUnordered(self.m_smartComboRoutingParams, l_theOther.m_smartComboRoutingParams):
			return False
		#  compare order combo legs
		if not Util.VectorEqualsUnordered(self.m_orderComboLegs, l_theOther.m_orderComboLegs):
			return False
		return True
Exemplo n.º 14
0
 def openOrder(cls, orderId, contract, order, orderState):
     msg = "open order: orderId=" + orderId + " action=" + order.m_action + " quantity=" + order.m_totalQuantity + " symbol=" + contract.m_symbol + " exchange=" + contract.m_exchange + " secType=" + contract.m_secType + " type=" + order.m_orderType + " lmtPrice=" + order.m_lmtPrice + " auxPrice=" + order.m_auxPrice + " TIF=" + order.m_tif + " localSymbol=" + contract.m_localSymbol + " client Id=" + order.m_clientId + " parent Id=" + order.m_parentId + " permId=" + order.m_permId + " outsideRth=" + order.m_outsideRth + " hidden=" + order.m_hidden + " discretionaryAmt=" + order.m_discretionaryAmt + " triggerMethod=" + order.m_triggerMethod + " goodAfterTime=" + order.m_goodAfterTime + " goodTillDate=" + order.m_goodTillDate + " faGroup=" + order.m_faGroup + " faMethod=" + order.m_faMethod + " faPercentage=" + order.m_faPercentage + " faProfile=" + order.m_faProfile + " shortSaleSlot=" + order.m_shortSaleSlot + " designatedLocation=" + order.m_designatedLocation + " ocaGroup=" + order.m_ocaGroup + " ocaType=" + order.m_ocaType + " rule80A=" + order.m_rule80A + " allOrNone=" + order.m_allOrNone + " minQty=" + order.m_minQty + " percentOffset=" + order.m_percentOffset + " eTradeOnly=" + order.m_eTradeOnly + " firmQuoteOnly=" + order.m_firmQuoteOnly + " nbboPriceCap=" + order.m_nbboPriceCap + " auctionStrategy=" + order.m_auctionStrategy + " startingPrice=" + order.m_startingPrice + " stockRefPrice=" + order.m_stockRefPrice + " delta=" + order.m_delta + " stockRangeLower=" + order.m_stockRangeLower + " stockRangeUpper=" + order.m_stockRangeUpper + " volatility=" + order.m_volatility + " volatilityType=" + order.m_volatilityType + " deltaNeutralOrderType=" + order.m_deltaNeutralOrderType + " deltaNeutralAuxPrice=" + order.m_deltaNeutralAuxPrice + " continuousUpdate=" + order.m_continuousUpdate + " referencePriceType=" + order.m_referencePriceType + " trailStopPrice=" + order.m_trailStopPrice + " scaleInitLevelSize=" + Util.IntMaxString(
         order.m_scaleInitLevelSize
     ) + " scaleSubsLevelSize=" + Util.IntMaxString(
         order.m_scaleSubsLevelSize
     ) + " scalePriceIncrement=" + Util.DoubleMaxString(
         order.m_scalePriceIncrement
     ) + " account=" + order.m_account + " settlingFirm=" + order.m_settlingFirm + " clearingAccount=" + order.m_clearingAccount + " clearingIntent=" + order.m_clearingIntent + " notHeld=" + order.m_notHeld + " whatIf=" + order.m_whatIf
     if "BAG" == contract.m_secType:
         if contract.m_comboLegsDescrip is not None:
             msg += " comboLegsDescrip=" + contract.m_comboLegsDescrip
         if (order.m_basisPoints != Double.MAX_VALUE):
             msg += " basisPoints=" + order.m_basisPoints
             msg += " basisPointsType=" + order.m_basisPointsType
     if contract.m_underComp is not None:
         underComp = contract.m_underComp
         msg += " underComp.conId =" + underComp.m_conId + " underComp.delta =" + underComp.m_delta + " underComp.price =" + underComp.m_price
     if not Util.StringIsEmpty(order.m_algoStrategy):
         msg += " algoStrategy=" + order.m_algoStrategy
         msg += " algoParams={"
         if order.m_algoParams is not None:
             algoParams = order.m_algoParams
             ## for-while
             i = 0
             while i < len(algoParams):
                 param = algoParams.elementAt(i)
                 if i > 0:
                     msg += ","
                 msg += param.m_tag + "=" + param.m_value
                 i += 1
         msg += "}"
     orderStateMsg = " status=" + orderState.m_status + " initMargin=" + orderState.m_initMargin + " maintMargin=" + orderState.m_maintMargin + " equityWithLoan=" + orderState.m_equityWithLoan + " commission=" + Util.DoubleMaxString(
         orderState.m_commission
     ) + " minCommission=" + Util.DoubleMaxString(
         orderState.m_minCommission
     ) + " maxCommission=" + Util.DoubleMaxString(
         orderState.m_maxCommission
     ) + " commissionCurrency=" + orderState.m_commissionCurrency + " warningText=" + orderState.m_warningText
     return msg + orderStateMsg
Exemplo n.º 15
0
 def openOrder(cls, orderId, contract, order, orderState):
     """ generated source for method openOrder """
     msg = "open order: orderId=" + str(orderId) \
           + " action=" + str(order.m_action) \
           + " quantity=" + str(order.m_totalQuantity) \
           + " conid=" + str(contract.m_conId) \
           + " symbol=" + str(contract.m_symbol) \
           + " secType=" + str(contract.m_secType) \
           + " expiry=" + str(contract.m_expiry) \
           + " strike=" + str(contract.m_strike) \
           + " right=" + str(contract.m_right) \
           + " multiplier=" + str(contract.m_multiplier) \
           + " exchange=" + str(contract.m_exchange) \
           + " primaryExch=" + str(contract.m_primaryExch) \
           + " currency=" + str(contract.m_currency) \
           + " localSymbol=" + str(contract.m_localSymbol) \
           + " tradingClass=" + str(contract.m_tradingClass) \
           + " type=" + str(order.m_orderType) \
           + " lmtPrice=" + Util.DoubleMaxString(order.m_lmtPrice) \
           + " auxPrice=" + Util.DoubleMaxString(order.m_auxPrice) \
           + " TIF=" + str(order.m_tif) \
           + " localSymbol=" + str(contract.m_localSymbol) \
           + " client Id=" + str(order.m_clientId) \
           + " parent Id=" + str(order.m_parentId) \
           + " permId=" + str(order.m_permId) \
           + " outsideRth=" + str(order.m_outsideRth) \
           + " hidden=" + str(order.m_hidden) \
           + " discretionaryAmt=" + str(order.m_discretionaryAmt) \
           + " displaySize=" + str(order.m_displaySize) \
           + " triggerMethod=" + str(order.m_triggerMethod) \
           + " goodAfterTime=" + str(order.m_goodAfterTime) \
           + " goodTillDate=" + str(order.m_goodTillDate) \
           + " faGroup=" + str(order.m_faGroup) \
           + " faMethod=" + str(order.m_faMethod) \
           + " faPercentage=" + str(order.m_faPercentage) \
           + " faProfile=" + str(order.m_faProfile) \
           + " shortSaleSlot=" + str(order.m_shortSaleSlot) \
           + " designatedLocation=" + str(order.m_designatedLocation) \
           + " exemptCode=" + str(order.m_exemptCode) \
           + " ocaGroup=" + str(order.m_ocaGroup) \
           + " ocaType=" + str(order.m_ocaType) \
           + " rule80A=" + str(order.m_rule80A) \
           + " allOrNone=" + str(order.m_allOrNone) \
           + " minQty=" + Util.IntMaxString(order.m_minQty) \
           + " percentOffset=" + Util.DoubleMaxString(order.m_percentOffset) \
           + " eTradeOnly=" + order.m_eTradeOnly \
           + " firmQuoteOnly=" + str(order.m_firmQuoteOnly) \
           + " nbboPriceCap=" + Util.DoubleMaxString(order.m_nbboPriceCap) \
           + " optOutSmartRouting=" + str(order.m_optOutSmartRouting) \
           + " auctionStrategy=" + str(order.m_auctionStrategy) \
           + " startingPrice=" + Util.DoubleMaxString(order.m_startingPrice) \
           + " stockRefPrice=" + Util.DoubleMaxString(order.m_stockRefPrice) \
           + " delta=" + Util.DoubleMaxString(order.m_delta) \
           + " stockRangeLower=" + Util.DoubleMaxString(order.m_stockRangeLower) \
           + " stockRangeUpper=" + Util.DoubleMaxString(order.m_stockRangeUpper) \
           + " volatility=" + Util.DoubleMaxString(order.m_volatility) \
           + " volatilityType=" + str(order.m_volatilityType) \
           + " deltaNeutralOrderType=" + str(order.m_deltaNeutralOrderType) \
           + " deltaNeutralAuxPrice=" + Util.DoubleMaxString(order.m_deltaNeutralAuxPrice) \
           + " deltaNeutralConId=" + str(order.m_deltaNeutralConId) \
           + " deltaNeutralSettlingFirm=" + str(order.m_deltaNeutralSettlingFirm) \
           + " deltaNeutralClearingAccount=" + str(order.m_deltaNeutralClearingAccount) \
           + " deltaNeutralClearingIntent=" + str(order.m_deltaNeutralClearingIntent) \
           + " deltaNeutralOpenClose=" + str(order.m_deltaNeutralOpenClose) \
           + " deltaNeutralShortSale=" + str(order.m_deltaNeutralShortSale) \
           + " deltaNeutralShortSaleSlot=" + str(order.m_deltaNeutralShortSaleSlot) \
           + " deltaNeutralDesignatedLocation=" + str(order.m_deltaNeutralDesignatedLocation) \
           + " continuousUpdate=" + str(order.m_continuousUpdate) \
           + " referencePriceType=" + str(order.m_referencePriceType) \
           + " trailStopPrice=" + Util.DoubleMaxString(order.m_trailStopPrice) \
           + " trailingPercent=" + Util.DoubleMaxString(order.m_trailingPercent) \
           + " scaleInitLevelSize=" + Util.IntMaxString(order.m_scaleInitLevelSize) \
           + " scaleSubsLevelSize=" + Util.IntMaxString(order.m_scaleSubsLevelSize) \
           + " scalePriceIncrement=" + Util.DoubleMaxString(order.m_scalePriceIncrement) \
           + " scalePriceAdjustValue=" + Util.DoubleMaxString(order.m_scalePriceAdjustValue) \
           + " scalePriceAdjustInterval=" + Util.IntMaxString(order.m_scalePriceAdjustInterval) \
           + " scaleProfitOffset=" + Util.DoubleMaxString(order.m_scaleProfitOffset) \
           + " scaleAutoReset=" + str(order.m_scaleAutoReset) \
           + " scaleInitPosition=" + Util.IntMaxString(order.m_scaleInitPosition) \
           + " scaleInitFillQty=" + Util.IntMaxString(order.m_scaleInitFillQty) \
           + " scaleRandomPercent=" + str(order.m_scaleRandomPercent) \
           + " hedgeType=" + str(order.m_hedgeType) \
           + " hedgeParam=" + str(order.m_hedgeParam) \
           + " account=" + str(order.m_account) \
           + " settlingFirm=" + str(order.m_settlingFirm) \
           + " clearingAccount=" + str(order.m_clearingAccount) \
           + " clearingIntent=" + str(order.m_clearingIntent) \
           + " notHeld=" + str(order.m_notHeld) \
           + " whatIf=" + str(order.m_whatIf)
     if "BAG" == contract.m_secType:
         if contract.m_comboLegsDescrip is not None:
             msg += " comboLegsDescrip=" + str(contract.m_comboLegsDescrip)
         msg += " comboLegs={"
         if contract.m_comboLegs is not None:
             i = 0
             while i < len(contract.m_comboLegs):
                 comboLeg = contract.m_comboLegs[i]
                 msg += " leg " + str(i + 1) + ": "
                 msg += "conId=" + str(comboLeg.m_conId)
                 msg += " ratio=" + str(comboLeg.m_ratio)
                 msg += " action=" + str(comboLeg.m_action)
                 msg += " exchange=" + str(comboLeg.m_exchange)
                 msg += " openClose=" + str(comboLeg.m_openClose)
                 msg += " shortSaleSlot=" + str(comboLeg.m_shortSaleSlot)
                 msg += " designatedLocation=" + str(
                     comboLeg.m_designatedLocation)
                 msg += " exemptCode=" + str(comboLeg.m_exemptCode)
                 if order.m_orderComboLegs is not None and len(
                         contract.m_comboLegs) == len(
                             order.m_orderComboLegs):
                     orderComboLeg = order.m_orderComboLegs[i]
                     msg += " price=" + Util.DoubleMaxString(
                         orderComboLeg.m_price)
                 msg += ";"
                 i += 1
         msg += "}"
         if order.m_basisPoints != Double.MAX_VALUE:
             msg += " basisPoints=" + Util.DoubleMaxString(
                 order.m_basisPoints)
             msg += " basisPointsType=" + Util.IntMaxString(
                 order.m_basisPointsType)
     if contract.m_underComp is not None:
         underComp = contract.m_underComp
         msg += " underComp.conId =" + str(
             underComp.m_conId) + " underComp.delta =" + str(
                 underComp.m_delta) + " underComp.price =" + str(
                     underComp.m_price)
     if not Util.StringIsEmpty(order.m_algoStrategy):
         msg += " algoStrategy=" + str(order.m_algoStrategy)
         msg += " algoParams={"
         if order.m_algoParams is not None:
             algoParams = order.m_algoParams
             i = 0
             while i < len(algoParams):
                 param = algoParams[i]
                 if i > 0:
                     msg += ","
                 msg += str(param.m_tag) + "=" + str(param.m_value)
                 i += 1
         msg += "}"
     if "BAG" == contract.m_secType:
         msg += " smartComboRoutingParams={"
         if order.m_smartComboRoutingParams is not None:
             smartComboRoutingParams = order.m_smartComboRoutingParams
             i = 0
             while i < len(smartComboRoutingParams):
                 param = smartComboRoutingParams[i]
                 if i > 0:
                     msg += ","
                 msg += str(param.m_tag) + "=" + str(param.m_value)
                 i += 1
         msg += "}"
     orderStateMsg = " status=" + str(orderState.m_status) \
                     + " initMargin=" + str(orderState.m_initMargin) \
                     + " maintMargin=" + str(orderState.m_maintMargin) \
                     + " equityWithLoan=" + str(orderState.m_equityWithLoan) \
                     + " commission=" + Util.DoubleMaxString(orderState.m_commission) \
                     + " minCommission=" + Util.DoubleMaxString(orderState.m_minCommission) \
                     + " maxCommission=" + Util.DoubleMaxString(orderState.m_maxCommission) \
                     + " commissionCurrency=" + str(orderState.m_commissionCurrency) \
                     + " warningText=" + str(orderState.m_warningText)
     return msg + orderStateMsg
Exemplo n.º 16
0
 def processMsg(self, msgId):
     if (msgId == -1):
         return False
     if msgId == self.TICK_PRICE:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         price = self.readDouble()
         size = 0
         if version >= 2:
             size = self.readInt()
         canAutoExecute = 0
         if version >= 3:
             canAutoExecute = self.readInt()
         self.eWrapper().tickPrice(tickerId, tickType, price, canAutoExecute)
         if version >= 2:
             sizeTickType = -1
             if tickType == 1:
                 sizeTickType = 0
             elif tickType == 2:
                 sizeTickType = 3
             elif tickType == 4:
                 sizeTickType = 5
             if (sizeTickType != -1):
                 self.eWrapper().tickSize(tickerId, sizeTickType, size)
     elif msgId == self.TICK_SIZE:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         size = self.readInt()
         self.eWrapper().tickSize(tickerId, tickType, size)
     elif msgId == self.TICK_OPTION_COMPUTATION:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         impliedVol = self.readDouble()
         if impliedVol < 0:
             impliedVol = Double.MAX_VALUE
         delta = self.readDouble()
         if abs(delta) > 1:
             delta = Double.MAX_VALUE
         modelPrice = float()
         pvDividend = float()
         if (tickType == TickType.MODEL_OPTION):
             modelPrice = self.readDouble()
             pvDividend = self.readDouble()
         else:
             modelPrice = pvDividend = Double.MAX_VALUE
         self.eWrapper().tickOptionComputation(tickerId, tickType, impliedVol, delta, modelPrice, pvDividend)
     elif msgId == self.TICK_GENERIC:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         value = self.readDouble()
         self.eWrapper().tickGeneric(tickerId, tickType, value)
     elif msgId == self.TICK_STRING:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         value = self.readStr()
         self.eWrapper().tickString(tickerId, tickType, value)
     elif msgId == self.TICK_EFP:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         basisPoints = self.readDouble()
         formattedBasisPoints = self.readStr()
         impliedFuturesPrice = self.readDouble()
         holdDays = self.readInt()
         futureExpiry = self.readStr()
         dividendImpact = self.readDouble()
         dividendsToExpiry = self.readDouble()
         self.eWrapper().tickEFP(tickerId, tickType, basisPoints, formattedBasisPoints, impliedFuturesPrice, holdDays, futureExpiry, dividendImpact, dividendsToExpiry)
     elif msgId == self.ORDER_STATUS:
         version = self.readInt()
         id = self.readInt()
         status = self.readStr()
         filled = self.readInt()
         remaining = self.readInt()
         avgFillPrice = self.readDouble()
         permId = 0
         if version >= 2:
             permId = self.readInt()
         parentId = 0
         if version >= 3:
             parentId = self.readInt()
         lastFillPrice = 0
         if version >= 4:
             lastFillPrice = self.readDouble()
         clientId = 0
         if version >= 5:
             clientId = self.readInt()
         whyHeld = None
         if version >= 6:
             whyHeld = self.readStr()
         self.eWrapper().orderStatus(id, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld)
     elif msgId == self.ACCT_VALUE:
         version = self.readInt()
         key = self.readStr()
         val = self.readStr()
         cur = self.readStr()
         accountName = None
         if version >= 2:
             accountName = self.readStr()
         self.eWrapper().updateAccountValue(key, val, cur, accountName)
     elif msgId == self.PORTFOLIO_VALUE:
         version = self.readInt()
         contract = Contract()
         if version >= 6:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         if version >= 7:
             contract.m_multiplier = self.readStr()
             contract.m_primaryExch = self.readStr()
         contract.m_currency = self.readStr()
         if version >= 2:
             contract.m_localSymbol = self.readStr()
         position = self.readInt()
         marketPrice = self.readDouble()
         marketValue = self.readDouble()
         averageCost = 0.0
         unrealizedPNL = 0.0
         realizedPNL = 0.0
         if version >= 3:
             averageCost = self.readDouble()
             unrealizedPNL = self.readDouble()
             realizedPNL = self.readDouble()
         accountName = None
         if version >= 4:
             accountName = self.readStr()
         if (version == 6) and (self.m_parent.serverVersion() == 39):
             contract.m_primaryExch = self.readStr()
         self.eWrapper().updatePortfolio(contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName)
     elif msgId == self.ACCT_UPDATE_TIME:
         version = self.readInt()
         timeStamp = self.readStr()
         self.eWrapper().updateAccountTime(timeStamp)
     elif msgId == self.ERR_MSG:
         version = self.readInt()
         if version < 2:
             msg = self.readStr()
             self.m_parent.error(msg)
         else:
             id = self.readInt()
             errorCode = self.readInt()
             errorMsg = self.readStr()
             self.m_parent.error(id, errorCode, errorMsg)
     elif msgId == self.OPEN_ORDER:
         version = self.readInt()
         order = Order()
         order.m_orderId = self.readInt()
         contract = Contract()
         if version >= 17:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         contract.m_exchange = self.readStr()
         contract.m_currency = self.readStr()
         if version >= 2:
             contract.m_localSymbol = self.readStr()
         order.m_action = self.readStr()
         order.m_totalQuantity = self.readInt()
         order.m_orderType = self.readStr()
         order.m_lmtPrice = self.readDouble()
         order.m_auxPrice = self.readDouble()
         order.m_tif = self.readStr()
         order.m_ocaGroup = self.readStr()
         order.m_account = self.readStr()
         order.m_openClose = self.readStr()
         order.m_origin = self.readInt()
         order.m_orderRef = self.readStr()
         if version >= 3:
             order.m_clientId = self.readInt()
         if version >= 4:
             order.m_permId = self.readInt()
             if version < 18:
                 self.readBoolFromInt()
             else:
                 order.m_outsideRth = self.readBoolFromInt()
             order.m_hidden = (self.readInt() == 1)
             order.m_discretionaryAmt = self.readDouble()
         if version >= 5:
             order.m_goodAfterTime = self.readStr()
         if version >= 6:
             self.readStr()
         if version >= 7:
             order.m_faGroup = self.readStr()
             order.m_faMethod = self.readStr()
             order.m_faPercentage = self.readStr()
             order.m_faProfile = self.readStr()
         if version >= 8:
             order.m_goodTillDate = self.readStr()
         if version >= 9:
             order.m_rule80A = self.readStr()
             order.m_percentOffset = self.readDouble()
             order.m_settlingFirm = self.readStr()
             order.m_shortSaleSlot = self.readInt()
             order.m_designatedLocation = self.readStr()
             order.m_auctionStrategy = self.readInt()
             order.m_startingPrice = self.readDouble()
             order.m_stockRefPrice = self.readDouble()
             order.m_delta = self.readDouble()
             order.m_stockRangeLower = self.readDouble()
             order.m_stockRangeUpper = self.readDouble()
             order.m_displaySize = self.readInt()
             if version < 18:
                 self.readBoolFromInt()
             order.m_blockOrder = self.readBoolFromInt()
             order.m_sweepToFill = self.readBoolFromInt()
             order.m_allOrNone = self.readBoolFromInt()
             order.m_minQty = self.readInt()
             order.m_ocaType = self.readInt()
             order.m_eTradeOnly = self.readBoolFromInt()
             order.m_firmQuoteOnly = self.readBoolFromInt()
             order.m_nbboPriceCap = self.readDouble()
         if version >= 10:
             order.m_parentId = self.readInt()
             order.m_triggerMethod = self.readInt()
         if version >= 11:
             order.m_volatility = self.readDouble()
             order.m_volatilityType = self.readInt()
             if (version == 11):
                 receivedInt = self.readInt()
                 order.m_deltaNeutralOrderType = "NONE" if (receivedInt == 0) else "MKT"
             else:
                 order.m_deltaNeutralOrderType = self.readStr()
                 order.m_deltaNeutralAuxPrice = self.readDouble()
             order.m_continuousUpdate = self.readInt()
             if (self.m_parent.serverVersion() == 26):
                 order.m_stockRangeLower = self.readDouble()
                 order.m_stockRangeUpper = self.readDouble()
             order.m_referencePriceType = self.readInt()
         if version >= 13:
             order.m_trailStopPrice = self.readDouble()
         if version >= 14:
             order.m_basisPoints = self.readDouble()
             order.m_basisPointsType = self.readInt()
             contract.m_comboLegsDescrip = self.readStr()
         if version >= 15:
             if version >= 20:
                 order.m_scaleInitLevelSize = self.readIntMax()
                 order.m_scaleSubsLevelSize = self.readIntMax()
             else:
                 self.readIntMax()
                 order.m_scaleInitLevelSize = self.readIntMax()
             order.m_scalePriceIncrement = self.readDoubleMax()
         if version >= 19:
             order.m_clearingAccount = self.readStr()
             order.m_clearingIntent = self.readStr()
         if version >= 22:
             order.m_notHeld = self.readBoolFromInt()
         if version >= 20:
             if self.readBoolFromInt():
                 underComp = UnderComp()
                 underComp.m_conId = self.readInt()
                 underComp.m_delta = self.readDouble()
                 underComp.m_price = self.readDouble()
                 contract.m_underComp = underComp
         if version >= 21:
             order.m_algoStrategy = self.readStr()
             if not Util.StringIsEmpty(order.m_algoStrategy):
                 algoParamsCount = self.readInt()
                 if algoParamsCount > 0:
                     order.m_algoParams = Vector(algoParamsCount)
                     ## for-while
                     i = 0
                     while i < algoParamsCount:
                         tagValue = TagValue()
                         tagValue.m_tag = self.readStr()
                         tagValue.m_value = self.readStr()
                         order.m_algoParams.add(tagValue)
                         i += 1
         orderState = OrderState()
         if version >= 16:
             order.m_whatIf = self.readBoolFromInt()
             orderState.m_status = self.readStr()
             orderState.m_initMargin = self.readStr()
             orderState.m_maintMargin = self.readStr()
             orderState.m_equityWithLoan = self.readStr()
             orderState.m_commission = self.readDoubleMax()
             orderState.m_minCommission = self.readDoubleMax()
             orderState.m_maxCommission = self.readDoubleMax()
             orderState.m_commissionCurrency = self.readStr()
             orderState.m_warningText = self.readStr()
         self.eWrapper().openOrder(order.m_orderId, contract, order, orderState)
     elif msgId == self.NEXT_VALID_ID:
         version = self.readInt()
         orderId = self.readInt()
         self.eWrapper().nextValidId(orderId)
     elif msgId == self.SCANNER_DATA:
         contract = ContractDetails()
         version = self.readInt()
         tickerId = self.readInt()
         numberOfElements = self.readInt()
         ## for-while
         ctr = 0
         while ctr < numberOfElements:
             rank = self.readInt()
             if version >= 3:
                 contract.m_summary.m_conId = self.readInt()
             contract.m_summary.m_symbol = self.readStr()
             contract.m_summary.m_secType = self.readStr()
             contract.m_summary.m_expiry = self.readStr()
             contract.m_summary.m_strike = self.readDouble()
             contract.m_summary.m_right = self.readStr()
             contract.m_summary.m_exchange = self.readStr()
             contract.m_summary.m_currency = self.readStr()
             contract.m_summary.m_localSymbol = self.readStr()
             contract.m_marketName = self.readStr()
             contract.m_tradingClass = self.readStr()
             distance = self.readStr()
             benchmark = self.readStr()
             projection = self.readStr()
             legsStr = None
             if version >= 2:
                 legsStr = self.readStr()
             self.eWrapper().scannerData(tickerId, rank, contract, distance, benchmark, projection, legsStr)
             ctr += 1
         self.eWrapper().scannerDataEnd(tickerId)
     elif msgId == self.CONTRACT_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 3:
             reqId = self.readInt()
         contract = ContractDetails()
         contract.m_summary.m_symbol = self.readStr()
         contract.m_summary.m_secType = self.readStr()
         contract.m_summary.m_expiry = self.readStr()
         contract.m_summary.m_strike = self.readDouble()
         contract.m_summary.m_right = self.readStr()
         contract.m_summary.m_exchange = self.readStr()
         contract.m_summary.m_currency = self.readStr()
         contract.m_summary.m_localSymbol = self.readStr()
         contract.m_marketName = self.readStr()
         contract.m_tradingClass = self.readStr()
         contract.m_summary.m_conId = self.readInt()
         contract.m_minTick = self.readDouble()
         contract.m_summary.m_multiplier = self.readStr()
         contract.m_orderTypes = self.readStr()
         contract.m_validExchanges = self.readStr()
         if version >= 2:
             contract.m_priceMagnifier = self.readInt()
         if version >= 4:
             contract.m_underConId = self.readInt()
         if version >= 5:
             contract.m_longName = self.readStr()
             contract.m_summary.m_primaryExch = self.readStr()
         self.eWrapper().contractDetails(reqId, contract)
     elif msgId == self.BOND_CONTRACT_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 3:
             reqId = self.readInt()
         contract = ContractDetails()
         contract.m_summary.m_symbol = self.readStr()
         contract.m_summary.m_secType = self.readStr()
         contract.m_cusip = self.readStr()
         contract.m_coupon = self.readDouble()
         contract.m_maturity = self.readStr()
         contract.m_issueDate = self.readStr()
         contract.m_ratings = self.readStr()
         contract.m_bondType = self.readStr()
         contract.m_couponType = self.readStr()
         contract.m_convertible = self.readBoolFromInt()
         contract.m_callable = self.readBoolFromInt()
         contract.m_putable = self.readBoolFromInt()
         contract.m_descAppend = self.readStr()
         contract.m_summary.m_exchange = self.readStr()
         contract.m_summary.m_currency = self.readStr()
         contract.m_marketName = self.readStr()
         contract.m_tradingClass = self.readStr()
         contract.m_summary.m_conId = self.readInt()
         contract.m_minTick = self.readDouble()
         contract.m_orderTypes = self.readStr()
         contract.m_validExchanges = self.readStr()
         if version >= 2:
             contract.m_nextOptionDate = self.readStr()
             contract.m_nextOptionType = self.readStr()
             contract.m_nextOptionPartial = self.readBoolFromInt()
             contract.m_notes = self.readStr()
         if version >= 4:
             contract.m_longName = self.readStr()
         self.eWrapper().bondContractDetails(reqId, contract)
     elif msgId == self.EXECUTION_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 7:
             reqId = self.readInt()
         orderId = self.readInt()
         contract = Contract()
         if version >= 5:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         contract.m_exchange = self.readStr()
         contract.m_currency = self.readStr()
         contract.m_localSymbol = self.readStr()
         exec_ = Execution()
         exec_.m_orderId = orderId
         exec_.m_execId = self.readStr()
         exec_.m_time = self.readStr()
         exec_.m_acctNumber = self.readStr()
         exec_.m_exchange = self.readStr()
         exec_.m_side = self.readStr()
         exec_.m_shares = self.readInt()
         exec_.m_price = self.readDouble()
         if version >= 2:
             exec_.m_permId = self.readInt()
         if version >= 3:
             exec_.m_clientId = self.readInt()
         if version >= 4:
             exec_.m_liquidation = self.readInt()
         if version >= 6:
             exec_.m_cumQty = self.readInt()
             exec_.m_avgPrice = self.readDouble()
         self.eWrapper().execDetails(reqId, contract, exec_)
     elif msgId == self.MARKET_DEPTH:
         version = self.readInt()
         id = self.readInt()
         position = self.readInt()
         operation = self.readInt()
         side = self.readInt()
         price = self.readDouble()
         size = self.readInt()
         self.eWrapper().updateMktDepth(id, position, operation, side, price, size)
     elif msgId == self.MARKET_DEPTH_L2:
         version = self.readInt()
         id = self.readInt()
         position = self.readInt()
         marketMaker = self.readStr()
         operation = self.readInt()
         side = self.readInt()
         price = self.readDouble()
         size = self.readInt()
         self.eWrapper().updateMktDepthL2(id, position, marketMaker, operation, side, price, size)
     elif msgId == self.NEWS_BULLETINS:
         version = self.readInt()
         newsMsgId = self.readInt()
         newsMsgType = self.readInt()
         newsMessage = self.readStr()
         originatingExch = self.readStr()
         self.eWrapper().updateNewsBulletin(newsMsgId, newsMsgType, newsMessage, originatingExch)
     elif msgId == self.MANAGED_ACCTS:
         version = self.readInt()
         accountsList = self.readStr()
         self.eWrapper().managedAccounts(accountsList)
     elif msgId == self.RECEIVE_FA:
         version = self.readInt()
         faDataType = self.readInt()
         xml = self.readStr()
         self.eWrapper().receiveFA(faDataType, xml)
     elif msgId == self.HISTORICAL_DATA:
         version = self.readInt()
         reqId = self.readInt()
         startDateStr = ""
         endDateStr = ""
         completedIndicator = "finished"
         if version >= 2:
             startDateStr = self.readStr()
             endDateStr = self.readStr()
             completedIndicator += "-" + startDateStr + "-" + endDateStr
         itemCount = self.readInt()
         ## for-while
         ctr = 0
         while ctr < itemCount:
             date = self.readStr()
             open = self.readDouble()
             high = self.readDouble()
             low = self.readDouble()
             close = self.readDouble()
             volume = self.readInt()
             WAP = self.readDouble()
             hasGaps = self.readStr()
             barCount = -1
             if version >= 3:
                 barCount = self.readInt()
             self.eWrapper().historicalData(reqId, date, open, high, low, close, volume, barCount, WAP, Boolean.valueOf(hasGaps).booleanValue())
             ctr += 1
         self.eWrapper().historicalData(reqId, completedIndicator, -1, -1, -1, -1, -1, -1, -1, False)
     elif msgId == self.SCANNER_PARAMETERS:
         version = self.readInt()
         xml = self.readStr()
         self.eWrapper().scannerParameters(xml)
     elif msgId == self.CURRENT_TIME:
         self.readInt()
         time = self.readLong()
         self.eWrapper().currentTime(time)
     elif msgId == self.REAL_TIME_BARS:
         self.readInt()
         reqId = self.readInt()
         time = self.readLong()
         open = self.readDouble()
         high = self.readDouble()
         low = self.readDouble()
         close = self.readDouble()
         volume = self.readLong()
         wap = self.readDouble()
         count = self.readInt()
         self.eWrapper().realtimeBar(reqId, time, open, high, low, close, volume, wap, count)
     elif msgId == self.FUNDAMENTAL_DATA:
         self.readInt()
         reqId = self.readInt()
         data = self.readStr()
         self.eWrapper().fundamentalData(reqId, data)
     elif msgId == self.CONTRACT_DATA_END:
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().contractDetailsEnd(reqId)
     elif msgId == self.OPEN_ORDER_END:
         self.readInt()
         self.eWrapper().openOrderEnd()
     elif msgId == self.ACCT_DOWNLOAD_END:
         self.readInt()
         accountName = self.readStr()
         self.eWrapper().accountDownloadEnd(accountName)
     elif msgId == self.EXECUTION_DATA_END:
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().execDetailsEnd(reqId)
     elif msgId == self.DELTA_NEUTRAL_VALIDATION:
         self.readInt()
         reqId = self.readInt()
         underComp = UnderComp()
         underComp.m_conId = self.readInt()
         underComp.m_delta = self.readDouble()
         underComp.m_price = self.readDouble()
         self.eWrapper().deltaNeutralValidation(reqId, underComp)
     elif msgId == self.TICK_SNAPSHOT_END:
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().tickSnapshotEnd(reqId)
     else:
         self.m_parent.error(EClientErrors.NO_VALID_ID, EClientErrors.UNKNOWN_ID.code(), EClientErrors.UNKNOWN_ID.msg())
         return False
     return True
Exemplo n.º 17
0
 def processMsg(self, msgId):
     """ generated source for method processMsg """
     if msgId == -1:
         return False
     if msgId == self.TICK_PRICE:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         price = self.readDouble()
         size = 0
         if version >= 2:
             size = self.readInt()
         canAutoExecute = 0
         if version >= 3:
             canAutoExecute = self.readInt()
         self.eWrapper().tickPrice(tickerId, tickType, price,
                                   canAutoExecute)
         if version >= 2:
             #  not a tick
             sizeTickType = -1
             if tickType == 1:
                 #  BID
                 sizeTickType = 0
                 #  BID_SIZE
             elif tickType == 2:
                 #  ASK
                 sizeTickType = 3
                 #  ASK_SIZE
             elif tickType == 4:
                 #  LAST
                 sizeTickType = 5
                 #  LAST_SIZE
             if sizeTickType != -1:
                 self.eWrapper().tickSize(tickerId, sizeTickType, size)
     elif msgId == self.TICK_SIZE:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         size = self.readInt()
         self.eWrapper().tickSize(tickerId, tickType, size)
     elif msgId == self.POSITION:
         version = self.readInt()
         account = self.readStr()
         contract = Contract()
         contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         contract.m_multiplier = self.readStr()
         contract.m_exchange = self.readStr()
         contract.m_currency = self.readStr()
         contract.m_localSymbol = self.readStr()
         if version >= 2:
             contract.m_tradingClass = self.readStr()
         pos = self.readInt()
         avgCost = 0
         if version >= 3:
             avgCost = self.readDouble()
         self.eWrapper().position(account, contract, pos, avgCost)
     elif msgId == self.POSITION_END:
         version = self.readInt()
         self.eWrapper().positionEnd()
     elif msgId == self.ACCOUNT_SUMMARY:
         version = self.readInt()
         reqId = self.readInt()
         account = self.readStr()
         tag = self.readStr()
         value = self.readStr()
         currency = self.readStr()
         self.eWrapper().accountSummary(reqId, account, tag, value,
                                        currency)
     elif msgId == self.ACCOUNT_SUMMARY_END:
         version = self.readInt()
         reqId = self.readInt()
         self.eWrapper().accountSummaryEnd(reqId)
     elif msgId == self.TICK_OPTION_COMPUTATION:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         impliedVol = self.readDouble()
         if impliedVol < 0:  #  -1 is the "not yet computed" indicator
             impliedVol = Double.MAX_VALUE
         delta = self.readDouble()
         if abs(delta) > 1:  #  -2 is the "not yet computed" indicator
             delta = Double.MAX_VALUE
         optPrice = Double.MAX_VALUE
         pvDividend = Double.MAX_VALUE
         gamma = Double.MAX_VALUE
         vega = Double.MAX_VALUE
         theta = Double.MAX_VALUE
         undPrice = Double.MAX_VALUE
         if version >= 6 or (tickType == TickType.MODEL_OPTION):
             #  introduced in version == 5
             optPrice = self.readDouble()
             if optPrice < 0:  #  -1 is the "not yet computed" indicator
                 optPrice = Double.MAX_VALUE
             pvDividend = self.readDouble()
             if pvDividend < 0:  #  -1 is the "not yet computed" indicator
                 pvDividend = Double.MAX_VALUE
         if version >= 6:
             gamma = self.readDouble()
             if abs(gamma) > 1:  #  -2 is the "not yet computed" indicator
                 gamma = Double.MAX_VALUE
             vega = self.readDouble()
             if abs(vega) > 1:  #  -2 is the "not yet computed" indicator
                 vega = Double.MAX_VALUE
             theta = self.readDouble()
             if abs(theta) > 1:  #  -2 is the "not yet computed" indicator
                 theta = Double.MAX_VALUE
             undPrice = self.readDouble()
             if undPrice < 0:  #  -1 is the "not yet computed" indicator
                 undPrice = Double.MAX_VALUE
         self.eWrapper().tickOptionComputation(tickerId, tickType,
                                               impliedVol, delta, optPrice,
                                               pvDividend, gamma, vega,
                                               theta, undPrice)
     elif msgId == self.TICK_GENERIC:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         value = self.readDouble()
         self.eWrapper().tickGeneric(tickerId, tickType, value)
     elif msgId == self.TICK_STRING:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         value = self.readStr()
         self.eWrapper().tickString(tickerId, tickType, value)
     elif msgId == self.TICK_EFP:
         version = self.readInt()
         tickerId = self.readInt()
         tickType = self.readInt()
         basisPoints = self.readDouble()
         formattedBasisPoints = self.readStr()
         impliedFuturesPrice = self.readDouble()
         holdDays = self.readInt()
         futureExpiry = self.readStr()
         dividendImpact = self.readDouble()
         dividendsToExpiry = self.readDouble()
         self.eWrapper().tickEFP(tickerId, tickType, basisPoints,
                                 formattedBasisPoints, impliedFuturesPrice,
                                 holdDays, futureExpiry, dividendImpact,
                                 dividendsToExpiry)
     elif msgId == self.ORDER_STATUS:
         version = self.readInt()
         id = self.readInt()
         status = self.readStr()
         filled = self.readInt()
         remaining = self.readInt()
         avgFillPrice = self.readDouble()
         permId = 0
         if version >= 2:
             permId = self.readInt()
         parentId = 0
         if version >= 3:
             parentId = self.readInt()
         lastFillPrice = 0
         if version >= 4:
             lastFillPrice = self.readDouble()
         clientId = 0
         if version >= 5:
             clientId = self.readInt()
         whyHeld = None
         if version >= 6:
             whyHeld = self.readStr()
         self.eWrapper().orderStatus(id, status, filled, remaining,
                                     avgFillPrice, permId, parentId,
                                     lastFillPrice, clientId, whyHeld)
     elif msgId == self.ACCT_VALUE:
         version = self.readInt()
         key = self.readStr()
         val = self.readStr()
         cur = self.readStr()
         accountName = None
         if version >= 2:
             accountName = self.readStr()
         self.eWrapper().updateAccountValue(key, val, cur, accountName)
     elif msgId == self.PORTFOLIO_VALUE:
         version = self.readInt()
         contract = Contract()
         if version >= 6:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         if version >= 7:
             contract.m_multiplier = self.readStr()
             contract.m_primaryExch = self.readStr()
         contract.m_currency = self.readStr()
         if version >= 2:
             contract.m_localSymbol = self.readStr()
         if version >= 8:
             contract.m_tradingClass = self.readStr()
         position = self.readInt()
         marketPrice = self.readDouble()
         marketValue = self.readDouble()
         averageCost = 0.0
         unrealizedPNL = 0.0
         realizedPNL = 0.0
         if version >= 3:
             averageCost = self.readDouble()
             unrealizedPNL = self.readDouble()
             realizedPNL = self.readDouble()
         accountName = None
         if version >= 4:
             accountName = self.readStr()
         if version == 6 and self.m_parent.serverVersion() == 39:
             contract.m_primaryExch = self.readStr()
         self.eWrapper().updatePortfolio(contract, position, marketPrice,
                                         marketValue, averageCost,
                                         unrealizedPNL, realizedPNL,
                                         accountName)
     elif msgId == self.ACCT_UPDATE_TIME:
         version = self.readInt()
         timeStamp = self.readStr()
         self.eWrapper().updateAccountTime(timeStamp)
     elif msgId == self.ERR_MSG:
         version = self.readInt()
         if version < 2:
             msg = self.readStr()
             self.m_parent.error(msg)
         else:
             id = self.readInt()
             errorCode = self.readInt()
             errorMsg = self.readStr()
             self.m_parent.error(id, errorCode, errorMsg)
     elif msgId == self.OPEN_ORDER:
         #  read version
         version = self.readInt()
         #  read order id
         order = Order()
         order.m_orderId = self.readInt()
         #  read contract fields
         contract = Contract()
         if version >= 17:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         if version >= 32:
             contract.m_multiplier = self.readStr()
         contract.m_exchange = self.readStr()
         contract.m_currency = self.readStr()
         if version >= 2:
             contract.m_localSymbol = self.readStr()
         if version >= 32:
             contract.m_tradingClass = self.readStr()
         #  read order fields
         order.m_action = self.readStr()
         order.m_totalQuantity = self.readInt()
         order.m_orderType = self.readStr()
         if version < 29:
             order.m_lmtPrice = self.readDouble()
         else:
             order.m_lmtPrice = self.readDoubleMax()
         if version < 30:
             order.m_auxPrice = self.readDouble()
         else:
             order.m_auxPrice = self.readDoubleMax()
         order.m_tif = self.readStr()
         order.m_ocaGroup = self.readStr()
         order.m_account = self.readStr()
         order.m_openClose = self.readStr()
         order.m_origin = self.readInt()
         order.m_orderRef = self.readStr()
         if version >= 3:
             order.m_clientId = self.readInt()
         if version >= 4:
             order.m_permId = self.readInt()
             if version < 18:
                 #  will never happen
                 #  order.m_ignoreRth =
                 self.readBoolFromInt()
             else:
                 order.m_outsideRth = self.readBoolFromInt()
             order.m_hidden = self.readInt() == 1
             order.m_discretionaryAmt = self.readDouble()
         if version >= 5:
             order.m_goodAfterTime = self.readStr()
         if version >= 6:
             #  skip deprecated sharesAllocation field
             self.readStr()
         if version >= 7:
             order.m_faGroup = self.readStr()
             order.m_faMethod = self.readStr()
             order.m_faPercentage = self.readStr()
             order.m_faProfile = self.readStr()
         if version >= 8:
             order.m_goodTillDate = self.readStr()
         if version >= 9:
             order.m_rule80A = self.readStr()
             order.m_percentOffset = self.readDoubleMax()
             order.m_settlingFirm = self.readStr()
             order.m_shortSaleSlot = self.readInt()
             order.m_designatedLocation = self.readStr()
             if self.m_parent.serverVersion() == 51:
                 self.readInt()  #  exemptCode
             elif version >= 23:
                 order.m_exemptCode = self.readInt()
             order.m_auctionStrategy = self.readInt()
             order.m_startingPrice = self.readDoubleMax()
             order.m_stockRefPrice = self.readDoubleMax()
             order.m_delta = self.readDoubleMax()
             order.m_stockRangeLower = self.readDoubleMax()
             order.m_stockRangeUpper = self.readDoubleMax()
             order.m_displaySize = self.readInt()
             if version < 18:
                 #  will never happen
                 #  order.m_rthOnly =
                 self.readBoolFromInt()
             order.m_blockOrder = self.readBoolFromInt()
             order.m_sweepToFill = self.readBoolFromInt()
             order.m_allOrNone = self.readBoolFromInt()
             order.m_minQty = self.readIntMax()
             order.m_ocaType = self.readInt()
             order.m_eTradeOnly = self.readBoolFromInt()
             order.m_firmQuoteOnly = self.readBoolFromInt()
             order.m_nbboPriceCap = self.readDoubleMax()
         if version >= 10:
             order.m_parentId = self.readInt()
             order.m_triggerMethod = self.readInt()
         if version >= 11:
             order.m_volatility = self.readDoubleMax()
             order.m_volatilityType = self.readInt()
             if version == 11:
                 receivedInt = self.readInt()
                 order.m_deltaNeutralOrderType = ("NONE" if
                                                  (receivedInt
                                                   == 0) else "MKT")
             else:
                 #  version 12 and up
                 order.m_deltaNeutralOrderType = self.readStr()
                 order.m_deltaNeutralAuxPrice = self.readDoubleMax()
                 if version >= 27 and not Util.StringIsEmpty(
                         order.m_deltaNeutralOrderType):
                     order.m_deltaNeutralConId = self.readInt()
                     order.m_deltaNeutralSettlingFirm = self.readStr()
                     order.m_deltaNeutralClearingAccount = self.readStr()
                     order.m_deltaNeutralClearingIntent = self.readStr()
                 if version >= 31 and not Util.StringIsEmpty(
                         order.m_deltaNeutralOrderType):
                     order.m_deltaNeutralOpenClose = self.readStr()
                     order.m_deltaNeutralShortSale = self.readBoolFromInt()
                     order.m_deltaNeutralShortSaleSlot = self.readInt()
                     order.m_deltaNeutralDesignatedLocation = self.readStr()
             order.m_continuousUpdate = self.readInt()
             if self.m_parent.serverVersion() == 26:
                 order.m_stockRangeLower = self.readDouble()
                 order.m_stockRangeUpper = self.readDouble()
             order.m_referencePriceType = self.readInt()
         if version >= 13:
             order.m_trailStopPrice = self.readDoubleMax()
         if version >= 30:
             order.m_trailingPercent = self.readDoubleMax()
         if version >= 14:
             order.m_basisPoints = self.readDoubleMax()
             order.m_basisPointsType = self.readIntMax()
             contract.m_comboLegsDescrip = self.readStr()
         if version >= 29:
             comboLegsCount = self.readInt()
             if comboLegsCount > 0:
                 contract.m_comboLegs = []
                 i = 0
                 while i < comboLegsCount:
                     comboLeg = ComboLeg()
                     comboLeg.m_conId = self.readInt()
                     comboLeg.m_ratio = self.readInt()
                     comboLeg.m_action = self.readStr()
                     comboLeg.m_exchange = self.readStr()
                     comboLeg.m_openClose = self.readInt()
                     comboLeg.m_shortSaleSlot = self.readInt()
                     comboLeg.m_designatedLocation = self.readStr()
                     comboLeg.m_exemptCode = self.readInt()
                     contract.m_comboLegs.append(comboLeg)
                     i += 1
             orderComboLegsCount = self.readInt()
             if orderComboLegsCount > 0:
                 order.m_orderComboLegs = []
                 i = 0
                 while i < orderComboLegsCount:
                     price = self.readDoubleMax()
                     orderComboLeg = OrderComboLeg(price)
                     order.m_orderComboLegs.append(orderComboLeg)
                     i += 1
         if version >= 26:
             smartComboRoutingParamsCount = self.readInt()
             if smartComboRoutingParamsCount > 0:
                 order.m_smartComboRoutingParams = []
                 i = 0
                 while i < smartComboRoutingParamsCount:
                     tagValue = TagValue()
                     tagValue.m_tag = self.readStr()
                     tagValue.m_value = self.readStr()
                     order.m_smartComboRoutingParams.append(tagValue)
                     i += 1
         if version >= 15:
             if version >= 20:
                 order.m_scaleInitLevelSize = self.readIntMax()
                 order.m_scaleSubsLevelSize = self.readIntMax()
             else:
                 #  int notSuppScaleNumComponents =
                 self.readIntMax()
                 order.m_scaleInitLevelSize = self.readIntMax()
             order.m_scalePriceIncrement = self.readDoubleMax()
         if version >= 28 and order.m_scalePriceIncrement > 0.0 and order.m_scalePriceIncrement != Double.MAX_VALUE:
             order.m_scalePriceAdjustValue = self.readDoubleMax()
             order.m_scalePriceAdjustInterval = self.readIntMax()
             order.m_scaleProfitOffset = self.readDoubleMax()
             order.m_scaleAutoReset = self.readBoolFromInt()
             order.m_scaleInitPosition = self.readIntMax()
             order.m_scaleInitFillQty = self.readIntMax()
             order.m_scaleRandomPercent = self.readBoolFromInt()
         if version >= 24:
             order.m_hedgeType = self.readStr()
             if not Util.StringIsEmpty(order.m_hedgeType):
                 order.m_hedgeParam = self.readStr()
         if version >= 25:
             order.m_optOutSmartRouting = self.readBoolFromInt()
         if version >= 19:
             order.m_clearingAccount = self.readStr()
             order.m_clearingIntent = self.readStr()
         if version >= 22:
             order.m_notHeld = self.readBoolFromInt()
         if version >= 20:
             if self.readBoolFromInt():
                 underComp = UnderComp()
                 underComp.m_conId = self.readInt()
                 underComp.m_delta = self.readDouble()
                 underComp.m_price = self.readDouble()
                 contract.m_underComp = underComp
         if version >= 21:
             order.m_algoStrategy = self.readStr()
             if not Util.StringIsEmpty(order.m_algoStrategy):
                 algoParamsCount = self.readInt()
                 if algoParamsCount > 0:
                     order.m_algoParams = []
                     i = 0
                     while i < algoParamsCount:
                         tagValue = TagValue()
                         tagValue.m_tag = self.readStr()
                         tagValue.m_value = self.readStr()
                         order.m_algoParams.append(tagValue)
                         i += 1
         orderState = OrderState()
         if version >= 16:
             order.m_whatIf = self.readBoolFromInt()
             orderState.m_status = self.readStr()
             orderState.m_initMargin = self.readStr()
             orderState.m_maintMargin = self.readStr()
             orderState.m_equityWithLoan = self.readStr()
             orderState.m_commission = self.readDoubleMax()
             orderState.m_minCommission = self.readDoubleMax()
             orderState.m_maxCommission = self.readDoubleMax()
             orderState.m_commissionCurrency = self.readStr()
             orderState.m_warningText = self.readStr()
         self.eWrapper().openOrder(order.m_orderId, contract, order,
                                   orderState)
     elif msgId == self.NEXT_VALID_ID:
         version = self.readInt()
         orderId = self.readInt()
         self.eWrapper().nextValidId(orderId)
     elif msgId == self.SCANNER_DATA:
         contract = ContractDetails()
         version = self.readInt()
         tickerId = self.readInt()
         numberOfElements = self.readInt()
         ctr = 0
         while ctr < numberOfElements:
             rank = self.readInt()
             if version >= 3:
                 contract.m_summary.m_conId = self.readInt()
             contract.m_summary.m_symbol = self.readStr()
             contract.m_summary.m_secType = self.readStr()
             contract.m_summary.m_expiry = self.readStr()
             contract.m_summary.m_strike = self.readDouble()
             contract.m_summary.m_right = self.readStr()
             contract.m_summary.m_exchange = self.readStr()
             contract.m_summary.m_currency = self.readStr()
             contract.m_summary.m_localSymbol = self.readStr()
             contract.m_marketName = self.readStr()
             contract.m_summary.m_tradingClass = self.readStr()
             distance = self.readStr()
             benchmark = self.readStr()
             projection = self.readStr()
             legsStr = None
             if version >= 2:
                 legsStr = self.readStr()
             self.eWrapper().scannerData(tickerId, rank, contract, distance,
                                         benchmark, projection, legsStr)
             ctr += 1
         self.eWrapper().scannerDataEnd(tickerId)
     elif msgId == self.CONTRACT_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 3:
             reqId = self.readInt()
         contract = ContractDetails()
         contract.m_summary.m_symbol = self.readStr()
         contract.m_summary.m_secType = self.readStr()
         contract.m_summary.m_expiry = self.readStr()
         contract.m_summary.m_strike = self.readDouble()
         contract.m_summary.m_right = self.readStr()
         contract.m_summary.m_exchange = self.readStr()
         contract.m_summary.m_currency = self.readStr()
         contract.m_summary.m_localSymbol = self.readStr()
         contract.m_marketName = self.readStr()
         contract.m_summary.m_tradingClass = self.readStr()
         contract.m_summary.m_conId = self.readInt()
         contract.m_minTick = self.readDouble()
         contract.m_summary.m_multiplier = self.readStr()
         contract.m_orderTypes = self.readStr()
         contract.m_validExchanges = self.readStr()
         if version >= 2:
             contract.m_priceMagnifier = self.readInt()
         if version >= 4:
             contract.m_underConId = self.readInt()
         if version >= 5:
             contract.m_longName = self.readStr()
             contract.m_summary.m_primaryExch = self.readStr()
         if version >= 6:
             contract.m_contractMonth = self.readStr()
             contract.m_industry = self.readStr()
             contract.m_category = self.readStr()
             contract.m_subcategory = self.readStr()
             contract.m_timeZoneId = self.readStr()
             contract.m_tradingHours = self.readStr()
             contract.m_liquidHours = self.readStr()
         if version >= 8:
             contract.m_evRule = self.readStr()
             contract.m_evMultiplier = self.readDouble()
         if version >= 7:
             secIdListCount = self.readInt()
             if secIdListCount > 0:
                 contract.m_secIdList = []
                 i = 0
                 while i < secIdListCount:
                     tagValue = TagValue()
                     tagValue.m_tag = self.readStr()
                     tagValue.m_value = self.readStr()
                     contract.m_secIdList.append(tagValue)
                     i += 1
         self.eWrapper().contractDetails(reqId, contract)
     elif msgId == self.BOND_CONTRACT_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 3:
             reqId = self.readInt()
         contract = ContractDetails()
         contract.m_summary.m_symbol = self.readStr()
         contract.m_summary.m_secType = self.readStr()
         contract.m_cusip = self.readStr()
         contract.m_coupon = self.readDouble()
         contract.m_maturity = self.readStr()
         contract.m_issueDate = self.readStr()
         contract.m_ratings = self.readStr()
         contract.m_bondType = self.readStr()
         contract.m_couponType = self.readStr()
         contract.m_convertible = self.readBoolFromInt()
         contract.m_callable = self.readBoolFromInt()
         contract.m_putable = self.readBoolFromInt()
         contract.m_descAppend = self.readStr()
         contract.m_summary.m_exchange = self.readStr()
         contract.m_summary.m_currency = self.readStr()
         contract.m_marketName = self.readStr()
         contract.m_summary.m_tradingClass = self.readStr()
         contract.m_summary.m_conId = self.readInt()
         contract.m_minTick = self.readDouble()
         contract.m_orderTypes = self.readStr()
         contract.m_validExchanges = self.readStr()
         if version >= 2:
             contract.m_nextOptionDate = self.readStr()
             contract.m_nextOptionType = self.readStr()
             contract.m_nextOptionPartial = self.readBoolFromInt()
             contract.m_notes = self.readStr()
         if version >= 4:
             contract.m_longName = self.readStr()
         if version >= 6:
             contract.m_evRule = self.readStr()
             contract.m_evMultiplier = self.readDouble()
         if version >= 5:
             secIdListCount = self.readInt()
             if secIdListCount > 0:
                 contract.m_secIdList = []
                 i = 0
                 while i < secIdListCount:
                     tagValue = TagValue()
                     tagValue.m_tag = self.readStr()
                     tagValue.m_value = self.readStr()
                     contract.m_secIdList.append(tagValue)
                     i += 1
         self.eWrapper().bondContractDetails(reqId, contract)
     elif msgId == self.EXECUTION_DATA:
         version = self.readInt()
         reqId = -1
         if version >= 7:
             reqId = self.readInt()
         orderId = self.readInt()
         contract = Contract()
         #  read contract fields
         if version >= 5:
             contract.m_conId = self.readInt()
         contract.m_symbol = self.readStr()
         contract.m_secType = self.readStr()
         contract.m_expiry = self.readStr()
         contract.m_strike = self.readDouble()
         contract.m_right = self.readStr()
         if version >= 9:
             contract.m_multiplier = self.readStr()
         contract.m_exchange = self.readStr()
         contract.m_currency = self.readStr()
         contract.m_localSymbol = self.readStr()
         if version >= 10:
             contract.m_tradingClass = self.readStr()
         exec_ = Execution()
         exec_.m_orderId = orderId
         exec_.m_execId = self.readStr()
         exec_.m_time = self.readStr()
         exec_.m_acctNumber = self.readStr()
         exec_.m_exchange = self.readStr()
         exec_.m_side = self.readStr()
         exec_.m_shares = self.readInt()
         exec_.m_price = self.readDouble()
         if version >= 2:
             exec_.m_permId = self.readInt()
         if version >= 3:
             exec_.m_clientId = self.readInt()
         if version >= 4:
             exec_.m_liquidation = self.readInt()
         if version >= 6:
             exec_.m_cumQty = self.readInt()
             exec_.m_avgPrice = self.readDouble()
         if version >= 8:
             exec_.m_orderRef = self.readStr()
         if version >= 9:
             exec_.m_evRule = self.readStr()
             exec_.m_evMultiplier = self.readDouble()
         self.eWrapper().execDetails(reqId, contract, exec_)
     elif msgId == self.MARKET_DEPTH:
         version = self.readInt()
         id = self.readInt()
         position = self.readInt()
         operation = self.readInt()
         side = self.readInt()
         price = self.readDouble()
         size = self.readInt()
         self.eWrapper().updateMktDepth(id, position, operation, side,
                                        price, size)
     elif msgId == self.MARKET_DEPTH_L2:
         version = self.readInt()
         id = self.readInt()
         position = self.readInt()
         marketMaker = self.readStr()
         operation = self.readInt()
         side = self.readInt()
         price = self.readDouble()
         size = self.readInt()
         self.eWrapper().updateMktDepthL2(id, position, marketMaker,
                                          operation, side, price, size)
     elif msgId == self.NEWS_BULLETINS:
         version = self.readInt()
         newsMsgId = self.readInt()
         newsMsgType = self.readInt()
         newsMessage = self.readStr()
         originatingExch = self.readStr()
         self.eWrapper().updateNewsBulletin(newsMsgId, newsMsgType,
                                            newsMessage, originatingExch)
     elif msgId == self.MANAGED_ACCTS:
         version = self.readInt()
         accountsList = self.readStr()
         self.eWrapper().managedAccounts(accountsList)
     elif msgId == self.RECEIVE_FA:
         version = self.readInt()
         faDataType = self.readInt()
         xml = self.readStr()
         self.eWrapper().receiveFA(faDataType, xml)
     elif msgId == self.HISTORICAL_DATA:
         version = self.readInt()
         reqId = self.readInt()
         startDateStr = ""
         endDateStr = ""
         completedIndicator = "finished"
         if version >= 2:
             startDateStr = self.readStr()
             endDateStr = self.readStr()
             completedIndicator += "-" + startDateStr + "-" + endDateStr
         itemCount = self.readInt()
         ctr = 0
         while ctr < itemCount:
             date = self.readStr()
             open = self.readDouble()
             high = self.readDouble()
             low = self.readDouble()
             close = self.readDouble()
             volume = self.readInt()
             WAP = self.readDouble()
             hasGaps = self.readStr()
             barCount = -1
             if version >= 3:
                 barCount = self.readInt()
             self.eWrapper().historicalData(
                 reqId, date, open, high, low, close, volume, barCount, WAP,
                 Boolean.valueOf(hasGaps).booleanValue())
             ctr += 1
         #  send end of dataset marker
         self.eWrapper().historicalData(reqId, completedIndicator, -1, -1,
                                        -1, -1, -1, -1, -1, False)
     elif msgId == self.SCANNER_PARAMETERS:
         version = self.readInt()
         xml = self.readStr()
         self.eWrapper().scannerParameters(xml)
     elif msgId == self.CURRENT_TIME:
         # int version =
         self.readInt()
         time = self.readLong()
         self.eWrapper().currentTime(time)
     elif msgId == self.REAL_TIME_BARS:
         # int version =
         self.readInt()
         reqId = self.readInt()
         time = self.readLong()
         open = self.readDouble()
         high = self.readDouble()
         low = self.readDouble()
         close = self.readDouble()
         volume = self.readLong()
         wap = self.readDouble()
         count = self.readInt()
         self.eWrapper().realtimeBar(reqId, time, open, high, low, close,
                                     volume, wap, count)
     elif msgId == self.FUNDAMENTAL_DATA:
         # int version =
         self.readInt()
         reqId = self.readInt()
         data = self.readStr()
         self.eWrapper().fundamentalData(reqId, data)
     elif msgId == self.CONTRACT_DATA_END:
         # int version =
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().contractDetailsEnd(reqId)
     elif msgId == self.OPEN_ORDER_END:
         # int version =
         self.readInt()
         self.eWrapper().openOrderEnd()
     elif msgId == self.ACCT_DOWNLOAD_END:
         # int version =
         self.readInt()
         accountName = self.readStr()
         self.eWrapper().accountDownloadEnd(accountName)
     elif msgId == self.EXECUTION_DATA_END:
         # int version =
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().execDetailsEnd(reqId)
     elif msgId == self.DELTA_NEUTRAL_VALIDATION:
         # int version =
         self.readInt()
         reqId = self.readInt()
         underComp = UnderComp()
         underComp.m_conId = self.readInt()
         underComp.m_delta = self.readDouble()
         underComp.m_price = self.readDouble()
         self.eWrapper().deltaNeutralValidation(reqId, underComp)
     elif msgId == self.TICK_SNAPSHOT_END:
         # int version =
         self.readInt()
         reqId = self.readInt()
         self.eWrapper().tickSnapshotEnd(reqId)
     elif msgId == self.MARKET_DATA_TYPE:
         # int version =
         self.readInt()
         reqId = self.readInt()
         marketDataType = self.readInt()
         self.eWrapper().marketDataType(reqId, marketDataType)
     elif msgId == self.COMMISSION_REPORT:
         # int version =
         self.readInt()
         commissionReport = CommissionReport()
         commissionReport.m_execId = self.readStr()
         commissionReport.m_commission = self.readDouble()
         commissionReport.m_currency = self.readStr()
         commissionReport.m_realizedPNL = self.readDouble()
         commissionReport.m_yield = self.readDouble()
         commissionReport.m_yieldRedemptionDate = self.readInt()
         self.eWrapper().commissionReport(commissionReport)
     else:
         self.m_parent.error(EClientErrors.NO_VALID_ID,
                             EClientErrors.UNKNOWN_ID.code(),
                             EClientErrors.UNKNOWN_ID.msg())
         return False
     return True
Exemplo n.º 18
0
 def __eq__(self, p_other):
     """ generated source for method equals """
     if self == p_other:
         return True
     if p_other == None or not (isinstance(p_other, (Contract, ))):
         return False
     l_theOther = p_other
     if self.m_conId != l_theOther.m_conId:
         return False
     if Util.StringCompare(self.m_secType, l_theOther.m_secType) != 0:
         return False
     if Util.StringCompare(
             self.m_symbol, l_theOther.m_symbol) != 0 or Util.StringCompare(
                 self.m_exchange,
                 l_theOther.m_exchange) != 0 or Util.StringCompare(
                     self.m_primaryExch,
                     l_theOther.m_primaryExch) != 0 or Util.StringCompare(
                         self.m_currency, l_theOther.m_currency) != 0:
         return False
     if not Util.NormalizeString(self.m_secType) == "BOND":
         if self.m_strike != l_theOther.m_strike:
             return False
         if Util.StringCompare(
                 self.m_expiry,
                 l_theOther.m_expiry) != 0 or Util.StringCompare(
                     self.m_right,
                     l_theOther.m_right) != 0 or Util.StringCompare(
                         self.m_multiplier, l_theOther.m_multiplier
                     ) != 0 or Util.StringCompare(
                         self.m_localSymbol, l_theOther.m_localSymbol) != 0:
             return False
     if Util.StringCompare(self.m_secIdType, l_theOther.m_secIdType) != 0:
         return False
     if Util.StringCompare(self.m_secId, l_theOther.m_secId) != 0:
         return False
     #  compare combo legs
     if not Util.VectorEqualsUnordered(self.m_comboLegs,
                                       l_theOther.m_comboLegs):
         return False
     if self.m_underComp != l_theOther.m_underComp:
         if self.m_underComp == None or l_theOther.m_underComp == None:
             return False
         if not self.m_underComp == l_theOther.m_underComp:
             return False
     return True
Exemplo n.º 19
0
    def __eq__(self, p_other):
        if self is p_other:
            return True
        if p_other is None or not isinstance(p_other, (Contract)):
            return False
        l_theOther = p_other
        if (self.m_conId != l_theOther.m_conId):
            return False

        if self.m_comboLegs and l_theOther.comboLegsSize and len(
                self.m_comboLegs) != len(l_theOther.m_comboLegs):
            return False
        elif self.m_comboLegs or self.m_comboLegs:
            return False

        if (Util.StringCompare(self.m_secType, l_theOther.m_secType) != 0):
            return False
        if (Util.StringCompare(self.m_symbol, l_theOther.m_symbol) != 0) or (
                Util.StringCompare(self.m_exchange, l_theOther.m_exchange) != 0
        ) or (Util.StringCompare(self.m_primaryExch, l_theOther.m_primaryExch)
              != 0) or (Util.StringCompare(self.m_currency,
                                           l_theOther.m_currency) != 0):
            return False
        if not Util.NormalizeString(self.m_secType) == "BOND":
            if (self.m_strike != l_theOther.m_strike):
                return False
            if (Util.StringCompare(self.m_expiry, l_theOther.m_expiry) !=
                    0) or (Util.StringCompare(self.m_right, l_theOther.m_right)
                           != 0) or (Util.StringCompare(
                               self.m_multiplier, l_theOther.m_multiplier) !=
                                     0) or (Util.StringCompare(
                                         self.m_localSymbol,
                                         l_theOther.m_localSymbol) != 0):
                return False
        if self.m_comboLegs and len(self.m_comboLegs) > 0:
            comboLegsSize = len(self.m_comboLegs)
            alreadyMatchedSecondLeg = [
                bool() for __idx0 in range(comboLegsSize)
            ]
            ## for-while
            ctr1 = 0
            while ctr1 < comboLegsSize:
                l_thisComboLeg = self.m_comboLegs[ctr1]
                ctr2 = 0
                ## for-while
                while ctr2 < comboLegsSize:
                    if alreadyMatchedSecondLeg[ctr2]:
                        continue
                    if l_thisComboLeg == l_theOther.m_comboLegs[ctr2]:
                        alreadyMatchedSecondLeg[ctr2] = True
                        break
                    ctr2 += 1
                if ctr2 >= comboLegsSize:
                    return False
                ctr1 += 1
        if (self.m_underComp != l_theOther.m_underComp):
            if self.m_underComp is None or l_theOther.m_underComp is None:
                return False
            if not self.m_underComp == l_theOther.m_underComp:
                return False
        return True