aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2020-03-06 20:00:14 -0500
committerPaul Duncan <pabs@pablotron.org>2020-03-06 20:00:14 -0500
commit11bcdbc1070552dfc99df332d554e99057281d1b (patch)
treee2ac14edb6709555008eea76bc439ea83a27576c /bin
parentb6df5d6739975848fc10893700d78cdd616a0c96 (diff)
downloadalonzo-mood-calculator-11bcdbc1070552dfc99df332d554e99057281d1b.tar.bz2
alonzo-mood-calculator-11bcdbc1070552dfc99df332d554e99057281d1b.zip
asdf
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get-stock.py22
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))