Commit 5158f0d4 authored by Carlos Ungil's avatar Carlos Ungil

Initial commit

parents
```
;; tested on Windows (SBCL 64-bit, ClozurCL 32/64-bit, Lispworks 6.0 32-bit)
;; the test suite should run without any errors: (asdf:test-system :bloomie)
(ql:quickload :bloomie)
(bb:open-session)
;; FIELDS
(bb:field-info "MILITARY_REVENUE")
(bb:field-info "M1090")
(bb:field-info '("px_last" "pe_ratio") :documentation nil)
(mapcar #'bb:field-mnemonic (bb:field-search "military"))
(loop for cat in (bb:categorized-field-search "PRESID*")
do (format t "~&~A :~{ ~A~}" (bb:category-name cat)
(loop for fld in (bb:category-fields cat) collect (bb:field-mnemonic fld))))
(length (bb:field-list :type :real-time))
(length (bb:field-list :type :static)) ;; 57k+ fields
;; INSTRUMENTS
(bb:instruments "entropy")
(bb:instruments "entropy" :max-results 5)
(bb:instruments "entropy" :yellow-key :corp)
(bb:instruments "entropy" :yellow-key :indx)
(bb:govt "rome")
(bb:govt "rome" :max-results 1)
(bb:govt "rome" :ticker "ROM")
(bb:govt "rome" :ticker "ROM" :partial-match nil)
(bb:govt "rome" :ticker "ROMCTY" :partial-match nil)
(bb:curve "genev")
(bb:curve "" :curve-id "bi758")
(bb:curve "garch" :currency-code "CHF" :max-results 3)
(bb:curve "" :currency-code :chf :type :irs)
(mapcar #'curve-currency (bb:curve nil :currency-code "jpy" :subtype "spread"))
;; REFERENCE
(bb:bdp '("AAPL US Equity" "MSFT US Equity") '("PX_LAST" "BEST_EPS"))
(bb:bdp '("AAPL US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST"))
(bb:bdp '("AAAAPLE US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST"))
(let ((bb:*raise-all-errors* t))
(bb:bdp '("AAAAPL US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST")))
;; HISTORICAL
(bb:bdh '("AAPL US Equity" "MSFT US Equity") '("PX_LAST" "VOLUME")
:start-date "20170501" :end-date "20170510" :periodicity :daily)
(bb:bdh "AAPL US Equity" "PE_RATIO" :start-date "1995-12-31" :periodicity :yearly)
;; INTRADAY BARS
(bb:ibar "AAPL US Equity" "BID" :bar-size '(4 :hour)
:start-date-time "2017-08-08" :end-date-time "2017-08-11")
(bb:ibar "AAPL US Equity" "TRADE" :bar-size '(1 :m)
:start-date-time "2017-08-08T14" :end-date-time "2017-08-08T14:05")
;; PORTFOLIO
(bb:portfolio-tickers "U12345678-1")
(bb:portfolio-tickers "U12345678-1" "2017-08-04")
(bb:portfolio-weights "U12345678-1")
(bb:portfolio-positions "U12345678-1")
(bb:portfolio-data "U12345678-1")
(bb:portfolio-data "XXX")
;; EQUITY SCREENING
(bb:screen-tickers "Global Automotive Parts Retailers")
(bb:screen-tickers "Global Automotive Parts Retailers" :folder "General")
(bb:screen-tickers "Global Automotive Parts Retailers" :folder "Popular")
;; EARNINGS
(bb:get-earnings-dates "AAPL US")
(bb:get-earnings "AAPL US" :start "2016-12-31")
(bb:get-earnings "AAPL US" :start "2016-12-31" :currency "EUR")
;; PRODUCTS
(loop for ticker in (bb:index-composition "SPX") for prods = (bb:product-list ticker)
when prods do (format t "~A~10T~A~&" ticker (length prods)))
(bb:product-list "VRTX US")
(bb:product-forecast "VRTX US" "Orkambi")
(bb:product-forecast "VRTX US" "Orkambi" :year '(2017 2018 2019 2020))
(bb:product-forecast "VRTX US" "Orkambi" :year 2020 :source :all)
(bb:product-forecast "VRTX US" "Orkambi" :stat :all)
(bb:product-forecast "VRTX US" "Orkambi" :stat :revisions)
;; EXPORT SCHEMAS AND FIELD DEFINITIONS
(bb:document-schemas) ;; can be incomplete, see function docstring
(bb:document-fields) ;; can be incomplete, see function docstring
(bb:close-session)
```
(asdf:defsystem #:bloomie
:name "bloomie"
:serial t
:description "BLPAPI wrapper (http://www.bloomberglabs.com/api/)"
:author "Carlos Ungil <ungil@mac.com>"
:license "MIT"
:serial t
:in-order-to ((test-op (test-op "bloomie-test")))
:components ((:module #:ffi :pathname "ffi" :components ((:static-file "blpapi-3.11.1.1.h")))
(:file "package")
(:file "wrapper")
(:file "helper")
(:file "session")
(:file "values")
(:file "element")
(:file "response")
(:file "request")
;; no CFFI / FLI especific code after this point
(:file "tree")
(:file "field-info")
(:file "instruments")
(:file "reference")
(:file "historical")
(:file "intraday")
(:file "screen")
(:file "portfolio")
(:file "indices")
(:file "earnings")
(:file "recommendations")
(:file "products"))
:depends-on (:local-time :cl-unification #-lispworks :cl-autowrap #-lispworks :cl-plus-c))
(defsystem #:bloomie-test
:name "bloomie test suite"
:author "Carlos Ungil <ungil@mac.com>"
:license "MIT"
:depends-on (:bloomie :fiveam)
:components ((:file "test"))
:perform (asdf:test-op (o s) (declare (ignore o s)) (uiop:symbol-call :bloomie.test '#:run)))
(in-package :bloomie)
(defstruct (eps-announcement (:conc-name eps-))
period date time reported comparable estimated)
(defun get-earnings (ticker &key start end currency)
"Returns the fiscal period, date, time and reported/comparable/estimated EPS
for earnings announcements in the given period. The currency can also be set."
(loop for (period date time reported comparable estimated)
in (second (second (first (bdp (format nil "~A Equity" ticker)
'("EARN_ANN_DT_TIME_HIST_WITH_EPS")
:overrides (append
(when start `(("START_DT" ,(bbdate start))))
(when end `(("END_DT" ,(bbdate end))))
(when currency `(("EQY_FUND_CRNCY" ,currency))))))))
collect (make-eps-announcement :period period :date date :time time
:reported reported :comparable comparable :estimated estimated)))
(defun get-earnings-dates (ticker)
"Returns (date fiscal-period) pairs for the whole history of earnings announcements."
(second (second (first (bdp (format nil "~A Equity" ticker) '("ERN_ANN_DT_AND_PER"))))))
(in-package :bloomie)
(defvar *data-types*
(loop for s in (apropos-list "+BLPAPI-DATATYPE-" "BB.FFI")
collect (cons (symbol-value s) (intern (subseq (string-trim "+" (symbol-name s)) (length "BLPAPI-DATATYPE-")) "KEYWORD"))))
#+lispworks
(setf *data-types* '((1 . :BOOL) (3 . :BYTE) (9 . :BYTEARRAY) (2 . :CHAR)
(16 . :CHOICE) (17 . :CORRELATION-ID) (10 . :DATE)
(13 . :DATETIME) (12 . :DECIMAL) (14 . :ENUMERATION)
(6 . :FLOAT32) (7 . :FLOAT64) (4 . :INT32) (5 . :INT64)
(15 . :SEQUENCE) (8 . :STRING) (11 . :TIME)))
(defun decode-data-type (x)
(or (cdr (assoc x *data-types*)) (error "data-type ~A not in ~A" x *data-types*)))
#+lispworks
(defun get-element (elements name)
(multiple-value-bind (res element)
(bb.ffi::blpapi-element-get-element elements nil name nil)
(check-errors res)
element))
#-lispworks
(defun get-element (elements name)
(plus-c:c-with ((element :pointer))
(check-errors (bb.ffi:blpapi-element-get-element elements (element plus-c:&) name nil))
(autowrap:wrap-pointer element 'bb.ffi:blpapi-element-t)))
#+lispworks
(defun set-element (elements name values)
(let ((s (get-element elements name)))
(dolist (val values)
(check-errors (bb.ffi::blpapi-element-set-value-string
s val (fli:cast-integer -1 '(:unsigned :int)))))))
#-lispworks
(defun set-element (elements name values)
;;; bb.ffi:+blpapi-element-index-end+ is -1, but I cannot pass this value as :unsigned-int
;;; (cffi:with-foreign-object (x :unsigned-int) (setf (cffi:mem-aref x :int) -1) (cffi:mem-aref x :unsigned-int))
(let ((s (get-element elements name)))
(dolist (val values)
(check-errors (bb.ffi:blpapi-element-set-value-string s val 4294967295)))))
#+lispworks
(defun append-element (elements)
(multiple-value-bind (res element)
(bb.ffi::blpapi-element-append-element elements nil)
(check-errors res)
element))
#-lispworks
(defun append-element (elements)
(plus-c:c-with ((element :pointer))
(check-errors (bb.ffi:blpapi-element-append-element elements (element plus-c:&)))
(autowrap:wrap-pointer element 'bb.ffi:blpapi-element-t)))
#+lispworks
(defun get-element-at (elements i)
(multiple-value-bind (res val)
(bb.ffi::blpapi-element-get-element-at elements nil i)
(check-errors res)
val))
#-lispworks
(defun get-element-at (elements i)
(plus-c:c-with ((val :pointer))
(check-errors (bb.ffi:blpapi-element-get-element-at elements (val plus-c:&) i))
val))
#+lispworks
(defun get-choice (element)
(multiple-value-bind (res choice)
(bb.ffi::blpapi-element-get-choice element nil)
(check-errors res)
choice))
#-lispworks
(defun get-choice (element)
(plus-c:c-with ((choice :pointer))
(check-errors (bb.ffi:blpapi-element-get-choice element (choice plus-c:&)))
choice))
(defun element-info (element)
(list (bb.ffi::blpapi-element-name-string element)
:datatype (decode-data-type (bb.ffi::blpapi-element-datatype element))
:isarray (bb.ffi::blpapi-element-is-array element)
:nelements (bb.ffi::blpapi-element-num-elements element)
:iscomplex (bb.ffi::blpapi-element-is-complex-type element)
:nvalues (bb.ffi::blpapi-element-num-values element)
:isreadonly (bb.ffi::blpapi-element-is-read-only element)
:isnull (bb.ffi::blpapi-element-is-null element)
:schema (decode-schema element)))
(defun decode-type-definition (def)
(list :name (name-string-and-destroy (bb.ffi::blpapi-schema-type-definition-name def))
:description (bb.ffi::blpapi-schema-type-definition-description def)
:datatype (decode-data-type (bb.ffi::blpapi-schema-type-definition-datatype def))))
(defun decode-schema (element)
(let ((def (bb.ffi::blpapi-element-definition element)))
(list :name (name-string-and-destroy (bb.ffi::blpapi-schema-element-definition-name def))
:alt-names (let ((nalternative (bb.ffi::blpapi-schema-element-definition-num-alternate-names def)))
(if (plusp nalternative)
(loop for i below nalternative
collect (name-string-and-destroy
(bb.ffi::blpapi-schema-element-definition-get-alternate-name def i)))))
:description (bb.ffi::blpapi-schema-element-definition-description def)
:type (decode-type-definition (bb.ffi::blpapi-schema-element-definition-type def))
:status (bb.ffi::blpapi-schema-element-definition-status def)
:min-values (bb.ffi::blpapi-schema-element-definition-min-values def)
:max-values (bb.ffi::blpapi-schema-element-definition-max-values def))))
(defun decode-element (element)
(assert (or (zerop (bb.ffi::blpapi-element-is-array element))
(zerop (bb.ffi::blpapi-element-is-complex-type element))))
(assert (string= (name-string-and-destroy (bb.ffi::blpapi-element-name element))
(bb.ffi::blpapi-element-name-string element)))
(cons (intern (bb.ffi::blpapi-element-name-string element) "KEYWORD")
(ecase (decode-data-type (bb.ffi::blpapi-element-datatype element))
(:date (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-date element i)))
(:datetime (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-date element i t)))
(:bool (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-bool element i)))
(:int32 (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-int32 element i)))
(:int64 (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-int64 element i)))
(:float64 (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-float64 element i)))
(:string (loop for i below (bb.ffi::blpapi-element-num-values element)
collect (value-as-string element i)))
(:sequence (if (= 1 (bb.ffi::blpapi-element-is-array element))
(loop for i below (bb.ffi::blpapi-element-num-values element)
collect (decode-element (value-as-element element i)))
(loop for i below (bb.ffi::blpapi-element-num-elements element)
collect (decode-element (get-element-at element i)))))
(:enumeration (list (value-as-string element 0)))
(:choice (decode-element (get-choice element))))))
;; tested on Windows (SBCL 64-bit, ClozurCL 32/64-bit, Lispworks 6.0 32-bit)
;; the test suite should run without any errors: (asdf:test-system :bloomie)
(ql:quickload :bloomie)
(bb:open-session)
;; FIELDS
(bb:field-info "MILITARY_REVENUE")
(bb:field-info "M1090")
(bb:field-info '("px_last" "pe_ratio") :documentation nil)
(mapcar #'bb:field-mnemonic (bb:field-search "military"))
(loop for cat in (bb:categorized-field-search "PRESID*")
do (format t "~&~A :~{ ~A~}" (bb:category-name cat)
(loop for fld in (bb:category-fields cat) collect (bb:field-mnemonic fld))))
(length (bb:field-list :type :real-time))
(length (bb:field-list :type :static)) ;; 57k+ fields
;; INSTRUMENTS
(bb:instruments "entropy")
(bb:instruments "entropy" :max-results 5)
(bb:instruments "entropy" :yellow-key :corp)
(bb:instruments "entropy" :yellow-key :indx)
(bb:govt "rome")
(bb:govt "rome" :max-results 1)
(bb:govt "rome" :ticker "ROM")
(bb:govt "rome" :ticker "ROM" :partial-match nil)
(bb:govt "rome" :ticker "ROMCTY" :partial-match nil)
(bb:curve "genev")
(bb:curve "" :curve-id "bi758")
(bb:curve "garch" :currency-code "CHF" :max-results 3)
(bb:curve "" :currency-code :chf :type :irs)
(mapcar #'curve-currency (bb:curve nil :currency-code "jpy" :subtype "spread"))
;; REFERENCE
(bb:bdp '("AAPL US Equity" "MSFT US Equity") '("PX_LAST" "BEST_EPS"))
(bb:bdp '("AAPL US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST"))
(bb:bdp '("AAAAPLE US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST"))
(let ((bb:*raise-all-errors* t))
(bb:bdp '("AAAAPL US Equity" "MSFT US Equity") '("XXXXXX" "YYYYYY" "PX_LAST")))
;; HISTORICAL
(bb:bdh '("AAPL US Equity" "MSFT US Equity") '("PX_LAST" "VOLUME")
:start-date "20170501" :end-date "20170510" :periodicity :daily)
(bb:bdh "AAPL US Equity" "PE_RATIO" :start-date "1995-12-31" :periodicity :yearly)
;; INTRADAY BARS
(bb:ibar "AAPL US Equity" "BID" :bar-size '(4 :hour)
:start-date-time "2017-08-08" :end-date-time "2017-08-11")
(bb:ibar "AAPL US Equity" "TRADE" :bar-size '(1 :m)
:start-date-time "2017-08-08T14" :end-date-time "2017-08-08T14:05")
;; PORTFOLIO
(bb:portfolio-tickers "U12345678-1")
(bb:portfolio-tickers "U12345678-1" "2017-08-04")
(bb:portfolio-weights "U12345678-1")
(bb:portfolio-positions "U12345678-1")
(bb:portfolio-data "U12345678-1")
(bb:portfolio-data "XXX")
;; EQUITY SCREENING
(bb:screen-tickers "Global Automotive Parts Retailers")
(bb:screen-tickers "Global Automotive Parts Retailers" :folder "General")
(bb:screen-tickers "Global Automotive Parts Retailers" :folder "Popular")
;; EARNINGS
(bb:get-earnings-dates "AAPL US")
(bb:get-earnings "AAPL US" :start "2016-12-31")
(bb:get-earnings "AAPL US" :start "2016-12-31" :currency "EUR")
;; PRODUCTS
(loop for ticker in (bb:index-composition "SPX") for prods = (bb:product-list ticker)
when prods do (format t "~A~10T~A~&" ticker (length prods)))
(bb:product-list "VRTX US")
(bb:product-forecast "VRTX US" "Orkambi")
(bb:product-forecast "VRTX US" "Orkambi" :year '(2017 2018 2019 2020))
(bb:product-forecast "VRTX US" "Orkambi" :year 2020 :source :all)
(bb:product-forecast "VRTX US" "Orkambi" :stat :all)
(bb:product-forecast "VRTX US" "Orkambi" :stat :revisions)
;; EXPORT SCHEMAS AND FIELD DEFINITIONS
(bb:document-schemas) ;; can be incomplete, see function docstring
(bb:document-fields) ;; can be incomplete, see function docstring
(bb:close-session)
This source diff could not be displayed because it is too large. You can view the blob instead.
#undef __cplusplus
#include "blpapi-3.11.1.1/blpapi_abstractsession.h"
#include "blpapi-3.11.1.1/blpapi_call.h"
#include "blpapi-3.11.1.1/blpapi_constant.h"
#include "blpapi-3.11.1.1/blpapi_correlationid.h"
#include "blpapi-3.11.1.1/blpapi_datetime.h"
#include "blpapi-3.11.1.1/blpapi_defs.h"
#include "blpapi-3.11.1.1/blpapi_diagnosticsutil.h"
#include "blpapi-3.11.1.1/blpapi_dispatchtbl.h"
#include "blpapi-3.11.1.1/blpapi_element.h"
#include "blpapi-3.11.1.1/blpapi_error.h"
#include "blpapi-3.11.1.1/blpapi_event.h"
#include "blpapi-3.11.1.1/blpapi_eventdispatcher.h"
#include "blpapi-3.11.1.1/blpapi_eventformatter.h"
#include "blpapi-3.11.1.1/blpapi_exception.h"
#include "blpapi-3.11.1.1/blpapi_highresolutionclock.h"
#include "blpapi-3.11.1.1/blpapi_identity.h"
#include "blpapi-3.11.1.1/blpapi_logging.h"
#include "blpapi-3.11.1.1/blpapi_message.h"
#include "blpapi-3.11.1.1/blpapi_name.h"
#include "blpapi-3.11.1.1/blpapi_providersession.h"
#include "blpapi-3.11.1.1/blpapi_request.h"
#include "blpapi-3.11.1.1/blpapi_requesttemplate.h"
#include "blpapi-3.11.1.1/blpapi_resolutionlist.h"
#include "blpapi-3.11.1.1/blpapi_schema.h"
#include "blpapi-3.11.1.1/blpapi_service.h"
#include "blpapi-3.11.1.1/blpapi_session.h"
#include "blpapi-3.11.1.1/blpapi_sessionoptions.h"
#include "blpapi-3.11.1.1/blpapi_streamproxy.h"
#include "blpapi-3.11.1.1/blpapi_subscriptionlist.h"
#include "blpapi-3.11.1.1/blpapi_timepoint.h"
#include "blpapi-3.11.1.1/blpapi_tlsoptions.h"
#include "blpapi-3.11.1.1/blpapi_topic.h"
#include "blpapi-3.11.1.1/blpapi_topiclist.h"
#include "blpapi-3.11.1.1/blpapi_types.h"
#include "blpapi-3.11.1.1/blpapi_versioninfo.h"
#include "blpapi-3.11.1.1/blpapi_versionmacros.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright 2012. Bloomberg Finance L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: The above
* copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
// blpapi_defs.h -*-C++-*-
#ifndef INCLUDED_BLPAPI_DEFS
#define INCLUDED_BLPAPI_DEFS
//@PURPOSE: Common definitions used by the library.
//
//@DESCRIPTION: This component provides a list of preprocessors that are used
// by the library.
#include <limits.h>
#define BLPAPI_CORRELATION_TYPE_UNSET 0
#define BLPAPI_CORRELATION_TYPE_INT 1
#define BLPAPI_CORRELATION_TYPE_POINTER 2
#define BLPAPI_CORRELATION_TYPE_AUTOGEN 3
#define BLPAPI_CORRELATION_MAX_CLASS_ID ((1 << 16)-1)
#define BLPAPI_MANAGEDPTR_COPY 1
#define BLPAPI_MANAGEDPTR_DESTROY (-1)
#define BLPAPI_MANAGEDPTR_IMPOSSIBLE_OPERATION 0
#define BLPAPI_DATETIME_YEAR_PART 0x1
#define BLPAPI_DATETIME_MONTH_PART 0x2
#define BLPAPI_DATETIME_DAY_PART 0x4
#define BLPAPI_DATETIME_OFFSET_PART 0x8
#define BLPAPI_DATETIME_HOURS_PART 0x10
#define BLPAPI_DATETIME_MINUTES_PART 0x20
#define BLPAPI_DATETIME_SECONDS_PART 0x40
#define BLPAPI_DATETIME_MILLISECONDS_PART 0x80
#define BLPAPI_DATETIME_FRACSECONDS_PART 0x80
#define BLPAPI_DATETIME_DATE_PART (BLPAPI_DATETIME_YEAR_PART| \
BLPAPI_DATETIME_MONTH_PART| \
BLPAPI_DATETIME_DAY_PART)
#define BLPAPI_DATETIME_TIME_PART (BLPAPI_DATETIME_HOURS_PART| \
BLPAPI_DATETIME_MINUTES_PART| \
BLPAPI_DATETIME_SECONDS_PART)
#define BLPAPI_DATETIME_TIMEMILLI_PART (BLPAPI_DATETIME_TIME_PART| \
BLPAPI_DATETIME_MILLISECONDS_PART)
#define BLPAPI_DATETIME_TIMEFRACSECONDS_PART (BLPAPI_DATETIME_TIME_PART| \
BLPAPI_DATETIME_FRACSECONDS_PART)
#define BLPAPI_EVENTTYPE_ADMIN 1
#define BLPAPI_EVENTTYPE_SESSION_STATUS 2
#define BLPAPI_EVENTTYPE_SUBSCRIPTION_STATUS 3
#define BLPAPI_EVENTTYPE_REQUEST_STATUS 4
#define BLPAPI_EVENTTYPE_RESPONSE 5
#define BLPAPI_EVENTTYPE_PARTIAL_RESPONSE 6
#define BLPAPI_EVENTTYPE_SUBSCRIPTION_DATA 8
#define BLPAPI_EVENTTYPE_SERVICE_STATUS 9
#define BLPAPI_EVENTTYPE_TIMEOUT 10
#define BLPAPI_EVENTTYPE_AUTHORIZATION_STATUS 11
#define BLPAPI_EVENTTYPE_RESOLUTION_STATUS 12
#define BLPAPI_EVENTTYPE_TOPIC_STATUS 13
#define BLPAPI_EVENTTYPE_TOKEN_STATUS 14
#define BLPAPI_EVENTTYPE_REQUEST 15
#define BLPAPI_ELEMENT_INDEX_END 0xffffffff
#define BLPAPI_STATUS_ACTIVE 0
#define BLPAPI_STATUS_DEPRECATED 1
#define BLPAPI_STATUS_INACTIVE 2
#define BLPAPI_STATUS_PENDING_DEPRECATION 3
#define BLPAPI_SUBSCRIPTIONSTATUS_UNSUBSCRIBED 0
#define BLPAPI_SUBSCRIPTIONSTATUS_SUBSCRIBING 1
#define BLPAPI_SUBSCRIPTIONSTATUS_SUBSCRIBED 2
#define BLPAPI_SUBSCRIPTIONSTATUS_CANCELLED 3
#define BLPAPI_SUBSCRIPTIONSTATUS_PENDING_CANCELLATION 4
#define BLPAPI_CLIENTMODE_AUTO 0
#define BLPAPI_CLIENTMODE_DAPI 1
#define BLPAPI_CLIENTMODE_SAPI 2
#define BLPAPI_CLIENTMODE_COMPAT_33X 16
#define BLPAPI_ELEMENTDEFINITION_UNBOUNDED -1
#define BLPAPI_RESOLVEMODE_DONT_REGISTER_SERVICES 0
#define BLPAPI_RESOLVEMODE_AUTO_REGISTER_SERVICES 1
#define BLPAPI_SEATTYPE_INVALID_SEAT -1
#define BLPAPI_SEATTYPE_BPS 0
#define BLPAPI_SEATTYPE_NONBPS 1
#define BLPAPI_SERVICEREGISTRATIONOPTIONS_PRIORITY_LOW 0
#define BLPAPI_SERVICEREGISTRATIONOPTIONS_PRIORITY_MEDIUM INT_MAX/2
#define BLPAPI_SERVICEREGISTRATIONOPTIONS_PRIORITY_HIGH INT_MAX
#define BLPAPI_REGISTRATIONPARTS_DEFAULT 0x1
#define BLPAPI_REGISTRATIONPARTS_PUBLISHING 0x2
#define BLPAPI_REGISTRATIONPARTS_OPERATIONS 0x4
#define BLPAPI_REGISTRATIONPARTS_SUBSCRIBER_RESOLUTION 0x8
#define BLPAPI_REGISTRATIONPARTS_PUBLISHER_RESOLUTION 0x10
#if defined(_WIN32) || defined(__WIN32__) && \
! (defined(cygwin) || defined(__cygwin))
#ifdef BLPAPI_BUILD
#define BLPAPI_EXPORT __declspec(dllexport)
#else
#define BLPAPI_EXPORT __declspec(dllimport)
#endif
#elif __APPLE__
#define BLPAPI_EXPORT __attribute__((visibility("default")))
#else
#define BLPAPI_EXPORT
#endif
#endif // #ifndef INCLUDED_BLPAPI_DEFS
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright 2012. Bloomberg Finance L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: The above
* copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
// blpapi_streamproxy.h -*-C++-*-
#ifndef INCLUDED_BLPAPI_STREAMPROXY
#define INCLUDED_BLPAPI_STREAMPROXY
//@PURPOSE: A signature for callback on print and default C++ implementation
//
//@DESCRIPTION:
// This file defines 'blpapi_StreamWriter_t' a function pointer type.
// The user of the C API need to specify a callback of above type which will
// be called on xxx_print(...) with the formatted data. For C++ API, a default
// callback is specified which writes data to the stream specified in
// xxx::print
typedef int(*blpapi_StreamWriter_t)(const char* data,
int length,
void *stream);
#ifdef __cplusplus
#include <ostream>
namespace BloombergLP {
namespace blpapi {
inline int OstreamWriter(const char *data, int length, void *stream);
// DEPRECATED
// ==================
// struct StreamProxy
// ==================
struct StreamProxyOstream {
static int writeToStream(const char* data, int length, void *stream);
// Format, to the specified 'stream', which must be a pointer to a
// 'std::ostream', the specified 'length' bytes of the specified 'data'.
};
//=============================================================================
// INLINE FUNCTION DEFINITIONS
//=============================================================================
inline
int StreamProxyOstream::writeToStream(const char *data,
int length,
void *stream)
{
reinterpret_cast<std::ostream*>(stream)->write(data, length);
return 0;
}
inline
int OstreamWriter(const char *data, int length, void *stream)