Created
April 27, 2017 04:42
-
-
Save saurabhwahile/a79835cd527bb3c37aa9ccd5a17d17cd to your computer and use it in GitHub Desktop.
Script to alert if a stock value goes below the support
This file contains hidden or 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
from googlefinance import getQuotes | |
import winsound | |
import time | |
import math | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("stock", help="A google supported stock name. Example, NASDAQ:AAPL", type=str) | |
parser.add_argument("support", help="beep when below this price", type=float) | |
args = parser.parse_args() | |
stock = args.stock | |
support = float(args.support) | |
def sigmoid(x): | |
return 1 / (1 + math.exp(-x)) | |
while True: | |
s = getQuotes(stock) | |
ltp = float(s[0]['LastTradePrice']) | |
print(ltp) | |
if ltp - support < 0: | |
winsound.Beep(int(37+(sigmoid(-1*(ltp-support))-0.5)*32767), 1000) | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment