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


Python Order.m_orderType方法代码示例

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


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

示例1: create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
def create_order(order_type, quantity, limit_price=None):
    """
    Creates an (ib.ext.Order) object to send to IB
    :param order_type: (string) "MARKET" or "LIMIT"
    :param quantity: (int)
    :return: (ib.ext.Order)
    """
    order = Order()
    if order_type is "MARKET":
        order.m_orderType = "MKT"
    elif order_type is "LIMIT":
        order.m_orderType = "LMT"
        order.m_lmtPrice = limit_price
    assert(order.m_orderType is not None), "Invalid order_type!"

    if quantity == 0:
        raise Exception('Order quantity is 0!')
    elif quantity > 0:
        order.m_action = "BUY"
    elif quantity < 0:
        order.m_action = "SELL"
    assert(order.m_action is not None), "Invalid order action!"
    order.m_totalQuantity = abs(quantity)
    assert(abs(order.m_totalQuantity) > 0), "Invalid order quantity!"

    return order
开发者ID:EdwardBetts,项目名称:backtester,代码行数:28,代码来源:ib_execution_handler.py

示例2: createOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [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

示例3: create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
def create_order(action, quantity, price=None):
    order = Order()
    order.m_action = action
    order.m_totalQuantity = quantity
    if price is not None:
        order.m_orderType = 'LMT'
        order.m_lmtPrice = price
    else:
        order.m_orderType = 'MKT'
    return order
开发者ID:gongqingyi,项目名称:stock,代码行数:12,代码来源:common.py

示例4: order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
    def order(self, sid, amount, limit_price, stop_price, order_id=None):
        id = super(LiveBlotter, self).order(sid, amount, limit_price, stop_price, order_id=None)
        order_obj = self.orders[id]

        ib_order = IBOrder()
        ib_order.m_transmit = True
        ib_order.m_orderRef = order_obj.id
        ib_order.m_totalQuantity = order_obj.amount
        ib_order.m_action = ["BUY" if ib_order.m_totalQuantity > 0 else "SELL"][0]
        ib_order.m_tif = "DAY"
        # Todo: make the FA params configurable
        ib_order.m_faGroup = "ALL"
        ib_order.m_faMethod = "AvailableEquity"

        # infer order type
        if order_obj.stop and not order_obj.limit:
            ib_order.m_orderType = "STP"
            ib_order.m_auxPrice = float(order_obj.stop)

        elif order_obj.limit and not order_obj.stop:
            ib_order.m_orderType = "LMT"
            ib_order.m_lmtPrice = float(order_obj.limit)

        elif order_obj.stop and order_obj.limit:
            ib_order.m_orderType = "STPLMT"
            ib_order.m_auxPrice = float(order_obj.stop)
            ib_order.m_lmtPrice = float(order_obj.limit)

        else:
            ib_order.m_orderType = "MKT"

        contract = Contract()
        contract.m_symbol = order_obj.sid
        contract.m_currency = "USD"

        if hasattr(order_obj, "contract"):
            # This is a futures contract
            contract.m_secType = "FUT"
            contract.m_exchange = "GLOBEX"
            contract.m_expiry = order_obj.contract

        else:
            # This is a stock
            contract.m_secType = "STK"
            contract.m_exchange = "SMART"

        ib_id = self.place_order(contract, ib_order)
        self.id_map[order_obj.id] = ib_id

        return order_obj.id
开发者ID:martinkirov,项目名称:AlephNull,代码行数:52,代码来源:broker.py

示例5: close

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
            def close(orderty = "MKT", price = None, timeout = None):
                position = self["position"]
                order = Order()
                if position > 0:
                    order.m_action = "SELL"
                else:
                    order.m_action = "BUY"
                order.m_tif = "DAY"
                order.m_orderType = orderty
                order.m_totalQuantity = abs(position)
                order.m_openClose = "C"
                if price <> None: order.m_lmtPrice = price

                if price == None and orderty <> "MKT": order.m_lmtPrice = self.best_price(position)
                
                if timeout == None:
                    oid = self.con.placeOrder(self.contract, order, None)
                    self.oids.append(oid)
                    return oid
                else:
                    oid = self.con.placeOrder(self.contract, order, timedelta(seconds=timeout))
                    if oid == None:
                        return None
                    else:
                        self.oids.append(oid)
                        return oid
开发者ID:dm04806,项目名称:systemn,代码行数:28,代码来源:contract.py

示例6: make_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
def make_order(action, quantity, price = None):
    if price is not None:
        order = Order()
        order.m_orderType = 'LMY'
        order.m_totalQuantity = quantity
        order.m_action = action
        order.m_lmtPrice = price
        
    else:
        order = Order()
        order.m_orderType = 'MKT'
        order.m_totalQuantity = quantity
        order.m_action = action
       
       
    return order
开发者ID:derifo,项目名称:AlgoTrading,代码行数:18,代码来源:OrderCreationPython.py

示例7: create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
def create_order(order_type, quantity, action, limitprice, transmitf, auxprice, stopprice, rptype):
    order = Order()
    order.m_action = action
    order.m_totalQuantity = quantity
    order.m_transmit = transmitf
    order.m_orderType = order_type
    if order_type == 'LMT':
        order.m_lmtPrice = limitprice
        pass
    elif order_type  == 'STP':
        order.m_stpPrice = stopprice
        pass
    else:
        print'failing on price...need one'
    return order
#####################
##if ordernumx == 'filled':
##    launch profittake and stopbracket with ocaGroup
##reqIds()
##orderStatus()
##ParentID
##ocaType
##ocaGroup
###############################
##datahandler for snapshots
##reqmktdata live data
##req live recent bars
##PlaceOrder(entryorder)
##if entryorder filled:
##    PlaceOrder(profitorder)
##    get orderid
##    PlaceOrder(profitorder by number, transmit)
##    PlaceOrder(stopbracket) # with transmit true 
    '''
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:36,代码来源:ibutiles+TESTLIVE+pauser.py

示例8: create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
 def create_order(self, account, orderType, totalQuantity, action):
     order = Order()
     order.m_account = account
     order.m_orderType = orderType
     order.m_totalQuantity = totalQuantity
     order.m_action = action
     return order
开发者ID:anthonyng2,项目名称:ib,代码行数:9,代码来源:IBWrapper.py

示例9: placeOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [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

示例10: sendOrder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [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

示例11: order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
            def order(position = "BUY", orderty = "MKT", quantity = 100, price = None, timeout = None, openClose = "O"):
                order = Order()
                order.m_action = position
                order.m_tif = "DAY"
                order.m_orderType = orderty
                order.m_totalQuantity = quantity
                order.m_openClose = openClose
                if price <> None: order.m_lmtPrice = price

                if position == "BUY":
                    pos = quantity
                else:
                    pos = -quantity

                if price == None and orderty <> "MKT": order.m_lmtPrice = self.best_price(pos)
                
                if timeout == None:
                    oid = self.con.placeOrder(self.contract, order, None)
                    self.oids.append(oid)
                    
                    return oid
                else:
                    oid = self.con.placeOrder(self.contract, order, timedelta(seconds=timeout))
                    if oid == None:
                        return None
                    else:
                        self.oids.append(oid)
                        return oid
开发者ID:dm04806,项目名称:systemn,代码行数:30,代码来源:contract.py

示例12: order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
    def order(self, asset, amount, style):
        contract = Contract()
        contract.m_symbol = str(asset.symbol)
        contract.m_currency = self.currency
        contract.m_exchange = symbol_to_exchange[str(asset.symbol)]
        contract.m_secType = symbol_to_sec_type[str(asset.symbol)]

        order = Order()
        order.m_totalQuantity = int(fabs(amount))
        order.m_action = "BUY" if amount > 0 else "SELL"

        is_buy = (amount > 0)
        order.m_lmtPrice = style.get_limit_price(is_buy) or 0
        order.m_auxPrice = style.get_stop_price(is_buy) or 0

        if isinstance(style, MarketOrder):
            order.m_orderType = "MKT"
        elif isinstance(style, LimitOrder):
            order.m_orderType = "LMT"
        elif isinstance(style, StopOrder):
            order.m_orderType = "STP"
        elif isinstance(style, StopLimitOrder):
            order.m_orderType = "STP LMT"

        order.m_tif = "DAY"
        order.m_orderRef = self._create_order_ref(order)

        ib_order_id = self._tws.next_order_id
        zp_order = self._get_or_create_zp_order(ib_order_id, order, contract)

        log.info(
            "Placing order-{order_id}: "
            "{action} {qty} {symbol} with {order_type} order. "
            "limit_price={limit_price} stop_price={stop_price} {tif}".format(
                order_id=ib_order_id,
                action=order.m_action,
                qty=order.m_totalQuantity,
                symbol=contract.m_symbol,
                order_type=order.m_orderType,
                limit_price=order.m_lmtPrice,
                stop_price=order.m_auxPrice,
                tif=order.m_tif
            ))

        self._tws.placeOrder(ib_order_id, contract, order)

        return zp_order
开发者ID:florentchandelier,项目名称:zipline,代码行数:49,代码来源:ib_broker.py

示例13: _create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
 def _create_order(action, qty, order_type, limit_price, stop_price):
     order = Order()
     order.m_action = action
     order.m_totalQuantity = qty
     order.m_auxPrice = stop_price
     order.m_lmtPrice = limit_price
     order.m_orderType = order_type
     return order
开发者ID:huangzhengyong,项目名称:zipline,代码行数:10,代码来源:test_live.py

示例14: create_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
 def create_order(self, order_type, quantity, action):
     """ Create an Order Object to pair with the Contract Object
     """
     order = Order()
     order.m_orderType = order_type # 'MKT'/'LMT'
     order.m_totalQuantity = quantity # Integer
     order.m_action = action # 'BUY'/'SELL'
     return order
开发者ID:danbob123,项目名称:pythonSystemDev,代码行数:10,代码来源:ib_execution.py

示例15: make_order

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_orderType [as 别名]
def make_order(limit_price):
    order = Order()
    order.m_minQty = 100
    order.m_lmtPrice = limit_price
    order.m_orderType = 'MKT'
    order.m_totalQuantity = 100
    order.m_action = 'BUY'
    return order
开发者ID:TimonPeng,项目名称:pi314,代码行数:10,代码来源:api_coverage.py


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