-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLoans.py
59 lines (49 loc) · 1.63 KB
/
getLoans.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import requests
import pandas as pd
# load dbs
LO_db = pd.read_csv("LO_db.csv")
user_db = pd.read_csv("user_db.csv")
def getPMloans(code):
data = {'lender_groups[]': code,
'currencies[]': '978',
'with_buyback': '1',
'max_results': '20',
'sort_field': 'interest',
'sort_order': 'DESC',
'format': 'json'
}
response = requests.post('https://www.mintos.com/webapp/api/en/market/primary/list', data=data)
try:
return response.json()["data"]["list"][3]["loan_rate_percent"][:4]+'%'
except:
return 'No PM Loans'
def getSMloans(code):
data = {'lender_groups[]': code,
'max_premium': '0.0',
'statuses^[^]': '256',
'currencies^[^]': '978',
'with_buyback': '1',
'max_results': '20',
'sort_field': 'ytm',
'sort_order': 'DESC',
'page': '1',
'format': 'json'
}
response = requests.post('https://www.mintos.com/webapp/api/en/market/secondary/list', data=data)
try:
return response.json()["data"]["list"][3]["yield_to_maturity"][:4]+'%'
except:
return 'No SM Loans'
def getLoans(chosenLOs):
df = LO_db[LO_db.LO.isin(chosenLOs)]
pm_interests = []
sm_interests = []
for LO in df['Code']:
pm_interests.append(getPMloans(LO))
sm_interests.append(getSMloans(LO))
df['PM Interest'] = pm_interests
df['SM Interest'] = sm_interests
return df.drop('Code', axis=1).to_markdown(showindex=False)
if __name__ == '__main__':
print('Testing for Mogo')
getLoans([2])