Summary

If your market data needs are close-of-business, rather than real-time, this is the most effective way to utilize the Empirasign API.

How It Works

We put together an example script to ensure you never miss a piece of valuable market data.

In short, it performs a costless (from a quota perspective) API call to get a list of all bonds that we have collected market data on for a given day. You can then filter this list down to only sub-sectors you care about. For convenience, the /api/all-bonds/ endpoint returns CUSIP, ISIN, Bloomberg ticker and market subsector(s) as defined by openfigi.com. You can see the defintions and possible values of these extra sector fields here.

After you have winnowed down this list, you can then query the /api/bonds/ endpoint to ensure your local data store is a comprehensive and correct view of the marketplace. Up to 500 securities may be queried per call to the /api/bonds/ endoint, so you may have to batch them up.

The script is written in Python and does not import anything outside of the standard library (other than the ubiquitous requests library).

pseudo code

# run this after close of business (any time after 5PM EST should suffice)
all_bonds = api_call("/api/all-bonds/", "Mtge")
# all_bonds is now a list of all the bonds we have collected market data on for a given day

for chunk_500 in all_bonds:
    # can only poll 500 bonds per API call
    mkt_data = api_call("/api/bonds/", chunk_500)
    save_to_local_db(mkt_data)

repeat again at close of business tomorrow

You can find the actual Python code on github at the following URL: gist.github.com/empirasign/c8640a60011fde1a9a9b4643b9736475