Skip to main content

Bloomberg

Overview

The MDF Bridge version of the Bloomberg Adapter provides access to the Bloomberg Market Data Feed (B-PIPE). Real-time and delayed streaming market data and static reference data for securities and security fields can be retrieved via subscription or request/response mechanisms.

The MDF Bridge exposes a protocol based on Interop methods, which you can use to connect to the Bloomberg Market Data Feed (B-PIPE).

The @interopio/bbg-market-data library is a JavaScript (TypeScript) wrapper API around the exposed protocol, which enables easier integration with web apps.

ℹ️ For details on using the JavaScript API exposed by the @interopio/bbg-market-data library, see the Market Data > JavaScript section and the BBG Market Data example on GitHub.

ℹ️ For more details on the Bloomberg API, see the Bloomberg API documentation.

MDF Mock

The MDF Bridge version of the Bloomberg Adapter includes a fully functional mock implementation of the Bloomberg Market Data Feed (B-PIPE). It uses a pre-recorded SQLite database of instruments and fields and generates random but type-correct values for all requested fields, and supports an interception mechanism that enables you to supply custom field values at runtime.

⚠️ Note that for the MDF Mock to operate, you must provide a mock data package that contains the pre-recorded SQLite database of instruments and fields. This mock data package and a tool for generating mock data can be provided on demand separately from the Bloomberg Adapter. For more details, contact us.

To enable the MDF Mock, use the "parameters" property of the "details" top-level key in the Bloomberg Adapter app definition and provide command line arguments for starting the MDF Mock:

{
    "title": "Bloomberg MDF Mock",
    "type": "exe",
    "name": "bbg-mdf-mock",
    "service": true,
    "details": {
        "path": "%IO_CD_ROOT_DIR%/../BloombergBridge/",
        "command": "Glue42.MDFBridge.exe",
        // Enabling the MDF Mock.
        "parameters": "--mdf=mock --mockpack=path-to-mock-data-package.dll",
    }
}

Alternatively, you can use a command prompt and provide the arguments directly when starting the executable:

Glue42.MDFBridge.exe --mdf=mock --mockpack=path-to-mock-data-package.dll

Command Line Arguments

The following command line arguments are available for enabling and configuring the MDF Mock:

Argument Description
--allow-console Allocates a console window for debug output.
--killMaster Kills another running instance of the MDF bridge on the same mutex before starting.
--mdf=mock Enables the MDF Mock mode.
--mockConfig=<json_configuration> Inline JSON string with default field settings for the MDF Mock. Applied to all requests unless overridden per request.
--mockConfigPath=<path_to_json_file> Path to a JSON file containing default field settings for the MDF Mock. If both --mockConfig and --mockConfigPath are provided, --mockConfigPath takes precedence.
--mockpack=<path_to_mock_data_package> Path to a mock data pack (a signed DLL containing the pre-recorded SQLite database of instruments and fields).
--mutex=<mutex_name> Overrides the default mutex name, effectively enabling you to run multiple instances of the MDF bridge. Defaults to "Glue42.BBG.Bridge".
--no-console Starts with a hidden console window.
--servicePrefix=<interop_method_prefix> Optional prefix for the names of the Interop methods registered by the MDF bridge (e.g., "DEV." would register DEV.T42.MDFApi.CreateRequest).
--waitMaster=<seconds> Waits for an existing MDF bridge instance to quit. If set to 0 (default), won't wait. If set to -1, will wait indefinitely.
--wnd Shows a window that acts as a lifetime anchor for the MDF Bridge. Useful for debugging.

Field Settings

Mock settings control how the MDF Mock generates field values. They can be provided in three ways (in order of precedence, lowest to highest):

  1. Startup inline JSON provided via the --mockConfig command line argument.
  2. Startup config file provided via the --mockConfigPath command line argument.
  3. Per-request settings provided programmatically via the "settings" object in each MDF API request or via the UI of the BBG Market Data example.

Per-request settings are merged with the startup defaults — any property not specified in the request falls back to the startup default.

The following table describes the available settings for controlling field value generation in the MDF Mock:

Property Type Description
"fullSchemaMock" boolean If true, Market Data subscriptions will return all fields from the internal mktdata.json schema, not just the requested fields. Useful for testing apps that consume many fields. Defaults to false.
"mockApp" string Restricts the lookup for the Interop method specified in "mockGenerator" to methods registered by a specific app. If not specified, any app providing the Interop method will be used.
"mockFields" string[] Array of field mnemonics to intercept with the Interop method specified in "mockGenerator". If null (default), all fields will be intercepted. If specified, only the listed fields will be passed to the mock generator and the rest of the fields will use the built-in generation.
"mockGenerator" string The name of an Interop method to invoke for generating custom field values. If not specified, the built-in random value generation will be used.
"mockGeneratorTimeout" number Interval in milliseconds at which to invoke the "mockGenerator" method. If the generator doesn't respond in time, the built-in generation will be used. Defaults to 500.
"subscriptionThrottle" number Interval in milliseconds between subscription data pushes. Defaults to 500.

The following is an example of a JSON configuration for the MDF Mock settings that can be saved as a file and passed via the --mockConfigPath command line argument:

{
    "mockGenerator": "MyApp.GenerateFieldValue",
    "mockFields": ["PX_LAST", "BID", "ASK", "OPEN", "HIGH", "LOW"],
    "mockApp": "my-field-generator",
    "mockGeneratorTimeout": 1000,
    "fullSchemaMock": false,
    "subscriptionThrottle": 250
}

When using the @interopio/bbg-market-data library, you can pass per-request mock settings via the open() method options. Any additional properties (besides session and aggregateResponse) are forwarded to the MDF protocol settings object:

import BBGMarketData, { Session } from "@interopio/bbg-market-data";

const bbgMarketData = BBGMarketData(io.interop, { debug: false });

const requestArgs = {
    securities: ["VOD LN Equity"],
    fields: ["PX_LAST", "BID", "ASK"]
};

const request = bbgMarketData.createReferenceDataRequest(requestArgs);

const openOptions = {
    session: Session.CreateNew,
    mockGenerator: "MyApp.GenerateFieldValue",
    subscriptionThrottle: 100
};

const response = await request.open(openOptions);

Custom Field Generation

The "mockGenerator" property allows you to register an Interop method that the MDF Mock will invoke for each field value it needs to generate. This enables you to return semantically correct values (realistic prices, timestamps) instead of random data.

Your Interop method will receive as an argument an object with the following properties:

Property Type Description
field string The field mnemonic (e.g., "PX_LAST", "BID", "VOLUME").
request object The request context (correlation ID, service, operation, and operation arguments).
tick object Tick information (a counter for subscriptions, or a security index for requests).
type string The field type from the database (e.g., "Price", "Real", "Date", "Boolean").

Your method must return an object with a "value" property containing the generated value. Return null or let the invocation time out to fall back to the built-in random value generation.

The following example demonstrates how to register a custom field generator that returns realistic values for price and volume fields and falls back to random generation for any other fields:

const handleFieldGeneration = async (args) => {
    const { field, type } = args;

    if (type === "Price") {
        return { value: (Math.random() * 1000).toFixed(2) };
    }

    if (type === "Volume") {
        return { value: Math.floor(Math.random() * 100000) };
    }

    // Use the built-in generation for all other fields.
    return null;
};

await io.interop.register("MyApp.GenerateFieldValue", handleFieldGeneration);

Mock Data Package

⚠️ Note that the mock data package that contains the pre-recorded SQLite database of instruments and fields and a tool for generating mock data can be provided on demand separately from the Bloomberg Adapter. For more details, contact us.

The mock data package is a signed DLL assembly containing an embedded SQLite database with pre-recorded Bloomberg field metadata and instrument data:

  • Instruments — Security names and descriptions.
  • Fields — Field IDs, mnemonics, descriptions, data types, field types, categories, overrides, and documentation.

The built-in value generation uses the field data type from the database to produce type-appropriate random values:

Data Type Generated Value
Bool Random true or false values.
DateTime Current UTC time plus a random offset (up to 365 days).
Double Random number between 10 and 10 000.
Float Random number between 10 and 10 000.
Int32 Random integer between 10 and 100 000.
Int64 Random integer between 10 and 100 000.
String Random 3–10 character alphabetic string.

Supported Requests

The supported requests are:

  • //blp/instruments:instrumentListRequest
  • //blp/apiflds:FieldListRequest
  • //blp/apiflds:FieldSearchRequest
  • //blp/refdata:HistoricalDataRequest
  • //blp/refdata:ReferenceDataRequest
  • //blp/refdata:IntradayBarRequest
  • //blp/refdata:IntradayTickRequest

The supported subscriptions are:

  • //blp/mktdata