Created
March 12, 2021 15:54
-
-
Save invisiblek/85c3f5b4dabeac37ef9e1388d48852c6 to your computer and use it in GitHub Desktop.
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
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment