本文整理汇总了Python中ib.ext.Order.Order.m_account方法的典型用法代码示例。如果您正苦于以下问题:Python Order.m_account方法的具体用法?Python Order.m_account怎么用?Python Order.m_account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ib.ext.Order.Order
的用法示例。
在下文中一共展示了Order.m_account方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mkOrder
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [as 别名]
def mkOrder(id,shares, limit=None, account='',transmit=0, tif = 'DAY'):
'''
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 = id
o.m_account=account
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'
return o
示例2: create_order
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [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
示例3: placeOrder
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [as 别名]
def placeOrder(self,symbol,shares,limit=None,account='U8830832',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_account = account
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)
示例4: makeStkOrder
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [as 别名]
def makeStkOrder(shares,action,account,ordertype='MKT'):
order = Order()
order.m_minQty = shares
order.m_orderType = ordertype
order.m_totalQuantity = shares
order.m_action = str(action).upper()
order.m_outsideRth = True #allow order to be filled ourside regular trading hours
order.m_account = account
return order
示例5: create_order
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [as 别名]
def create_order(self, order_type, quantity, action):
"""Create an Order object (Market/Limit) to go long/short.
order_type - 'MKT', 'LMT' for Market or Limit orders
quantity - Integral number of assets to order
action - 'BUY' or 'SELL'"""
order = Order()
order.m_orderType = order_type
order.m_totalQuantity = quantity
order.m_action = action
order.m_account = self.current_account
return order
示例6: place_order
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [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
示例7: newOrder_GUI
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [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
示例8: processMsg
# 需要导入模块: from ib.ext.Order import Order [as 别名]
# 或者: from ib.ext.Order.Order import m_account [as 别名]
#.........这里部分代码省略.........
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()
if (self.m_parent.serverVersion() == 51):
self.readInt()