English 中文(简体)
我怎样才能确保Excel能和Bloomberg保持连接, 进行电子表格自动化?
原标题:How can I make sure Excel will remain connected to Bloomberg to perform spreadsheets automations?
I will try to make this issue as clear as possible as I am a beginner and I struggle tof find a solution to this issue. The goal is to run a python code that automatically open excel, run some macros that are used on Bloomberg formulas then close everything. My python code looks like that: import time import win32com.client as win32 import gc def update_excel_and_send_email(): excel = win32.gencache.EnsureDispatch( Excel.Application ) excel.Visible = False try: wb = excel.Workbooks.Open( mypath ) wb.RefreshAll() time.sleep(10) excel.Application.Run("Send2") except Exception as e: print("Error: " + str(e)) finally: wb.Close(SaveChanges=False) excel.Quit() excel = None gc.collect() if __name__ == __main__ : update_excel_and_send_email() Example of the bbg formulas that I am using Basically, the code is opening an instance of excel, running the macro, then closes. My dream goal is to be able to run these Macros without having excel to pop up on my screen. I am always connected to bloomberg, and I also want to be able to execute this code even if my computer is locked, thanks to a scheduler. It works for an hour or two even if my computer is locked, then randomly, all the formulas that I receive by email thanks to the macros are not updated anymore with bbg and are displayed as #N/A. I ve been trying to refresh Bloomberg with formulas each time I run my macros with excel but it doesn t work when excel crashes. These are my two observations: When it crashes, even if I open the excel sheet manually, every data remains N/A, thus I need to completely close excel and open it again to correctly refresh the formulas. Formulas sometimes are not getting refreshed if excel is in background (big issue for me as I wish that I could run all that in background without having to painfully wait that all the macros are done running) Any help will be more than welcome as I really struggle with this issue and can t find a viable solution for now. Many thanks for your help
问题回答
Contrary to @braX d comment, that s not a website but a Bloomberg API request within Excel. You can skip Excel and use the API directly. WAPI has all details you may need (or search here for lots of content). If you really want an Excel format, export the data feed to an Excel workbook once you get the data. That said, it s breaching the data feed addendum everyone signs when you try to distribute (email) the data. The standard API is for desktop use, which means you should not have access without being actively involved in the process of looking at the data. The connection breaks after a while for this reason (also whenever you look up stuff on your phones app). If you need automated downloads you should use data license offerings.




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签