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


Python Order.m_openClose方法代码示例

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


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

示例1: close

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

示例2: order

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

示例3: addmktorder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_openClose [as 别名]
	def addmktorder(self, action, qty, oc, cid, tif = "DAY"):
		o = Order()
		o.m_action = action
		print tif
		o.m_tif = tif
		o.m_orderType = 'MKT'
		o.m_totalQuantity = qty
		o.m_openClose = oc
		res = self.placeOrder(cid, o)
		return(res)
开发者ID:dm04806,项目名称:systemn,代码行数:12,代码来源:server.py

示例4: addlmtorder

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_openClose [as 别名]
	def addlmtorder(self, action, qty, oc, price, cid, tif = "DAY", date = ""):
		o = Order()
		o.m_action = action
		#print tif
		o.m_tif = tif
		o.m_orderType = 'LMT'
		o.m_totalQuantity = qty
		o.m_openClose = oc
		o.m_lmtPrice = float(round(price,2))
		o.m_goodTillDate = date
		res = self.placeOrder(cid, o)
		return(res)
开发者ID:dm04806,项目名称:systemn,代码行数:14,代码来源:server.py

示例5: processMsg

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

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

示例6: Contract

# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_openClose [as 别名]
o = Pyro.core.getProxyForURI("PYRONAME://serverInterface")



c = Contract()
c.m_symbol = "GS"
c.m_secType = 'STK'
c.m_exchange = "SMART"
c.m_currency = "USD"

order1 = Order()
order1.m_action = "BUY"
order1.m_tif = "DAY"
order1.m_orderType = 'LMT'
order1.m_totalQuantity = 100
order1.m_openClose = "O"
order1.m_lmtPrice = float(round(120,2))

order2 = Order()
order2.m_action = "BUY"
order2.m_tif = "DAY"
order2.m_orderType = 'LMT'
order2.m_totalQuantity = 100
order2.m_openClose = "O"
order2.m_lmtPrice = float(round(130,2))

oid1 = o.placeOrder(c, order2, None)
print "orderId1: " + str(oid1)

oid2 = o.placeOrder(c, order1, timedelta(seconds=3))
print "orderId2: " + str(oid2)
开发者ID:dm04806,项目名称:systemn,代码行数:33,代码来源:test2.py


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