Serving the Quantitative Finance Community

 
User avatar
drinese18
Topic Author
Posts: 0
Joined: January 4th, 2008, 2:15 pm

Bloomberg Download

February 8th, 2008, 3:00 pm

I am not too familiar with downloading from Bloomberg using VBA coding, I have checked out the WAPI section but don't have much time to read through it, I basically want to download the daily yield for EONIA HP from Bloomberg, I've tried various codes but none really work, I don't want to use the Web Query method since I do have a dedicated Bloomberg Terminal and I don't want to use DDE either, I just want to find a way to download that value so if anyone can help me with this that would be great and does anyone know of a book that teaches you about the bloomberg VBA syntax?
 
User avatar
rmax
Posts: 374
Joined: December 8th, 2005, 9:31 am

Bloomberg Download

February 8th, 2008, 3:17 pm

This is tricky from a legal stand-point. You need to check whether the bloomer license will allow it as re-distribution of their data is a strict no no.
 
User avatar
drinese18
Topic Author
Posts: 0
Joined: January 4th, 2008, 2:15 pm

Bloomberg Download

February 8th, 2008, 3:23 pm

well yeh, my friend downloads data from bloomberg through coding, the thing is I'm too proud to ask him and I basically want to have an understanding of it for myself, he did show me a way but that was wayyyy too complicated
 
User avatar
Yossarian22
Posts: 4
Joined: March 15th, 2007, 2:27 am

Bloomberg Download

February 8th, 2008, 7:20 pm

There shouldn't be a book; the WAPI gives you all the examples you need!Here is a random snippet for some code i've used in the pastDim objBBG As BLP_DATA_CTRLLib.BlpDataIf objBBG Is Nothing Then Set objBBG = New BlpDataarrayfields = Array("Sales_Rev_Turn", "Ebit", "EBIT_MARGIN", "CF_NET_INC", "PROF_MARGIN", "CF_FREE_CASH_FLOW", "CASH_AND_EQUIV", "BS_TOT_ASSET", "RETURN_ON_ASSET", "RETURN_ON_CAP", "BS_TOT_EQY", "TOT_DEBT_TO_TOT_CAP", "LT_DEBT_TO_TOT_CAP", "TOT_DEBT_TO_EBITDA", "EBIT_TO_TOT_INT_EXP") Application.StatusBar = "Financial data downloading" Application.ScreenUpdating = True objBBG.DisplayNonTradingDays = Quarterly objBBG.NonTradingDayValue = ShowNoNumber 'objBBG.ReverseChronological = Not Sheets("Template").reverseBOX.Value If Sheets("Template").QuarterlyBox.Value = False Then objBBG.Periodicity = bbQuarterly Else objBBG.Periodicity = bbYearly 'Set r = Range(Cells(17, 3), Cells(21, 18)) End If Dim crncy As String crncy = Range("A27") If Sheets("Template").Range("years").Value = 5 And Sheets("Template").QuarterlyBox.Value = True Then BACKDAYS = 6 * 365 End If dim secCode = "F US Equity" ' set this equal to a range in your template ReSult = objBBG.BLPGetHistoricalData2(secCode, arrayfields, CDate(Date - BACKDAYS), crncy) uBoundNumber = UBound(ReSult) If (uBoundNumber <= 0) & Sheets("Template").QuarterlyBox.Value = False Then MsgBox ("There is no quarterly data available for this ticker sorry!") Exit Sub ElseIf (uBoundNumber <= 0) Then MsgBox ("There is no data available for this ticker sorry!") Exit Sub End If 'Inputting data for the specific obligor Dim numarrayfields numarrayfields = UBound(arrayfields) For i = 0 To numarrayfields If i = 0 Then For j = 0 To uBoundNumber Cells(17 + j, 3) = Left(ReSult(j, 0, 0), 10) 'GET THE DATE If Left(ReSult(j, 0, 1), 1) <> "#" Then _ Cells(j + 17, 4) = ReSult(j, 0, i + 1) Next j Else For j = 0 To uBoundNumber If Left(ReSult(j, 0, i + 1), 1) <> "#" Then Cells(j + 17, i + 4) = ReSult(j, 0, i + 1) ElseIf Left(ReSult(j, 0, i + 1), 1) = "#" Then Cells(j + 17, i + 4) = "Not Available" End If Next j End If Next i
 
User avatar
SeaHawk
Posts: 1
Joined: February 6th, 2009, 3:03 pm

Bloomberg Download

April 6th, 2009, 9:33 pm

Hi All, I try to download Bloomberg data and somehow it is not refreshing. All I got is something like "N/A Data Request". I have already added the refresh all workbook like but it's still not doing the job. The trick seems to be due to the fact that I have a command to paste value the bloomberg data after downloading. If I remove this command, then it works but I don't want bloomberg to automatically update the data for me. Thanks!---------------------------------------------------------------------------------------------------------------------------Public Sub LoadBloomberg() Dim CurveDate As String CurveDate = CStr(Format(Range("CurveDate"), "mm/dd/yyyy")) Dim Ticker As String Dim Analytics As String: Analytics = "Last_Price" Dim i As Integer Range("RatesInput").ClearContents For i = 1 To 25 Range("Rates").Offset(i - 1, 1) = CurveDate Range("Rates").Offset(i - 1, 2) = _ "=BDH($" & "C" & i + 6 & ", ""LAST_PRICE"" , " & _ """" & CurveDate & """" & ", " & """" & CurveDate & """)" Application.Run ("bloombergui.xla!RefreshAllWorkbooks") Next i For i = 1 To 25 Range("Rates").Offset(i - 1, 2) = Range("ST").Offset(i - 1, 2).Value Next i End Sub
 
User avatar
Shilo
Posts: 0
Joined: October 14th, 2007, 1:08 pm

Bloomberg Download

April 9th, 2009, 7:03 am

You can check DOCS 2047421 which has some examples of how to do this. You shouldnt use the BDx formulas within the VBA code. Hope this helps.