コード例 #1
0
def get_instrument_object_from_config(instrument_code: str,
                                      config: IBconfig=None) ->futuresInstrumentWithIBConfigData:
    if config is None:
        config = read_ib_config_from_file()

    config_row = config[config.Instrument == instrument_code]
    symbol = config_row.IBSymbol.values[0]
    exchange = config_row.IBExchange.values[0]
    currency = value_or_npnan(config_row.IBCurrency.values[0], NOT_REQUIRED_FOR_IB)
    ib_multiplier = value_or_npnan(
        config_row.IBMultiplier.values[0], NOT_REQUIRED_FOR_IB)
    my_multiplier = value_or_npnan(
        config_row.MyMultiplier.values[0], 1.0)
    ignore_weekly = config_row.IgnoreWeekly.values[0]

    # We use the flexibility of futuresInstrument to add additional arguments
    instrument = futuresInstrument(instrument_code)
    ib_data = ibInstrumentConfigData(symbol, exchange, currency=currency,
                                     ibMultiplier=ib_multiplier,
                                     myMultiplier=my_multiplier,
                                     ignoreWeekly=ignore_weekly
                                     )

    futures_instrument_with_ib_data = futuresInstrumentWithIBConfigData(instrument, ib_data)

    return futures_instrument_with_ib_data
コード例 #2
0
def get_instrument_object_from_config( instrument_code, config = None):
    if config is None:
        config = get_ib_config()
    config_row = config[config.Instrument == instrument_code]
    symbol = config_row.IBSymbol.values[0]
    exchange = config_row.IBExchange.values[0]
    currency = value_or_npnan(config_row.IBCurrency.values[0], NOT_REQUIRED)
    ib_multiplier = value_or_npnan(config_row.IBMultiplier.values[0], NOT_REQUIRED)
    my_multiplier = value_or_npnan(config_row.MyMultiplier.values[0], NOT_REQUIRED)
    ignore_weekly = config_row.IgnoreWeekly.values[0]

    ## We use the flexibility of futuresInstrument to add additional arguments
    instrument_config = futuresInstrument(instrument_code, symbol=symbol, exchange=exchange, currency=currency,
                                          ibMultiplier=ib_multiplier, myMultiplier=my_multiplier,
                                          ignoreWeekly=ignore_weekly)

    return instrument_config