-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI Testing
More file actions
116 lines (104 loc) · 2.95 KB
/
API Testing
File metadata and controls
116 lines (104 loc) · 2.95 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 14 00:06:54 2018
@author: enshucheng
"""
import json
import requests
import pygame
#chartSimplify = True
#r = requests.get('https://api.iextrading.com/1.0/stock/qqq/company', params=chartSimplify)
#print(r.url)
#chart = r.json()
#print(chart)
def get_info():
print('Company Information Search')
symbol = input('Please enter the company symbol: ')
# symbol = 'amzn'
print('-----------------------')
url = 'https://api.iextrading.com/1.0/stock/'
url_b = '/company'
f_url = url + str(symbol) + url_b
r = requests.get(f_url)
r= r.json()
for i in r:
print(i+' : '+r[i])
print('-----------------------')
return r
def get_quote():
print('Stock Quote Search')
symbol = input('Please enter the company symbol: ')
print('-----------------------')
url = 'https://api.iextrading.com/1.0/stock/'
url_b = '/quote'
f_url = url + str(symbol) + url_b
r = requests.get(f_url)
r= r.json()
for i in r:
print(i+' : '+ str(r[i]))
print('-----------------------')
def get_keystats():
print('Stock Key Stats Search')
symbol = input('Please enter the company symbol: ')
print('-----------------------')
url = 'https://api.iextrading.com/1.0/stock/'
url_b = '/stats'
f_url = url + str(symbol) + url_b
r = requests.get(f_url)
r= r.json()
for i in r:
print(i+' : '+ str(r[i]))
print('-----------------------')
def get_news():
print('Related News Search')
symbol = input('Please enter the company symbol: ')
Range = input('Please enter how many pieces of news you want to read (1-50): ')
print('-----------------------')
url = 'https://api.iextrading.com/1.0/stock/'
url_b = '/news/last/'
f_url = url + str(symbol) + url_b+Range
r = requests.get(f_url)
r= r.json()
for i in r:
for j in i:
print(j+' : '+ str(i[j]))
print('**********************')
print('-----------------------')
def main():
while True:
fun = input('Enter the module you want to use (i:info, n:news, q:quote, ks:keystats): ')
print('\n')
if fun =='i':
get_info()
if fun == 'n':
get_news()
if fun == 'q':
get_quote()
if fun == 'ks':
get_keystats()
if fun == 'quit':
break
screen = pygame.display.set_mode((1280,960))
black = (0,0,0)
white = (255,255,255)
grey = (100,100,100)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.display.quit()
sys.exit()
# screen.fill(black)
key = pygame.key.get_pressed()
info = get_info()
pygame.font.init()
font = pygame.font.Font(None, 36)
m = 10
for i in info:
key = font.render(str(i), True, white)
value = font.render(str(info[i]), True, white)
screen.blit(key,(10,50+m))
screen.blit(value,(150,50+m))
m +=20
pygame.display.update()
#main()