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


Python Contract.m_secType方法代码示例

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


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

示例1: inner

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
    def inner():

        #con.reqAccountUpdates(1, '')
        qqqq = Contract()
        qqqq.m_symbol = 'QQQ'
        qqqq.m_secType = 'STK'
        qqqq.m_exchange = 'SMART'

        contract = Contract() #
        contract.m_symbol = 'AUD'
        contract.m_currency = 'USD'
        contract.m_secType = 'CASH'
        contract.m_exchange = 'IDEALPRO'

        fut = Contract() #
        fut.m_localSymbol = 'CLM6'
        #fut.m_symbol = 'CL'
        fut.m_currency = 'USD'
        fut.m_secType = 'FUT'
        fut.m_exchange = 'NYMEX'
        #fut.m_expiry = '201606'
        #fut.m_multiplier = '1000'

        #con.reqMktData(1, qqqq, '', False)
        #con.reqMktData(1, contract, '', False)
        con.reqMktData(1, fut, '', False)
开发者ID:border,项目名称:quantway,代码行数:28,代码来源:mktData.py

示例2: order

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

示例3: inner

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
 def inner():
     con.reqAccountUpdates(1, '')
     qqqq = Contract()
     qqqq.m_symbol = 'QQQQ'
     qqqq.m_secType = 'STK'
     qqqq.m_exchange = 'SMART'
     con.reqMktData(1, qqqq, '', False)
开发者ID:TimonPeng,项目名称:pi314,代码行数:9,代码来源:filters.py

示例4: sendOrder

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

示例5: addfutur

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def addfutur(ticker, exchg, expiry):
    c = Contract()
    c.m_symbol = ticker
    c.m_secType = 'FUT'
    c.m_exchange = exchg
    c.m_expiry = expiry
    addcontract(c, "Fut(" + exchg + ", " + expiry + ")")
开发者ID:dm04806,项目名称:systemn,代码行数:9,代码来源:test.py

示例6: generate_spx

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
    def generate_spx(self, symbol="SPX", exchange="SMART", currency="USD", \
                                            secType="OPT", expiry="20151023",
                                            strikep=None):
        """ Function to resemble a main function """
        # Establish a connection
        sys.stdout.write("\nCalling connection\n")
        connection = ibConnection()
        connection.registerAll(self.ibhndl.my_callback_handler)
        connection.connect()

        # Get contract details
        contract_values = Contract()
        contract_values.m_symbol = symbol
        contract_values.m_exchange = exchange
        contract_values.m_currency = currency
        contract_values.m_secType = secType
        contract_values.m_expiry = expiry
        
        if strikep:
            contract_values.m_strike = strikep

        self.ibhndl.get_contract_details(connection, 1, contract_values)

        # Get Market values
        self.ibhndl.get_market_data(connection)

        if not os.path.isdir(os.path.join('.', 'spx_files')):
            os.makedirs('spx_files')

        mydir = os.path.join(os.getcwd(), 'spx_files', \
                         datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
        os.makedirs(mydir)

        OPTIONS.to_csv(os.path.join(mydir, 'Options.csv'))
        sys.stdout.write("\n\n")
开发者ID:LumbaJack,项目名称:Plan-Visualizer,代码行数:37,代码来源:interactivebroker.py

示例7: request_market_data

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
    def request_market_data(self, timeframe, interval, symbol, sectype, \
                                        exchange, currency=None, expiry=None, \
                                        primexch=None, latestdate=None):
        # Establish a connection
        sys.stdout.write("\nCalling connection\n")
        connection = ibConnection()
        connection.register(self.ibhndl.my_callback_handler, \
                                                        message.historicalData)
        connection.connect()
 
        #Contract
        contract = Contract()
        contract.m_symbol = symbol
        contract.m_secType = sectype
        contract.m_exchange = exchange
        contract.m_currency = currency
 
        if primexch:
            contract.m_primaryExch = primexch
 
        if expiry:
            contract.m_expiry = expiry
 
        # Get historical data
        rtnData = self.ibhndl.reqHistoricalData(contract, interval, connection,\
                                                        timeframe, latestdate)
        connection.disconnect()
 
        if not rtnData[0]:
            sys.stderr.write("ERROR: No data return for %s : %s\n" % (symbol,\
                                                                    interval)) 
            return rtnData, ""

        dateList = list()
        stockFile = list()
        for data, volume in zip(rtnData[0], rtnData[1]):
            dateList = dateList + [data[0]]
            dataStr = '%s, %s, %s, %s, %s, %s' % \
                        (strftime("%Y-%m-%d %H:%M:%S", \
                              localtime(int(str(data[0]))/1000)), data[1], \
                              data[2], data[3], data[4], str(volume[1]))
        
            stockFile = stockFile + [dataStr]
        
        convertStr = '%Y-%m-%d %H:%M:%S'
        date, _, _, _, closep, volume = \
                        np.loadtxt(stockFile, delimiter=',', unpack=True, \
                       converters={0:mdates.strpdate2num(convertStr)})
        
        #PATTERNS
        retpat = []
        try:
            patterndb = PatternDB()
            patterndb.add(HS())
            patterndb.add(IHS())
        
            retpat = patterndb.check(closep[-60:], date[-60:])
        except Exception, excp:
            sys.stderr.write("ERROR: PATTERNS failed with exception " \
                                                            "%s\n" % excp)
开发者ID:LumbaJack,项目名称:Plan-Visualizer,代码行数:62,代码来源:interactivebroker.py

示例8: create_ticksym

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def create_ticksym(symbol_id,sym):
    libsyms = EXE + 'library.syms.csv'
    symdict = rpu_rp.create_dict(libsyms,0,1)
    exchdict = rpu_rp.create_dict(libsyms,0,2)
    typedict = rpu_rp.create_dict(libsyms,0,5)
    currdict = rpu_rp.create_dict(libsyms,0,3)
    expiredict = rpu_rp.create_dict(libsyms,0,4)
    dboostdict = rpu_rp.create_dict(libsyms,0,6)
    tickdict = rpu_rp.create_dict(libsyms,0,8)
    tsizedict = rpu_rp.create_dict(libsyms,0,7)
    roundfactordict = rpu_rp.create_dict(libsyms,0,9)
    entrywiderdict = rpu_rp.create_dict(libsyms,0,10)
    symib = symdict[sym] 
    ibsecType = typedict[sym] #'CASH'
    ibexchange = exchdict[sym] #'IDEALPRO'
    cashcurr = currdict[sym] #'USD'
    expiry = expiredict[sym] #'ignore'  
    contract = Contract()  
    contract.m_symbol = symib
    contract.m_secType = ibsecType 
    contract.m_exchange = ibexchange
    contract.m_currency = cashcurr
    if ibsecType  == 'FUT':
        contract.m_expiry = expiry
        sleep(2)
    return contract
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:28,代码来源:ibutiles+-+Copy.py

示例9: reqMktData

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
 def reqMktData(self):
     contract = Contract() #
     contract.m_symbol = 'AUD'
     contract.m_currency = 'USD'
     contract.m_secType = 'CASH'
     contract.m_exchange = 'IDEALPRO'
     self.connection.reqMktData(1, contract, '', False)
开发者ID:TimonPeng,项目名称:pi314,代码行数:9,代码来源:reference_python.py

示例10: makeContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
 def makeContract(self, symbol):
     c = Contract()
     c.m_symbol = symbol
     c.m_secType = "STK"
     c.m_currency = "USD"
     c.m_exchange = "SMART"
     return c
开发者ID:jessetane,项目名称:2502,代码行数:9,代码来源:tws.py

示例11: create_ib_futures_contract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def create_ib_futures_contract(symbol, exp_month=1, exp_year=2016, exchange='NYMEX', currency='USD'):
    """
    Creates a futures contract used for IB orders.
    :param symbol: (string) base symbol e.g. 'CL'
    :param type: (string) 'FUT' --> futures
    :param exp_month: (int) e.g. 6 --> June
    :param exp_year: (int) e.g. 2016
    :param exchange:
    :param currency:
    :return:
    """
    # TODO: create IBContract class
    exp_month = str(exp_month)
    if len(exp_month) == 1:
        exp_month = '0' + exp_month
    exp_year = str(exp_year)
    expiry = exp_year + exp_month

    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = 'FUT'
    contract.m_expiry = expiry
    contract.m_exchange = exchange
    contract.m_currency = currency
    return contract
开发者ID:EdwardBetts,项目名称:backtester,代码行数:27,代码来源:ib_utils.py

示例12: makeStkContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def makeStkContract(symbol, cur = 'USD'):
    contract = Contract()
    contract.m_symbol = symbol
    contract.m_secType = 'STK'
    contract.m_exchange = 'SMART'
    contract.m_currency = cur
    return contract
开发者ID:muennix,项目名称:IbHandler,代码行数:9,代码来源:IbHandler.py

示例13: main

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def main():
  symbol = sys.argv[1]
  exch = sys.argv[2]
  expiry = convert_date(sys.argv[3])
  date = pd.to_datetime(convert_date(sys.argv[4])) - pd.DateOffset(days=1)
  to_date = pd.to_datetime(convert_date(sys.argv[5]))
  timeframe = sys.argv[6] + ' '
  units = sys.argv[7]
  duration = to_date - date

  contract = Contract()
  contract.m_symbol = symbol
  contract.m_secType = 'FUT'
  contract.m_exchange = exch
  contract.m_currency = 'USD'
  contract.m_expiry = expiry
  print 'Collecting', date, 'data for', contract.m_symbol, 'expiration', contract.m_expiry

  outfile = open('from %s to %s' % (sys.argv[4], sys.argv[5])+'.bars', 'w')

#  for h in xrange(20,24,2):
 #   broker = Datacol(contract, prev_date, ('%02d:00:00' % h), 7200, outfile)
  #  broker.close()

#  for h in xrange(0,18,2):
 #   broker = Datacol(contract, date, ('%02d:00:00' % h), 7200, outfile)
  #  broker.close()

  for h in range(duration.days):
      date = date + pd.DateOffset(days=1)
      broker = Datacol(contract, '%04d%02d%02d 21:59:00' % (date.year, date.month, date.day), timeframe+units, outfile)
      broker.close()

  outfile.close()
开发者ID:lightme16,项目名称:ibpy_work,代码行数:36,代码来源:get_hictorical_data.py

示例14: create_option_ticker

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
 def create_option_ticker(self, ticker, currency='USD', exchange='SMART'):
     c = Contract()
     c.m_secType = 'OPT'
     c.m_localSymbol = ticker
     c.m_currency = currency
     c.m_exchange = exchange
     return c
开发者ID:gongqingyi,项目名称:untws,代码行数:9,代码来源:connection.py

示例15: makeStkContract

# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_secType [as 别名]
def makeStkContract(contractTuple):
    newContract = Contract()
    newContract.m_symbol = contractTuple[0]
    newContract.m_secType = contractTuple[1]
    newContract.m_exchange = contractTuple[2]
    newContract.m_currency = contractTuple[3]
    return newContract
开发者ID:oolsson,项目名称:oo_eclipse,代码行数:9,代码来源:ee.py


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