diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/get-stock.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/get-stock.py b/bin/get-stock.py new file mode 100755 index 0000000..334cab6 --- /dev/null +++ b/bin/get-stock.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +# +# get-stock.py: fetch current stock ticker information and write it to +# as JSON to standard output. +# +# Usage: +# +# # fetch current google price and write it to current.json +# get-stock.py GOOG > current.json +# + +import sys +import json +import yfinance + +# check command-line arguments +if len(sys.argv) < 2: + raise RuntimeError('missing code') + +# get ticker info, convert to json, print to stdout +print(json.dumps(yfinance.Ticker(sys.argv[1]).info)) |