Giter Site home page Giter Site logo

node-blpapi's Introduction

build status node-blpapi

Bloomberg Open API binding for Node.js.

Find source code in the Github repository.

Dependencies

This module requires:

  • Node.js version >= 0.6.x
  • Linux, Windows, or Mac OS X (32 or 64-bit)
  • GCC (Linux), MSVC++ (Windows), or Xcode (Mac OS X)
  • Bloomberg Desktop API (DAPI), Server API (SAPI), or B-PIPE subscription

This module includes:

Installation

From your project directory, run:

$ npm install blpapi

To install directly from github source, run:

$ npm install git://github.com/bloomberg/node-blpapi.git

This will download and build blpapi in node_modules/.

Note: Windows users using the Express version of Visual Studio may not have the 64-bit compiler platform installed. If errors are seen related to the x64 platform not being found, please force a 32-bit arch before invoking npm by running from the command shell:

> set npm_config_arch="ia32"

Usage

The module design closely follows the BLPAPI SDK design, with slight modifications in syntax for easier consumption in Javascript. The SDK developer's guide should serve as the main guide for the module's functionality.

Full examples contained in the examples directory demonstrate how to use most SDK functionality. Full descriptions of all availabe requests, responses, and options are contained within the BLPAPI API Developer Guide.

Opening A Session

var blpapi = require('blpapi');
var session = new blpapi.Session({ host: '127.0.0.1', port: 8194 });

session.on('SessionStarted', function(m) {
    // ready for work
});

Opening A Subscription Service

var service_id = 1;

session.on('SessionStarted', function(m) {
    session.openService('//blp/mktdata', service_id);
});

session.on('ServiceOpened', function(m) {
    // m.correlations[0].value == service_id
    // ready for subscriptions
});

Subscribing To Market Data

var securities = [
    { security: 'AAPL US Equity', correlation: 0, fields: ['LAST_TRADE'] },
    { security: 'GOOG US Equity', correlation: 1, fields: ['LAST_TRADE'] }
];

session.on('ServiceOpened', function(m) {
    if (m.correlations[0].value == service_id) {
        session.subscribe(securities);
    }
});

session.on('MarketDataEvents', function(m) {
    if (m.data.hasOwnProperty('LAST_TRADE')) {
        console.log(securities[m.correlations[0].value].security,
                    'LAST_TRADE', m.data.LAST_TRADE);
        // outputs:
        // AAPL US Equity LAST_TRADE 600.00
        // AAPL US Equity LAST_TRADE 601.00
        // GOOG US Equity LAST_TRADE 650.00
        // ...
    }
});

License

MIT license. See license text in LICENSE.

node-blpapi's People

Contributors

apaprocki avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.