-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfibot_api.py
41 lines (31 loc) · 1.13 KB
/
fibot_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
# MS API for historical values
# monthly update
import json
import requests
def get_historical_values(fid, cur, freq, d1, d2):
api_token = ''
API_URL_BASE = "http://tools.morningstar.fr/api/rest.svc/timeseries_price/ok91jeenoo?"
P_ID = "id="
P_CUR = "¤cyId="
P_TYPE = "&idtype=Morningstar"
P_PRICE = "&priceType="
P_FREQ = "&frequency="
P_FROM = "&startDate="
P_TO = "&endDate="
P_FORMAT= "&outputType=COMPACTJSON"
api_url = API_URL_BASE + P_ID + fid + P_CUR + cur + P_TYPE + P_PRICE + P_FREQ + freq + P_FROM + d1 + P_TO + d2 + P_FORMAT
headers = {'Content-Type': 'application/json'}
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
return json.loads(response.content.decode('utf-8'))
else:
return None
def get_currencies():
api_url = 'http://api.openrates.io/latest'
headers = {'Content-Type': 'application/json'}
response = requests.get(api_url, headers=headers)
if response.status_code == 200:
return json.loads(response.content.decode('utf-8'))
else:
return None