-
Notifications
You must be signed in to change notification settings - Fork 0
/
StockExchange_Domain.py
37 lines (28 loc) · 1.03 KB
/
StockExchange_Domain.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
from DomainMaster import DomainMaster
from googlefinance import getQuotes
import json
### References_
### https://pypi.python.org/pypi/googlefinance
class StockExchange_Domain(DomainMaster):
def __init__(self, domainDIR, d, PN):
DomainMaster.__init__(self, domainDIR)
self.set_pronoun_and_domain(PN, d)
## Retrieve stock data of given symbol.
self.refresh_data()
##### ##### ##### ##### #####
##### ##### ##### ##### ##### STOCK VALUE RETRIEVAL
##### ##### ##### ##### #####
### Updates most recently available data.
def refresh_data(self):
self.raw = json.dumps(getQuotes(self.get_pronoun()), indent=2)
self.data = json.loads(self.raw)
## Update value dictionary.
self.set_value_dict(self.domain)
### Retrieves specified stock data given a type term.
def get_data_value(self, term):
## Check against available terms.
if term == "value":
val = self.data[0]['LastTradePrice']
else:
return ("")
return (val)