### Install xbbg library Source: https://xbbg.readthedocs.io/en/latest/index Installs the xbbg Python package using pip. ```python pip install xbbg ``` -------------------------------- ### Install Bloomberg Python API Source: https://xbbg.readthedocs.io/en/latest/index Installs the official Bloomberg Python API from a specific index URL. ```python pip install blpapi --index-url=https://bcms.bloomberg.com/pip/simple/ ``` -------------------------------- ### Fetch Intraday Bars using BDIB Source: https://xbbg.readthedocs.io/en/latest/index Retrieves intraday bar data (open, high, low, close, volume) for a ticker on a specific date using the BDIB function. The example shows the last few entries of the day. ```python In [9]: blp.bdib(ticker='BHP AU Equity', dt='2018-10-17').tail() Out[9]: BHP AU Equity open high low close volume num_trds 2018-10-17 15:56:00+11:00 33.62 33.65 33.62 33.64 16660 126 2018-10-17 15:57:00+11:00 33.65 33.65 33.63 33.64 13875 156 2018-10-17 15:58:00+11:00 33.64 33.65 33.62 33.63 16244 159 2018-10-17 15:59:00+11:00 33.63 33.63 33.61 33.62 16507 167 2018-10-17 16:10:00+11:00 33.66 33.66 33.66 33.66 1115523 216 ``` -------------------------------- ### Retrieve Adjusted Historical Prices (BDH) Source: https://xbbg.readthedocs.io/en/latest/index Fetches historical price data for a given equity ticker and field, specifying start and end dates. The 'adjust' parameter set to 'all' retrieves data adjusted for dividends and splits. ```python import blp blp.bdh('AAPL US Equity', 'Px_Last', '20140606', '20140609', adjust='all') ``` -------------------------------- ### Retrieve Unadjusted Historical Prices (BDH) Source: https://xbbg.readthedocs.io/en/latest/index Fetches historical price data for a given equity ticker and field, specifying start and end dates. The 'adjust' parameter set to '-' retrieves data without adjustments for dividends and splits. ```python import blp blp.bdh('AAPL US Equity', 'Px_Last', '20140606', '20140609', adjust='-') ``` -------------------------------- ### Import blp module from xbbg Source: https://xbbg.readthedocs.io/en/latest/index Imports the 'blp' module from the 'xbbg' library, commonly used for Bloomberg data requests. ```python from xbbg import blp ``` -------------------------------- ### Fetch Intraday Bars with Reference Exchange using BDIB Source: https://xbbg.readthedocs.io/en/latest/index Retrieves intraday bar data using BDIB, specifying a reference exchange ('ref') to help resolve market hours for tickers. This is useful for exchanges not directly mapped in configuration. ```python In [10]: blp.bdib(ticker='ESM0 Index', dt='2020-03-20', ref='ES1 Index').tail() out[10]: ESM0 Index open high low close volume num_trds value 2020-03-20 16:55:00-04:00 2,260.75 2,262.25 2,260.50 2,262.00 412 157 931,767.00 2020-03-20 16:56:00-04:00 2,262.25 2,267.00 2,261.50 2,266.75 812 209 1,838,823.50 2020-03-20 16:57:00-04:00 2,266.75 2,270.00 2,264.50 2,269.00 1136 340 2,576,590.25 2020-03-20 16:58:00-04:00 2,269.25 2,269.50 2,261.25 2,265.75 1077 408 2,439,276.00 2020-03-20 16:59:00-04:00 2,265.25 2,272.00 2,265.00 2,266.50 1271 378 2,882,978.25 ``` -------------------------------- ### Retrieve Dividend Data for Equities Source: https://xbbg.readthedocs.io/en/latest/index Retrieves dividend information, including payment dates, ex-dates, and amounts, for a list of equity tickers within a specified date range. Uses the 'blp' library. ```python import blp blp.dividend(['C US Equity', 'MS US Equity'], start_date='2018-01-01', end_date='2018-05-01') ``` -------------------------------- ### Dividends API Source: https://xbbg.readthedocs.io/en/latest/index Fetches dividend information for one or more equity tickers within a specified date range. ```APIDOC ## GET /api/dividends ### Description Retrieves dividend payment details for specified equity tickers, including dates, amounts, and frequency, within a given date range. ### Method GET ### Endpoint /api/dividends ### Parameters #### Query Parameters - **tickers** (array of strings) - Required - A list of equity ticker symbols (e.g., ['C US Equity', 'MS US Equity']). - **start_date** (string) - Required - The start date for the dividend search (YYYY-MM-DD). - **end_date** (string) - Required - The end date for the dividend search (YYYY-MM-DD). ### Request Example ``` GET /api/dividends?tickers=["C US Equity", "MS US Equity"]&start_date=2018-01-01&end_date=2018-05-01 ``` ### Response #### Success Response (200) - **data** (object) - A structured object where keys are ticker symbols and values are arrays of dividend records. Each record includes dates, dividend amount, frequency, and type. #### Response Example ```json { "data": { "C US Equity": [ { "dec_date": "2018-01-18", "ex_date": "2018-02-02", "rec_date": "2018-02-05", "pay_date": "2018-02-23", "dvd_amt": "0.32", "dvd_freq": "Quarter", "dvd_type": "Regular Cash" } ], "MS US Equity": [ { "dec_date": "2018-04-18", "ex_date": "2018-04-27", "rec_date": "2018-04-30", "pay_date": "2018-05-15", "dvd_amt": "0.25", "dvd_freq": "Quarter", "dvd_type": "Regular Cash" }, { "dec_date": "2018-01-18", "ex_date": "2018-01-30", "rec_date": "2018-01-31", "pay_date": "2018-02-15", "dvd_amt": "0.25", "dvd_freq": "Quarter", "dvd_type": "Regular Cash" } ] } } ``` ``` -------------------------------- ### Fetch Intraday Bars within Market Session using BDIB Source: https://xbbg.readthedocs.io/en/latest/index Retrieves intraday bar data for a specific part of the trading session (e.g., 'am_open_30' for the first 30 minutes) using the BDIB function. Requires a ticker and date. ```python In [11]: blp.bdib(ticker='7974 JT Equity', dt='2018-10-17', session='am_open_30').tail() Out[11]: 7974 JT Equity open high low close volume num_trds 2018-10-17 09:27:00+09:00 39,970.00 40,020.00 39,970.00 39,990.00 10800 44 2018-10-17 09:28:00+09:00 39,990.00 40,020.00 39,980.00 39,980.00 6300 33 ``` -------------------------------- ### Fetch Security Name and Sector using BDP Source: https://xbbg.readthedocs.io/en/latest/index Retrieves the security name and GICS sector name for a given ticker using the BDP function. Requires a valid Bloomberg API connection. ```python In [2]: blp.bdp(tickers='NVDA US Equity', flds=['Security_Name', 'GICS_Sector_Name']) Out[2]: security_name gics_sector_name NVDA US Equity NVIDIA Corp Information Technology ``` -------------------------------- ### Fetch Historical Price Data with Excel-like Parameters using BDH Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical High, Low, and Last Price data using BDH with parameters similar to Excel's financial functions. 'Per' for period, 'Fill' for filling missing values, and 'Days' for day count convention. ```python In [5]: blp.bdh( ...: tickers='SHCOMP Index', flds=['High', 'Low', 'Last_Price'], ...: start_date='2018-09-26', end_date='2018-10-20', ...: Per='W', Fill='P', Days='A', ...: ) Out[5]: SHCOMP Index High Low Last_Price 2018-09-28 2,827.34 2,771.16 2,821.35 2018-10-05 2,827.34 2,771.16 2,821.35 2018-10-12 2,771.94 2,536.66 2,606.91 2018-10-19 2,611.97 2,449.20 2,550.47 ``` -------------------------------- ### Fetch Weighted Average Price with Overrides using BDP Source: https://xbbg.readthedocs.io/en/latest/index Fetches the weighted average price (VWAP) for a ticker on a specific date using the BDP function with overrides. The VWAP_Dt parameter specifies the date for the calculation. ```python In [3]: blp.bdp('AAPL US Equity', 'Eqy_Weighted_Avg_Px', VWAP_Dt='20181224') Out[3]: eqy_weighted_avg_px AAPL US Equity 148.75 ``` -------------------------------- ### Retrieve Corporate Earnings by Geography Source: https://xbbg.readthedocs.io/en/latest/index Fetches corporate earnings data for a given equity, specifying geographical breakdown, fiscal year, and number of periods. Requires the 'blp' library and an active Bloomberg connection. ```python import blp blp.earning('AMD US Equity', by='Geo', Eqy_Fund_Year=2017, Number_Of_Periods=1) ``` -------------------------------- ### Fetch Adjusted Historical Prices using BDH Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical 'Px_Last' data for a ticker with adjustments for dividends and splits by setting CshAdjNormal, CshAdjAbnormal, and CapChg to True. ```python In [7]: blp.bdh( ...: 'AAPL US Equity', 'Px_Last', '20140605', '20140610', ...: CshAdjNormal=True, CshAdjAbnormal=True, CapChg=True ...: ) Out[7]: AAPL US Equity Px_Last 2014-06-05 85.45 2014-06-06 85.22 2014-06-09 86.58 2014-06-10 87.09 ``` -------------------------------- ### Fetch Dividend History using BDS Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical dividend information for a ticker, including declaration date, ex-date, and dividend amount, using the BDS function. Requires specifying date ranges for dividends. ```python In [8]: blp.bds('AAPL US Equity', 'DVD_Hist_All', DVD_Start_Dt='20180101', DVD_End_Dt='20180531') Out[8]: declared_date ex_date record_date payable_date dividend_amount dividend_frequency dividend_type AAPL US Equity 2018-05-01 2018-05-11 2018-05-14 2018-05-17 0.73 Quarter Regular Cash AAPL US Equity 2018-02-01 2018-02-09 2018-02-12 2018-02-15 0.63 Quarter Regular Cash ``` -------------------------------- ### Fetch Unadjusted Historical Prices using BDH Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical 'Px_Last' data for a ticker without adjustments for dividends and splits by setting CshAdjNormal, CshAdjAbnormal, and CapChg to False. ```python In [6]: blp.bdh( ...: 'AAPL US Equity', 'Px_Last', '20140605', '20140610', ...: CshAdjNormal=False, CshAdjAbnormal=False, CapChg=False ...: ) Out[6]: AAPL US Equity Px_Last 2014-06-05 647.35 2014-06-06 645.57 2014-06-09 93.70 2014-06-10 94.25 ``` -------------------------------- ### Fetch Historical Price Data using BDH Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical High, Low, and Last Price data for a given ticker within a specified date range using the BDH function. Requires a valid Bloomberg API connection. ```python In [4]: blp.bdh( ...: tickers='SPX Index', flds=['High', 'Low', 'Last_Price'], ...: start_date='2018-10-10', end_date='2018-10-20', ...: ) Out[4]: SPX Index High Low Last_Price 2018-10-10 2,874.02 2,784.86 2,785.68 2018-10-11 2,795.14 2,710.51 2,728.37 2018-10-12 2,775.77 2,729.44 2,767.13 2018-10-15 2,775.99 2,749.03 2,750.79 2018-10-16 2,813.46 2,766.91 2,809.92 2018-10-17 2,816.94 2,781.81 2,809.21 2018-10-18 2,806.04 2,755.18 2,768.78 2018-10-19 2,797.77 2,760.27 2,767.78 ``` -------------------------------- ### Historical Data API (BDH) Source: https://xbbg.readthedocs.io/en/latest/index Retrieves historical data for a given security and field, with options to adjust for dividends and splits. ```APIDOC ## GET /api/bdh ### Description Fetches historical data for a specified security, field, and date range. Supports adjustments for dividends and stock splits using the `adjust` parameter. ### Method GET ### Endpoint /api/bdh ### Parameters #### Query Parameters - **ticker** (string) - Required - The security ticker symbol (e.g., 'AAPL US Equity'). - **field** (string) - Required - The data field to retrieve (e.g., 'Px_Last'). - **start_date** (string) - Required - The start date for historical data (YYYYMMDD format). - **end_date** (string) - Required - The end date for historical data (YYYYMMDD format). - **adjust** (string) - Optional - Type of adjustment. Use '-' for no adjustment, 'dividends' for dividend adjustment, 'splits' for split adjustment, or 'all' for both. ### Request Example ``` GET /api/bdh?ticker=AAPL US Equity&field=Px_Last&start_date=20140606&end_date=20140609&adjust=- ``` ### Response #### Success Response (200) - **data** (object) - A nested object containing the historical data, with dates as keys and values for the requested field. #### Response Example (No Adjustment) ```json { "data": { "2014-06-06": { "AAPL US Equity": { "Px_Last": 645.57 } }, "2014-06-09": { "AAPL US Equity": { "Px_Last": 93.70 } } } } ``` #### Response Example (Adjusted for Dividends and Splits) ```json { "data": { "2014-06-06": { "AAPL US Equity": { "Px_Last": 85.22 } }, "2014-06-09": { "AAPL US Equity": { "Px_Last": 86.58 } } } } ``` ``` -------------------------------- ### Corporate Earnings API Source: https://xbbg.readthedocs.io/en/latest/index Retrieves corporate earnings data for a given security, allowing filtering by geography and fiscal year. ```APIDOC ## GET /api/earnings ### Description Retrieves corporate earnings data for a specified equity, with options to filter by geographic region and fiscal year, and to specify the number of periods. ### Method GET ### Endpoint /api/earnings ### Parameters #### Query Parameters - **ticker** (string) - Required - The equity ticker symbol (e.g., 'AMD US Equity'). - **by** (string) - Optional - The geographical breakdown for earnings (e.g., 'Geo'). - **Eqy_Fund_Year** (integer) - Optional - The fiscal year for which to retrieve earnings. - **Number_Of_Periods** (integer) - Optional - The number of fiscal periods to include. ### Request Example ``` GET /api/earnings?ticker=AMD US Equity&by=Geo&Eqy_Fund_Year=2017&Number_Of_Periods=1 ``` ### Response #### Success Response (200) - **data** (object) - A nested object containing earnings data, including levels, fiscal year values, and percentage changes. #### Response Example ```json { "data": { "Asia-Pacific": { "level": 1.00, "fy2017": "3,540.00", "fy2017_pct": "66.43" }, "Asia-Pacific.China": { "level": 2.00, "fy2017": "1,747.00", "fy2017_pct": "49.35" } } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.