Library to download data from Trading Economics API
Project description
---
title: "Trading Economics API"
output: html_document
---
#Load Data Directly Into Python
If you don’t already have a copy of Python installed on your computer, you can get it from oficial website https://www.python.org/downloads/.
It's recomended to install pip, it is a package management system used to install and manage software packages written in Python. All information you can find on https://packaging.python.org/installing/. Then just type in Python (command line)
```python
pip install tradingeconomics
```
There is a possibility to install package using easy_install
```python
easy_install https://pypi.python.org/packages/4c/b4/e2e2a9668be305a42c0644b3eb5d4d1034ae062653ef737d7e80c1423d28/tradingeconomics-0.2.x.tar.gz
```
Where 'x' is last version number.
As alternatyive you can download package from https://pypi.python.org/pypi/tradingeconomics and then follow the install instructions for [Python 3.x](https://docs.python.org/3/install/) or [Python 2.x](https://docs.python.org/2/install/)
Another method is to download folder from GitHub https://github.com/ieconomics/open-api/tree/master/python and then place this folder in your Python library folder.
###Lets start
In command window type
```python
import tradingeconomics as te
te.login('APIkey')
```
If you don't have APIkey just left empty space in brackets.
**Note:** Without APIkey datasets will default to returning sample data.
###How to Use
Results are available in differente formats, such as : JSON, pandas.DataFrame or dictionary.
To get calendar data for specific country, in data frame format, just type
```python
te.getCalendarData(country = 'Italy', output_type = 'df')
```
In some cases initial date and end date could be specified
```python
te.getHistoricalData(country = 'United Kingdom', indicator = 'GDP', initDate= '1990-01-01', endDate= '2015-01-01')
```
For several countries and indicators
```python
te.getHistoricalData(country = ['United States', 'Germany'], indicator = ['Exports','Imports', 'GDP'], initDate= '1990-01-01', endDate= '2015-01-01')
```
To get stock market index just type
```python
te.getMarketsData(marketsField = 'index', output_type = 'df')
```
Forecasted values for spcifique countrie, in this case Portugal.
```python
te.getForecastData(country = 'Portugal', output_type = 'df')
```
Next code will give you Country/Indicator pair
```python
te.getIndicatorData(country = 'United Kingdom', indicators = 'Imports')
```
###Bonus
Easy graphical representation
```python
import matplotlib.pyplot as plt
mydata = te.getHistoricalData(country = 'United Kingdom', indicators = 'GDP')
plt.plot(mydata)
```
![](C:\Users\Analyst\Desktop/uk_gdp.png)
and some stratistics
```python
import numpy as np
np.average(mydata)
# 1081.0103571428572
np.median(mydata)
# 827.63999999999999
np.std(mydata)
# 953.846661
np.max(mydata)
# 2990.2
np.min(mydata)
# 72.33
```
title: "Trading Economics API"
output: html_document
---
#Load Data Directly Into Python
If you don’t already have a copy of Python installed on your computer, you can get it from oficial website https://www.python.org/downloads/.
It's recomended to install pip, it is a package management system used to install and manage software packages written in Python. All information you can find on https://packaging.python.org/installing/. Then just type in Python (command line)
```python
pip install tradingeconomics
```
There is a possibility to install package using easy_install
```python
easy_install https://pypi.python.org/packages/4c/b4/e2e2a9668be305a42c0644b3eb5d4d1034ae062653ef737d7e80c1423d28/tradingeconomics-0.2.x.tar.gz
```
Where 'x' is last version number.
As alternatyive you can download package from https://pypi.python.org/pypi/tradingeconomics and then follow the install instructions for [Python 3.x](https://docs.python.org/3/install/) or [Python 2.x](https://docs.python.org/2/install/)
Another method is to download folder from GitHub https://github.com/ieconomics/open-api/tree/master/python and then place this folder in your Python library folder.
###Lets start
In command window type
```python
import tradingeconomics as te
te.login('APIkey')
```
If you don't have APIkey just left empty space in brackets.
**Note:** Without APIkey datasets will default to returning sample data.
###How to Use
Results are available in differente formats, such as : JSON, pandas.DataFrame or dictionary.
To get calendar data for specific country, in data frame format, just type
```python
te.getCalendarData(country = 'Italy', output_type = 'df')
```
In some cases initial date and end date could be specified
```python
te.getHistoricalData(country = 'United Kingdom', indicator = 'GDP', initDate= '1990-01-01', endDate= '2015-01-01')
```
For several countries and indicators
```python
te.getHistoricalData(country = ['United States', 'Germany'], indicator = ['Exports','Imports', 'GDP'], initDate= '1990-01-01', endDate= '2015-01-01')
```
To get stock market index just type
```python
te.getMarketsData(marketsField = 'index', output_type = 'df')
```
Forecasted values for spcifique countrie, in this case Portugal.
```python
te.getForecastData(country = 'Portugal', output_type = 'df')
```
Next code will give you Country/Indicator pair
```python
te.getIndicatorData(country = 'United Kingdom', indicators = 'Imports')
```
###Bonus
Easy graphical representation
```python
import matplotlib.pyplot as plt
mydata = te.getHistoricalData(country = 'United Kingdom', indicators = 'GDP')
plt.plot(mydata)
```
![](C:\Users\Analyst\Desktop/uk_gdp.png)
and some stratistics
```python
import numpy as np
np.average(mydata)
# 1081.0103571428572
np.median(mydata)
# 827.63999999999999
np.std(mydata)
# 953.846661
np.max(mydata)
# 2990.2
np.min(mydata)
# 72.33
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tradingeconomics-0.2.931.tar.gz
(12.0 kB
view hashes)
Built Distribution
Close
Hashes for tradingeconomics-0.2.931-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a368d1a49a8ee6a3bddc9e05615dcd6b4c4845fba1e0215305c4af1beed98ecc |
|
MD5 | 6dfb24b40ea9f1abaa9ae91b78d0a7d8 |
|
BLAKE2b-256 | d5e7bc8b1c35007f8bd8ef5bb1c0e55f2fefaabecfc981b97b654e5b7bc4383b |