-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e80fad4
commit 5970503
Showing
1 changed file
with
15 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
from googlefinance import getQuotes | ||
from datetime import datetime as dt | ||
|
||
quotes = ['AAPL', 'GOOG', 'MSFT', 'TSLA'] ## Here are the quotes desired. | ||
prices = [0,0,0,0] ## Intializes the prices list. | ||
prevtime = [dt.utcnow().minute, dt.utcnow().second, dt.utcnow().microsecond] ## Our comparitor | ||
for i in range(20): | ||
time = [dt.utcnow().minute, dt.utcnow().second, dt.utcnow().microsecond] ## 'Present' time | ||
if time[2] > prevtime[2] or time[1] > prevtime[1]: ## Compares our time | ||
q = getQuotes(quotes) | ||
for j in range(len(q)): | ||
prices[j] = q[j]['LastTradePrice'] | ||
print(prices) | ||
prevtime = time | ||
def get_quotes(quotes): | ||
prices = [0,0,0,0,0] ## Intializes the prices list. | ||
prevtime = [dt.utcnow().minute, dt.utcnow().second, dt.utcnow().microsecond] ## Our comparitor | ||
for i in range(20): | ||
time = [dt.utcnow().minute, dt.utcnow().second, dt.utcnow().microsecond] ## 'Present' time | ||
if time[2] > prevtime[2] or time[1] > prevtime[1]: ## Compares our time | ||
q = getQuotes(quotes) | ||
for j in range(len(q)): | ||
prices[j] = q[j]['LastTradePrice'] | ||
print(prices) | ||
prevtime = time | ||
|
||
if __name__ == "__main__": | ||
quotes = ['AAPL', 'GOOG', 'MSFT', 'TSLA', 'GOOG'] ## Here are the quotes desired. | ||
get_quotes(quotes) |