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


Python Order.m_orderId方法代码示例

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


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

示例1: createOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def createOrder(orderId,shares,limit = None, transmit=0):
    ''' 
    create order object 
 
    Parameters
    -----------
    orderId : The order Id. You must specify a unique value. 
              When the order status returns, it will be identified by this tag. 
              This tag is also used when canceling the order.
 
    shares: number of shares to buy or sell. Negative for sell order.  
    limit : price limit, None for MKT order
    transmit: transmit immideatelly from tws
    '''
 
    action = {-1:'SELL',1:'BUY'}    
 
    o = Order()
 
    o.m_orderId = orderId
    o.m_action = action[sign(shares)]
    o.m_totalQuantity = abs(shares)
    o.m_transmit = transmit
 
    if limit is not None:
        o.m_orderType = 'LMT'
        o.m_lmtPrice = limit
    else:
        o.m_orderType = 'MKT'
 
    return o    
开发者ID:aborodya,项目名称:trading-with-python,代码行数:33,代码来源:ib_placeOrder.py

示例2: sendOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
 def sendOrder(self, orderReq):
     """发单"""
     # 增加报单号1,最后再次进行查询
     # 这里双重设计的目的是为了防止某些情况下,连续发单时,nextOrderId的回调推送速度慢导致没有更新
     self.orderId += 1
     
     # 创建合约对象
     contract = Contract()
     contract.m_symbol = str(orderReq.symbol)
     contract.m_exchange = exchangeMap.get(orderReq.exchange, '')
     contract.m_secType = productClassMap.get(orderReq.productClass, '')
     contract.m_currency = currencyMap.get(orderReq.currency, '')
     
     contract.m_expiry = orderReq.expiry
     contract.m_strike = orderReq.strikePrice
     contract.m_right = optionTypeMap.get(orderReq.optionType, '')
     
     # 创建委托对象
     order = Order()
     order.m_orderId = self.orderId
     order.m_clientId = self.clientId
     
     order.m_action = directionMap.get(orderReq.direction, '')
     order.m_lmtPrice = orderReq.price
     order.m_totalQuantity = orderReq.volume
     order.m_orderType = priceTypeMap.get(orderReq.priceType, '')
     
     # 发送委托
     self.connection.placeOrder(self.orderId, contract, order)
     
     # 查询下一个有效编号
     self.connection.reqIds(1)
开发者ID:Allen1203,项目名称:vnpy,代码行数:34,代码来源:ibGateway.py

示例3: placeOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
    def placeOrder(self, symbol, shares, limit=None, exchange='SMART', transmit=0):
        """ place an order on already subscribed contract """


        if symbol not in self.contracts.keys():
            self.log.error("Can't place order, not subscribed to %s" % symbol)
            return


        action = {-1: 'SELL', 1: 'BUY'}


        o = Order()
        o.m_orderId = self.getOrderId()
        o.m_action = action[cmp(shares, 0)]
        o.m_totalQuantity = abs(shares)
        o.m_transmit = transmit


        if limit is not None:
            o.m_orderType = 'LMT'
            o.m_lmtPrice = limit


        self.log.debug('Placing %s order for %i %s (id=%i)' % (o.m_action, o.m_totalQuantity, symbol, o.m_orderId))

        self.tws.placeOrder(o.m_orderId, self.contracts[symbol], o)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:29,代码来源:new+apidataget+longone.py

示例4: makeOptOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def makeOptOrder(action, orderID, tif, orderType):
    newOptOrder = Order()
    newOptOrder.m_orderId = orderID
    newOptOrder.m_clientId = 0
    newOptOrder.m_permid = 0
    newOptOrder.m_action = action
    newOptOrder.m_lmtPrice = 0
    newOptOrder.m_auxPrice = 0
    newOptOrder.m_tif = tif
    newOptOrder.m_transmit = False
    newOptOrder.m_orderType = orderType
    newOptOrder.m_totalQuantity = 1
    return newOptOrder
开发者ID:Jicheng-Yan,项目名称:ib-py,代码行数:15,代码来源:option_order_data.py

示例5: makeFutOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def makeFutOrder(type, action, orderId=-99, price=None):
    order = Order()
    order.m_orderId = orderId
    order.m_clientId = 0
    order.m_permid = 0
    order.m_orderType = type
    order.m_action = action
    order.m_minQty = 1
    order.m_totalQuantity = 1
    # order.m_transmit = False
    if type == 'LMT':
        order.m_lmtPrice = price
    if action == 'SELL':
        pass

    return order
开发者ID:lightme16,项目名称:ibpy_work,代码行数:18,代码来源:working_prototype.py

示例6: newOrder_GUI

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def newOrder_GUI(action, orderID, quantity,startTime):
    global trade_params
    
    newStkOrder = Order()
    print orderID, action, trade_params['OrderTIF'],trade_params['OrderType'],quantity,trade_params['Account'],startTime
    newStkOrder.m_orderId = orderID
    
    newStkOrder.m_action = action
    newStkOrder.m_tif = 'DAY'
    newStkOrder.m_transmit = True
    newStkOrder.m_orderType = 'MKT'
    newStkOrder.m_totalQuantity = quantity
    newStkOrder.m_account = 'DU164541'
    newStkOrder.m_goodAfterTime = startTime
    #newStkOrder.m_goodAfterTime=endTime
    return newStkOrder
开发者ID:jc3939,项目名称:My-Work-During-Internship,代码行数:18,代码来源:IB_GUI.py

示例7: addmktorder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def addmktorder(cid, action, qty):
    id = len(orders)
    o = Order()
    o.m_orderId = id
    o.m_clientId = 0
    o.m_permid = 0
    o.m_action = action
    o.m_lmtPrice = 0
    o.m_auxPrice = 0
    o.m_tif = 'DAY'
    o.m_orderType = 'MKT'
    o.m_totalQuantity = qty
    o.m_transmit = True
    orders.append([o, cid, qty, id])        
    con.placeOrder(id, contracts[cid], o)
    position(cid)
    pending(cid)
开发者ID:dm04806,项目名称:systemn,代码行数:19,代码来源:test.py

示例8: addlmtorder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def addlmtorder(cid, action, price, qty):
    id = len(orders)
    o = Order()
    o.m_orderId = id
    o.m_action = action
    o.m_orderType = 'LMT'
    o.m_tif = 'DAY'
    o.m_totalQuantity = qty

    o.m_clientId = 0
    o.m_permId = 0
    o.m_lmtPrice = float(round(price,2))
    #o.m_auxPrice = float(price)

    orders.append([o, cid, qty, id])        
    con.placeOrder(id, contracts[cid], o)
    position(cid)
    pending(cid)
开发者ID:dm04806,项目名称:systemn,代码行数:20,代码来源:test.py

示例9: create_stock_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
def create_stock_order(order_id, quantity, is_buy, price=None, stop_price=None):
    order = Order()

    order.m_outsideRth = True
    order.m_orderId = order_id
    order.m_totalQuantity = quantity
    order.m_action = DataType.ORDER_ACTION_BUY if is_buy else DataType.ORDER_ACTION_SELL

    if price is None:
        order.m_orderType = DataType.ORDER_TYPE_MARKET
    else:
        order.m_lmtPrice = price
        order.m_orderType = DataType.ORDER_TYPE_LIMIT

        if stop_price is not None:
            order.m_auxPrice = stop_price
            order.m_orderType = DataType.ORDER_TYPE_STOP_LIMIT

    return order
开发者ID:JulesTan,项目名称:IB-Trading-Models-And-Backtester,代码行数:21,代码来源:ibUtil.py

示例10: placeOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
 def placeOrder(self,contract, shares,limit = None, transmit=0):
     ''' 
     create order object 
  
     Parameters
     -----------
     
     shares: number of shares to buy or sell. Negative for sell order.  
     limit : price limit, None for MKT order
     transmit: transmit immideatelly from tws
     
     Returns: 
     -----------
     orderId : The order Id. You must specify a unique value. 
               When the order status returns, it will be identified by this tag. 
               This tag is also used when canceling the order.
  
     
     '''
  
     action = {-1:'SELL',1:'BUY'}  
     
     
     orderId = self.nextValidOrderId
     self.nextValidOrderId += 1 # increment  
     
     o = Order()
     o.m_orderId = orderId
     o.m_action = action[cmp(shares,0)]
     o.m_totalQuantity = abs(shares)
     o.m_transmit = transmit
  
     if limit is not None:
         o.m_orderType = 'LMT'
         o.m_lmtPrice = limit
     else:
         o.m_orderType = 'MKT'
  
     # place order
     self.tws.placeOrder(orderId, contract, o) # place order     
  
  
     return orderId
开发者ID:Kevin-Prichard,项目名称:trading-with-python,代码行数:45,代码来源:handlers.py

示例11: makeOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderId [as 别名]
    def makeOrder(self, action, orderId, tif, orderType, price, transmit, parentId):
        newOrder = Order()
        newOrder.m_orderId = orderId
        newOrder.m_transmit = transmit
        newOrder.m_lmtPrice = price
        newOrder.m_tif = tif
        newOrder.m_action = action
        newOrder.m_orderType = orderType
        if parentId is not None:
            newOrder.m_parentId = parentId

        newOrder.m_hidden = False
        newOrder.m_outsideRth = True
        newOrder.m_clientId = 999
        newOrder.m_permid = 0
        if orderType == 'LMT':
            newOrder.m_auxPrice = 0
        elif orderType == 'STP' or orderType == 'MIT':
            newOrder.m_auxPrice = price
        newOrder.m_totalQuantity = 1
        
        return newOrder
开发者ID:chicagohawk,项目名称:TwitterAutoTrade,代码行数:24,代码来源:iblib.py

示例12: processMsg

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

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


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