当前位置: 首页>>代码示例>>Python>>正文


Python Order.m_algoStrategy方法代码示例

本文整理汇总了Python中ib.ext.Order.Order.m_algoStrategy方法的典型用法代码示例。如果您正苦于以下问题:Python Order.m_algoStrategy方法的具体用法?Python Order.m_algoStrategy怎么用?Python Order.m_algoStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ib.ext.Order.Order的用法示例。


在下文中一共展示了Order.m_algoStrategy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: place_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_algoStrategy [as 别名]
    def place_order(self, instrument, expiry, quantity, acc=None):
        """
        Send API request to place an order on the exchange.
        :param instrument: core.instrument.Instrument object
        :param expiry: contract label
        :param quantity: order size as a signed integer (quantity > 0 means 'BUY'
                         and quantity < 0 means 'SELL')
        :param acc: IB account to place order from, if None - the default account will be used
        """
        contract = Contract()
        contract.m_symbol = instrument.ib_code
        contract.m_secType = 'FUT'
        # place_order expects the contract label here, not the actual expiration date
        contract.m_expiry = expiry
        contract.m_exchange = instrument.exchange
        contract.m_currency = instrument.denomination
        if hasattr(instrument, 'ib_trading_class'):
            contract.m_tradingClass = instrument.ib_trading_class
        if hasattr(instrument, 'ib_multiplier'):
            contract.m_multiplier = instrument.ib_multiplier

        order = Order()
        order.m_orderType = 'MKT'
        order.m_algoStrategy = 'Adaptive'
        order.m_algoParams = [TagValue('adaptivePriority', 'Patient')]
        order.m_totalQuantity = int(abs(quantity))
        order.m_action = quantity > 0 and 'BUY' or 'SELL'
        if acc is not None:
            order.m_account = acc.name
            self.last_account = acc
        logger.warning(
            ' '.join(['Order:', str(self.order_id), contract.m_symbol, contract.m_expiry, \
                      order.m_action, str(order.m_totalQuantity)]))
        self.connection.placeOrder(self.order_id, contract, order)
        self.orders_cache[self.order_id] = {'contract': contract,
                                            'order': order}
        # order_id may not update just after the order is submitted so we save the previous one and
        # keep requesting until it's updated or we hit the time/iterations limit
        prev_id = self.order_id
        i = 0
        while prev_id >= self.order_id:
            sleep(self.api_delay)
            i += 1
            logger.debug('Requesting next order_id..')
            self.connection.reqIds(1)
            self.next_id_event.wait(timeout=(self.api_delay * 30))
            self.next_id_event.clear()
            if i > 60:
                logger.warning("Couldn't obtain next valid order id. Next orders may not be"
                               "submitted correctly!")
                return
开发者ID:renc,项目名称:PyTrendFollow,代码行数:53,代码来源:ibstate.py

示例2: processMsg

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_algoStrategy [as 别名]

#.........这里部分代码省略.........
                 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 = list()
                     ## for-while
                     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()
开发者ID:Jicheng-Yan,项目名称:ib-py,代码行数:70,代码来源:EReader.py


注:本文中的ib.ext.Order.Order.m_algoStrategy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。