cmallwitz / Financials-Extension

Extension for LibreOffice Calc to access stock market data
Other
137 stars 17 forks source link

Using Basic Macros #84

Open Mike-VB opened 1 year ago

Mike-VB commented 1 year ago

Thanks very much for your hard work. I am not familiar with Python - but, it looks like some significant coding. I have a Windows 10 computer with Libreofffice 7.4.4.2 X64. I am new to Libreoffice Macros (I have coded in VBA). I want to write some macros to watch tickers for setups that might be suitable for investing. I examined the Depot code that comes with Libreoffice to (re)learn Basic and see how they accessed financial data (Yahoo deleted the .csv feature). I would like to access your routines from my Basic macros. I have spent many hours trying to guess how to do it (here is an example):

oService = createUNOService("com.sun.star.sheet.addin.Financials") oPrice = com.sun.star.financials.getHistoric("GLD", 90, "2023-03-23", "YAHOO")

Do you have any sample code that works?

Mike-VB commented 1 year ago

I worked around this problem by inserting the GetRealTime() function in a cell in the spreadsheet. A hard update is required to update the value in the cell: oDocument = ThisComponent.CurrentController.Frame oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper") oDispatcher.executeDispatch(oDocument, ".uno:CalculateHard", "", 0, Array())