ExcelRtd is a functional module for accessing any data information within the VeighNa program in Excel. RTD, or RealTimeData, is an Excel data docking solution provided by Microsoft and designed primarily for real-time data needs in the financial industry. ExcelRtd relies on the PyXLLC module (www.pyxll.com). ), which is commercial software and needs to be purchased in order to use it (30 days free usage is provided).
In order to use the ExcelRtd module, the PyXLL plug-in needs to be installed. The steps are as follows:
First go to the PyXLL website and click DownloadPyXLL as shown below:
Then jump to the download screen, as shown below:
At this time you need to fill in the corresponding fields, in which Python Version choose Python3.10, and Excel Version according to their own version of Excel installed, generally 64bit (x64).
After filling in the form, click [Download PyXLL], and you will be redirected to the download page. After downloading the file, go to the folder where the file is located, hold down the shift key and click the right mouse button, select [Open a PowerShell window here] and run the following command:
pip install pyxll pyxll install
Then follow the software's instructions and it will install successfully.
Please note that when you get to the next step in the image below:
If you do not specify a path, it will be installed in the default location shown in the picture (remember this path as you will need to access this folder later).
Then go to the examples directory under that directory and put vnpy_rtd.py under the path
~/veighna_studio/Lib/site-packages/vnpy_excelrtd/ into that directory, as shown below:
The installation is now complete.
Loading VeighNa Station
After logging in to VeighNa Station, click the [Transaction] button, and check [ExcelRtd] in the [Application Module] column of the configuration dialog box.
Add the following code to the startup script:
# Write at the top from vnpy_excelrtd import ExcelRtdApp # Write after creating the main_engine object main_engine.add_app(ExcelRtdApp)
Start the module
Before starting the module, please connect to the trading interface (for details on how to do this, see the Connecting to the Interface section of the Basic Usage chapter). Start the module after you see "Contract Information Query Successful" in the [Log] column of the main interface of VeighNa Trader, as shown in the figure below:
Please note that the IB interface does not automatically get all the contract information when you log in, but only when you subscribe to the market manually. Therefore, you need to manually subscribe to contract quotes in the main interface before starting the module.
After successfully connecting to the trading interface, click [Functions] -> [Excel RTD] in the menu bar, or click Charts in the left button bar:
You can enter the UI interface of Excel RTD module, as shown in the following figure:
Functions and Configurations
After starting the Excel RTD module, you can call the functions provided by the module in an Excel table through PyXll (mainly to get real-time data through the rtd_tick_data function).
First open an excel table and call rtd_tick_data function in each cell and pass the corresponding parameters to get the corresponding data, as shown in the following figure:
The above figure is an example of obtaining real-time data for four fields of Soybean Oil 2205 (bid_price_1, high_price, low_price and last_price).
From the figure, we can see that the rtd_tick_data function takes two parameters: one is vt_symbol, and the other is the attribute of TickData defined in VeighNa (for specific attributes, please refer to the source code vnpy.trader.object.TickData). These two parameters are strings, the first parameter can be specified by the specific location of the cell, such as "A1" that the first row of column A data.
At the same time, in the graphical interface of the Excel RTD module can also see the corresponding output, as shown below:
Of course, the above is only a simple demonstration of the function of the ExcelRtd module. As for the specific data to be obtained and displayed on excel in what way, it is up to the user to write it according to their actual needs. Here we provide several advanced cases, including futures market quote tracking, market depth quote tracking and spread monitoring: