Python API
The Infront Python API is an easy way to analyse data with your own Python scripts. It provides finished wrapped data in data frames, and you can use it with a Command Line Interface (CLI). Using Infront’s Python API, you can conduct portfolio analyses, simulate extreme events and their effect on prices, and create visualizations and indicators to better understand the market dynamics and much more. Python, as your daily companion with your Infront Professional Terminal, provides you with over 114,000 open-source packages covering thousands of use cases.
To access the full functionality of the Python API, you will need:
- Infront Professional Terminal
- EOD Module
- Access to relevant market data
If you do not have access, please contact Infront.
How to open the Python API
First, you need to install Python.
- You can find the installation for Python here. Click "Download Python" and install Python on your computer.
- A new window will pop up, click "Customize installation".
- The next window will show optional features.
We recommend you to install all features. Select:- Documentation
- pip
- tcl/tk and DLE
- Python test suite
- py launcher and for all users
- Click "Next" which will forward you to a window with overview of "Advanced Options".
- Select "Associate files with Python."
- Create shortcuts for installed applications.
- Add Python to environment variables.
- Click "Install" and the installation will start.
Once you have installed Python, you can follow the instructions under the Infront Connect Installation. You can find this on our website.
How to use the Python API
Finding a symbol
The Feed and Ticker fields are required to find a match for an instrument. These can be found in the "Overview" window for the instrument in the Infront Professional Terminal. It is also possible to find this information in a watchlist. To do so, open a watchlist, add the preferable instrument and add the columns Ticker and Feed.
An example, Feed = "OSS" and Ticker = "DNB". In Python code it will look like this: ["OSS:DNB"]
To send an API request: You can use the documentation to send an API request here.
There are a few variables you can change:
- Tickers: You should change FEED and TICKER to the feed and ticker that you want to export history from. If you want to export data DNB from Oslo Stock Exchange you put in OSS instead of FEED and DNB instead of TICKER, for example ["OSS:DNB"]
- Fields: The fields that are supported in the Python API are
- open
- high
- low
- last (last value from the day before)
- turnover
- volume
- bid
- ask
- Start date: Here you can set the date from when you would like to get the historical data. The date format is "YYYY-MM-DD", for example "2019-01-01".
- End date: This date has the same format as Start_Date and you can set the last date in the period you want to export history from. If you set this to a future date, for example "2099-01-01", you will get all the data from the start date until yesterday’s date.
Example of an API request without information inserted
MySymbol = infront.GetHistory(tickers = ["FEED:TICKER"], fields = ["open", "high", "low", "last", "turnover", "volume", "bid", "ask"], start_date = "YYYY-MM-DD", end_date = "YYYY-MM-DD")Example of an API request with information inserted
(Ticker= DNB, Feed= OSS. Start_date= 2019-01-01, End_date= 2099-01-01: MySymbol = infront.GetHistory(tickers = ["OSS:DNB"], fields = ["open", "high", "low", "last", "turnover", "volume", "bid", "ask"], start_date = "2019-01-01", end_date = "2099-01-31")
The data that can be retrieved with Python API includes:
- Historical Data
- Stocks, bonds, futures, forex, warrants
- Fields: open, high, low, last, turnover, volume, bid, ask