Skip to content

Instantly share code, notes, and snippets.

@sadcracker
Last active June 19, 2021 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadcracker/a694b50492aceaf5a7e36a64e002a91d to your computer and use it in GitHub Desktop.
Save sadcracker/a694b50492aceaf5a7e36a64e002a91d to your computer and use it in GitHub Desktop.
BDS extraction
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from xbbg import blp\n",
"import time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## BDS values"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" ticker\n",
"0 MSFT US Equity\n",
"1 TSLA US Equity\n"
]
}
],
"source": [
"tickers = pd.read_csv ('Tiker_list_file_name.csv') #list of indexes with first row 'ticker'\n",
"print (tickers)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" field\n",
"0 CIE_DES_BULK\n"
]
}
],
"source": [
"bds_fields= pd.read_csv ('BDS_fields_file_name.csv') #list of fields from FLDS with first row 'field'\n",
"print (bds_fields)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for field in bds_fields.field:\n",
" temp_data = blp.bds(tickers.ticker,field)\n",
" temp_data.to_csv('./folder_name/' + field +'_.csv')\n",
" time.sleep(10) #delay for better API connection"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment