• This repository has been archived on 19/Sep/2018
  • Stars
    star
    243
  • Rank 162,879 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 12 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bloomberg Open API module for node.js

build status blpapi-node

Bloomberg Open API binding for Node.js.

Find source code in the Github repository.

Note: This repository was renamed from node-blpapi to blpapi-node.

Dependencies

This module requires:

  • Node.js version >= 0.12.x (io.js >= 1.0.x is supported)
  • 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:

Note: Mac OS X users can only connect to SAPI or B-PIPE products.

Installation

From your project directory, run:

$ npm install blpapi

To install directly from github source, run:

$ npm install git://github.com/bloomberg/blpapi-node.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 available 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
        // ...
    }
});

Creating An Authorized Identity

Some session configurations, for example when connecting to a B-PIPE, may require calls to request and subscribe to specify an authorized Identity. The authorizeUser function performs an AuthorizationRequest on the //blp/apiauth. This function differs slightly from the BLPAPI SDK design in two ways. First, rather than having separate response events for success and failure, it emits the AuthorizationResponse event for both. Second, the Identity object is returned via the response as data.identity. This is only set for successful authorization, so its presence or absence can be used to determine whether the AuthorizationResponse indicates success or failure. data.identity is an opaque object representing the authorized user. Its only use is to be passed to request and subscribe.

var auth_service_id = 2;
var token_correlation_id = 3;
var identity_correlation_id = 4;

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

session.on('ServiceOpened', function(m) {
    if (m.correlations[0].value == auth_service_id) {
        // Request a token to be sent to you via MSG.
        session.request('//blp/apiauth', 'AuthorizationTokenRequest',
            { uuid: 12345678, label: 'testApp' }, token_correlation_id);
    }
});

session.on('AuthorizationTokenResponse', function(m) {
    if (m.correlations[0].value == token_correlation_id) {
        // Request the identity
        session.authorizeUser({ uuid: 12345678, token: 'token from MSG' },
            identity_correlation_id);
    }
});

session.on('AuthorizationResponse', function(m) {
    if (m.correlations[0].value == identity_correlation_id) {
        if (m.data.hasOwnProperty('identity') {
            // Authorization successful;
            // Save m.data.identity for use with later requests.
        }
    }
});

Using An Authorized Identity To Make A Request

var identity;  // Assumed to be set by a previous AuthorizationResponse

var refdata_service_id = 5;
var refdata_correlation_id = 6;

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

session.on('ServiceOpened', function(m) {
    if (m.correlations[0].value == refdata_service_id) {
        session.request('//blp/refdata', 'ReferenceDataRequest',
            { securities: ['IBM US Equity'], fields: [PX_LAST'] },
            refdata_correlation_id, identity);
    }
});

session.on('ReferenceDataResponse', function(m) {
    if (m.correlations[0].value == refdata_correlation_id) {
         console.log(m.data);
    }
});

Error Handling

Exceptions thrown from the C++ SDK layer are translated into JavaScript exceptions with the same type name. The JavaScript exception types inherit from Error with the message property set to the description obtained from the original C++ exception. Refer to the C++ SDK documentation for additional information on exceptions.

This is a list of the exception types:

  • DuplicateCorrelationIdException
  • InvalidStateException
  • InvalidArgumentException
  • InvalidConversionException
  • IndexOutOfRangeException
  • FieldNotFoundException
  • NotFoundException
  • UnknownErrorException
  • UnsupportedOperationException

License

MIT license. See license text in LICENSE.

More Repositories

1

memray

Memray is a memory profiler for Python
Python
12,679
star
2

blazingmq

A modern high-performance open source message queuing system
C++
2,490
star
3

goldpinger

Debugging tool for Kubernetes which tests and displays connectivity between nodes in the cluster.
JavaScript
2,457
star
4

bde

Basic Development Environment - a set of foundational C++ libraries used at Bloomberg.
C++
1,542
star
5

comdb2

Bloomberg's distributed RDBMS
C
1,311
star
6

pystack

๐Ÿ” ๐Ÿ Like pstack but for Python!
Python
962
star
7

xcdiff

A tool which helps you diff xcodeproj files.
Swift
909
star
8

quantum

Powerful multi-threaded coroutine dispatcher and parallel execution engine
C++
567
star
9

ipydatagrid

Fast Datagrid widget for the Jupyter Notebook and JupyterLab
TypeScript
510
star
10

foml

Foundations of Machine Learning
Handlebars
330
star
11

pytest-memray

pytest plugin for easy integration of memray memory profiler
Python
318
star
12

python-github-webhook

A framework for writing webhooks for GitHub, in Python.
Python
276
star
13

chromium.bb

Chromium source code and modifications
267
star
14

koan

A word2vec negative sampling implementation with correct CBOW update.
C++
261
star
15

chef-bcpc

Bloomberg Clustered Private Cloud distribution
Python
228
star
16

phabricator-tools

Phabricator Tools
Python
221
star
17

scatteract

Project which implements extraction of data from scatter plots
Jupyter Notebook
208
star
18

record-tuple-polyfill

A polyfill for the ECMAScript Record and Tuple proposal.
JavaScript
162
star
19

pasta-sourcemaps

Pretty (and) Accurate Stack Trace Analysis is an extension to the JavaScript source map format that allows for accurate function name decoding.
TypeScript
160
star
20

collectdwin

CollectdWin - a system statistics collection daemon for Windows, inspired by 'collectd'
C#
123
star
21

clangmetatool

A framework for reusing code in Clang tools
C++
119
star
22

kubernetes-cluster-cookbook

Ruby
100
star
23

quant-research

A collection of projects published by Bloomberg's Quantitative Finance Research team.
Jupyter Notebook
98
star
24

blpapi-http

HTTP wrapper for Bloomberg Open API
TypeScript
83
star
25

dataless-model-merging

Code release for Dataless Knowledge Fusion by Merging Weights of Language Models (https://openreview.net/forum?id=FCnohuR6AnM)
Python
74
star
26

amqpprox

An AMQP 0.9.1 proxy server, designed for use in front of an AMQP 0.9.1 compliant message queue broker such as RabbitMQ.
C++
72
star
27

spire-tpm-plugin

Provides agent and server plugins for SPIRE to allow TPM 2-based node attestation.
Go
71
star
28

bde-tools

Tools for developing and building libraries modeled on BDE
Perl
67
star
29

ntf-core

Sockets, timers, resolvers, events, reactors, proactors, and thread pools for asynchronous network programming
C++
67
star
30

repofactor

Tools for refactoring history of git repositories
Perl
63
star
31

chef-bach

Chef recipes for Bloomberg's deployment of Hadoop and related components
Ruby
61
star
32

minilmv2.bb

Our open source implementation of MiniLMv2 (https://aclanthology.org/2021.findings-acl.188)
Python
59
star
33

wsk

A straightforward and maintainable build system from the Bloomberg Graphics team.
JavaScript
58
star
34

git-adventure-game

An adventure game to help people learn Git
Shell
57
star
35

corokafka

C++ Kafka coroutine library using Quantum dispatcher and wrapping CppKafka
C++
50
star
36

attrs-strict

Provides runtime validation of attributes specified in Python 'attr'-based data classes.
Python
50
star
37

cnn-rnf

Convolutional Neural Networks with Recurrent Neural Filters
Python
49
star
38

rmqcpp

A batteries included C++ RabbitMQ Client Library/API.
C++
46
star
39

selekt

A Kotlin and familiar Android SQLite database library that uses encryption.
Kotlin
45
star
40

ppx_string_interpolation

PPX rewriter that enables string interpolation in OCaml
OCaml
44
star
41

bde_verify

Tool used to format, improve and verify code to BDE guidelines
C++
42
star
42

vault-auth-spire

vault-auth-spire is an authentication plugin for Hashicorp Vault which allows logging into Vault using a Spire provided SVID.
Go
41
star
43

spark-flow

Library for organizing batch processing pipelines in Apache Spark
Scala
41
star
44

startup-python-bootcamp

35
star
45

chef-umami

A tool to automatically generate test code for Chef cookbooks and policies.
Ruby
34
star
46

p1160

P1160 Add Test Polymorphic Memory Resource To Standard Library
C++
34
star
47

pycsvw

A tool to read CSV files with CSVW metadata and transform them into other formats.
Python
32
star
48

bde-allocator-benchmarks

A set of benchmarking tools used to quantify the performance of BDE-style polymorphic allocators.
C++
31
star
49

blpapi-hs

Haskell interface to BLPAPI
Haskell
30
star
50

bbit-learning-labs

Learning labs curated by BBIT
Python
28
star
51

rwl-bench

A set of benchmark tools for reader/writer locks.
C++
28
star
52

entsum

Open Source / ENTSUM: A Data Set for Entity-Centric Extractive Summarization
Jupyter Notebook
28
star
53

consul-cluster-cookbook

Wrapper cookbook which installs and configures a Consul cluster.
Ruby
26
star
54

kbir_keybart

Experimental code used in pre-training the KBIR and KeyBART models
Python
26
star
55

presto-accumulo

Presto Accumulo Integration
Java
25
star
56

sgtb

Structured Gradient Tree Boosting
Python
25
star
57

blazingmq-sdk-java

Java SDK for BlazingMQ, a modern high-performance open source message queuing system.
Java
24
star
58

python-comdb2

Python API to Bloomberg's comdb2 database.
Python
23
star
59

jupyterhub-kdcauthenticator

A Kerberos authenticator module for the JupyterHub platform
Python
22
star
60

docket

Tool to make running test suites easier, using docker-compose.
Go
22
star
61

blazingmq-sdk-python

Python SDK for BlazingMQ, a modern high-performance open source message queuing system.
Python
21
star
62

tzcron

A parser of cron-style scheduling expressions.
Python
20
star
63

constant.js

Immutable/Constant Objects for JavaScript
JavaScript
20
star
64

go-testgroup

Helps you organize tests in Go programs into groups.
Go
19
star
65

redis-cookbook

A set of Chef recipes for installing and configuring Redis.
HTML
19
star
66

userchroot

A tool to allow controlled access to 'chroot' functionality by users without root permissions
C
19
star
67

nginx-cookbook

A set of Chef recipes for installing and configuring Nginx.
Ruby
17
star
68

MixCE-acl2023

Implementation of MixCE method described in ACL 2023 paper by Zhang et al.
Python
17
star
69

zookeeper-cookbook

A set of Chef recipes for installing and configuring Apache Zookeeper.
Ruby
17
star
70

mynexttalk

16
star
71

chef-bcs

Bloomberg Cloud Storage Chef application
Ruby
16
star
72

vault-cluster-cookbook

Application cookbook which installs and configures Vault with Consul as a backend.
Ruby
15
star
73

git-adventure-game-builder

A set of tools for building a Git adventure game, to help people learn Git
Shell
15
star
74

emnlp20_depsrl

Research code and scripts used in the paper Semantic Role Labeling as Syntactic Dependency Parsing.
Python
14
star
75

coffeechat

A simple web application for arranging 'chats over coffee'.
TypeScript
12
star
76

k8eraid

A relatively simple, unified method for reporting on Kubernetes resource issues.
Go
12
star
77

hackathon-aws-cluster

HTML
11
star
78

fast-noise-aware-topic-clustering

Research code and scripts used in the Silburt et al. (2021) EMNLP 2021 paper 'FANATIC: FAst Noise-Aware TopIc Clustering'
Python
10
star
79

emnlp21_fewrel

Code to reproduce the results of the paper 'Towards Realistic Few-Shot Relation Extraction' (EMNLP 2021)
Python
10
star
80

mastering-difficult-conversations

Plan It, Say It, Nail It: Mastering Difficult Conversations
10
star
81

wsk-notify

Simple, customizable console notifications.
JavaScript
10
star
82

jenkins-cluster-cookbook

Ruby
9
star
83

decorator-taxonomy

A taxonomy of Python decorator types.
HTML
9
star
84

pytest-pystack

Pytest plugin that runs PyStack on slow or hanging tests.
Python
9
star
85

tdd-labs

Problems and Solutions for Test-Driven-Development training
JavaScript
9
star
86

argument-relation-transformer-acl2022

This repository contains code for our ACL 2022 Findings paper `Efficient Argument Structure Extraction with Transfer Learning and Active Learning`. We implement an argument structure extraction method based on a pre-trained Transformer model.`
Python
9
star
87

sigir2018-kg-contextualization

8
star
88

bloomberg.github.io

Source code for the https://bloomberg.github.io site
HTML
8
star
89

locking_resource-cookbook

Chef cookbook for serializing access to resources
Ruby
7
star
90

datalake-query-ingester

Python
7
star
91

cobbler-cookbook

A Chef cookbook for installing and maintaining Cobbler
Ruby
7
star
92

p2473

Example code for WG21 paper P2473
Perl
6
star
93

collectd-cookbook

Ruby
6
star
94

Catalyst-Authentication-Credential-GSSAPI

A module that provides integration of the Catalyst web application framework with GSSAPI/SPNEGO HTTP authentication.
Perl
6
star
95

bob-bot

Java
5
star
96

.github

Organization-wide community files
5
star
97

jenkins-procguard

Perl
5
star
98

datalake-query-db-consumer

Python
4
star
99

datalake-metrics-db

Python
3
star
100

collectd_plugins-cookbook

Ruby
3
star