Thursday, 13 April 2017

I got no response from the Node.js Bloomberg API package (blpapi)

I'm working on a Node.js project and I need to price some stocks with the Bloomberg API. I found out that there's an NPM package for this API, so I had it installed and started testing it according to https://github.com/bloomberg/blpapi-node but I'm getting no responses.

This is my code:

var blpapi = require('blpapi');

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

    session.on('SessionStarted', function(m) {
        console.log('bonjou');
    session.openService('//blp/mktdata', 1);

    });

    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) {
    console.log(session);
    if (m.correlations[0].value == service_id) {
        console.log(session);
        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);
    }
});

}

Is this package still working? If not, how is it possible to call the Java Bloomberg API from Node.js?

Thank you very much.



via Everblack

No comments:

Post a Comment