#!/usr/bin/python3 import json import os import requests import sys import yfinance s = sys.argv[1] threshold = float(sys.argv[2]) force = False if len(sys.argv) > 3 and sys.argv[3] == "force": force = True # insert discord webhook url here url = "" bid = yfinance.Ticker(sys.argv[1]).info['bid'] stocks = {} if os.path.exists('/home/dp/stocker.json'): with open('/home/dp/stocker.json') as j: stocks = json.load(j) if s in stocks: check_threshold = 0 while check_threshold < bid or check_threshold < stocks[s]: if force or (check_threshold > bid and check_threshold < stocks[s]) or (check_threshold < bid and check_threshold > stocks[s]): msg = "Price for {} has hit {}".format(s, bid) print(msg) data = { "content" : msg, "username" : "stonkbot" } #requests.post(url, json=data) break else: check_threshold = check_threshold + threshold stocks[s] = bid with open('/home/dp/stocker.json', 'w') as j: json.dump(stocks, j)