Skip to content

Commit

Permalink
Bloomberg File conversion added
Browse files Browse the repository at this point in the history
  • Loading branch information
deolekar committed Apr 7, 2024
1 parent 3ee4fbb commit f173e5a
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Sample/inputcsv_to_bbg.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
|||ID_BB_COMPANY|ID_BB_SECURITY|ID_CUSIP|ID_ISIN|TICKER|ID_BB_UNIQUE|CPN|MATURITY|NAME|RTG_SP|RTG_SP_WATCH|RTG_SP_NO_WATCH|RTG_SP_WATCH_DT|SP_EFF_DT|RTG_SP_LONG|RTG_SP_SHRT|RTG_SP_LONG_RATING_DT|RTG_SP_SHRT_RATING_DT
03061NHE1 Mtge|0|18|700043| |03061NHE1|U103061NHE22|AMCAR|MG!!00FE61|1.278000|20050606|AMCAR 2004-1 A1|A-1+| |A-1+| |20090617| |A-1+| |20090617|
055237AA2 Mtge|0|18|700080| |055237AA2|U1055237AA98|BAMT|MG!!0000E2|4.110000|20030815|BAMT 1997-A A|AAA| |AAA| |19991217|AAA| |19991217| |
055237AB3 Mtge|0|18|700080| |055237AB3|U1055237AB71|BAMT|MG!!0000E4|4.120000|20030815|BAMT 1997-A B|A| |A| |19991217|A| |19991217| |
096647AE4 Mtge|0|18|700112| |096647AE4|U1096647AE27|BOAT|MG!!0000E5|5.752500|19970808|BOAT 1998-A A1|A-1+| |A-1+| |19990719| |A-1+| |19990719|
3 changes: 2 additions & 1 deletion SecuMas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .isin import dummy , validate
from .cusip import dummy , validate
from .sedol import dummy , validate
from .gics import gics
from .gics import gics
from .bbgbo import fromcsv
42 changes: 42 additions & 0 deletions SecuMas/bbgbo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import csv

def fromcsv(csvFile,bbgFile):
rowCount =0

bbg = open(bbgFile,'w')

#results = []
with open(csvFile, newline='') as inputfile:
xs = csv.reader(inputfile)
for idx, x in enumerate(xs):
if (idx == 0):
bbg.write("START-OF-FILE\n")
bbg.write("PROGRAMNAME=getdata\n")
bbg.write("DATEFORMAT=yyyymmdd\n")
bbg.write("\n")
bbg.write("START-OF-FILE\n")

x=x[0]
headers = x.split("|")
for i, header in enumerate(headers):
if(i>2):
field = header + "\n"
bbg.write(field)
bbg.write("END-OF-FIELDS\n")
bbg.write("\n")
bbg.write("TIMESTARTED=Tue Jul 13 14:17:17 EDT 2004\n")
bbg.write("START-OF-DATA\n")

else:
row = x[0] + "\n"
bbg.write(row)
rowCount+=1

if (rowCount>0):
bbg.write("END-OF-DATA\n")
rowCountRecord = "DATARECORDS="+str(rowCount)+"\n"
bbg.write(rowCountRecord)
bbg.write("TIMEFINISHED=Tue Jul 13 14:17:17 EDT 2004\n")
bbg.write("END-OF-FILE\n")

bbg.close()
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions docs/fileUtility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# File Utility

Utilities to convert market data vendor feed files

## Bloomberg

### CSV -> BBG

Utility for Bloomberg Back Office feed file conversion.
</br>

#### Input

Pipe delimited CSV with first row as header. [Sample](https://github.com/deolekar/SecuMas/blob/master/Sample/inputcsv_to_bbg.csv)

#### Output

BBG file at specified path.

```py
import SecuMas

SecuMas.bbgbo.fromcsv('path/to/inputcsv_to_bbg.csv','path/to/output_bbg_bo.dif')
```
8 changes: 8 additions & 0 deletions docs/lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ print(classification.sub_industry.code) #45203020
```

</br>
By default latest [GICS mapping](https://github.com/deolekar/SecuMas/tree/master/SecuMas/definitions) is referred. Below snippet point to previous version of the mapping.

```py
#classification = SecuMas.gics(<gics_code>, <date>)
classification = SecuMas.gics('45203020', '20180929')
```

</br>

0 comments on commit f173e5a

Please sign in to comment.