From 11bcdbc1070552dfc99df332d554e99057281d1b Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 6 Mar 2020 20:00:14 -0500 Subject: asdf --- bin/get-stock.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 bin/get-stock.py (limited to 'bin') 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)) -- cgit v1.2.3