-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmarquee.py
81 lines (61 loc) · 1.97 KB
/
marquee.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from flask import request
import requests
import json
import datetime
auth_data = {
"grant_type" : "client_credentials",
"client_id" : "27590ede7e3d454c82374eaa8b5a7531",
"client_secret" : "e341794fbc0a39a030263ebeb270fe8253f2380f52cd306e856f4dda70ba40f5",
"scope" : "read_product_data"
}
class Data(object):
def __init__(self, ticker):
self.TCK = ticker
self.growth = []
self.financialReturns = []
self.integrated = []
self.multiples = []
def addGrowth(self, point):
self.growth.append(point)
def addFinancialReturns(self, point):
self.financialReturns.append(point)
def addIntegerated(self, point):
self.integrated.append(point)
def addMultiples(self, point):
self.multiples.append(point)
def getMarqueeData(ticker):
# Create a session instance
session = requests.Session()
auth_request = session.post("https://idfs.gs.com/as/token.oauth2", data = auth_data)
access_token_dict = json.loads(auth_request.text)
access_token = access_token_dict["access_token"]
#Update session headers with the access token
session.headers.update({"Authorization":"Bearer "+ access_token})
#URL for the request
request_url = "https://api.marquee.gs.com/v1/data/USCANFPP_MINI/query"
request_query = {}
#What we want to query
today = datetime.date.today()
startDate = "2009-01-01"
endDate = today.strftime("%Y-%m-%d")
request_query = {
"where": {
"gsid": [str(ticker)]
},
"startDate": startDate,
"endDate": endDate
}
#Get the POST request text
request = session.post(url=request_url, json=request_query)
results = json.loads(request.text)
returnData = Data(ticker)
print(type(results['data'][0]))
for dataPoint in results['data']:
try:
returnData.addGrowth([dataPoint['growthScore']])
returnData.addFinancialReturns([dataPoint['financialReturnsScore']])
returnData.addIntegerated([dataPoint['integratedScore']])
returnData.addMultiples([dataPoint['multipleScore']])
except:
continue
return returnData