Skip to main content

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
```

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.88.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file tradingeconomics-0.2.88.tar.gz.

File metadata

File hashes

Hashes for tradingeconomics-0.2.88.tar.gz
Algorithm Hash digest
SHA256 5d15dfeb7360dbd83dbbd24e83a1d073aea2f5588abdabde41c58ae08401a14f
MD5 5051d41a8687cc55c88063bdc3f22f43
BLAKE2b-256 b4e3114b4fe160a0424b3c3df2730cf0c1b2a0a2199d4e9124533c82dc2f365d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page