diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0b460a92 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3 + +RUN pip install --upgrade pip && \ + pip install --no-cache-dir nibabel pydicom matplotlib pillow && \ + pip install --no-cache-dir med2image + +# As per https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ + +COPY requirements.txt /tmp +RUN pip install --requirement /tmp/requirements.txt +COPY . /tmp/ + +RUN mkdir /opt/wsb/ +COPY grapher.py market_scanner.py stocklist.py /opt/wsb/ + +RUN mkdir /opt/wsb/data +COPY data /opt/wsb/data diff --git a/README.md b/README.md index f669a810..2ea5c3aa 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,50 @@ This scans every ticker on the market, gets their last 5 months of volume history, and alerts you when a stock's volume exceeds 10 standard deviations from the mean within the last 3 days. (these numbers are all adjustable). Helps find anomalies in the stock market +## [Website Link!](http://165.22.228.6/ ): -## How to run this: +[credit!](https://www.reddit.com/r/wallstreetbets/comments/i10mif/i_made_a_website_for_that_scanner_made_by_that/) --download your favorite Python IDE. (I use VSCode) --get my script from GitHub +## Requirements --open the script in your IDE and install all required dependancies by typing pip install -r requirements.txt into the IDE's terminal. You can get to the the terminal on VSC by pressing CMD and ` at the same time. +Docker - install Docker https://docs.docker.com/get-docker/ --run the market_scanner.py and it will print out results into the terminal --you can also graph any ticker's volume in grapher.py +Alternatively, + +1) download your favorite Python IDE. (For example, the project creator uses VSCode) + +2) Clone project from GitHub + +3) Open project in your IDE and install all required dependancies by typing pip install -r requirements.txt into the IDE's terminal. You can get to the the terminal on VSC by pressing CMD and ` at the same time. + +## How to run +Build docker image by running commands below, from the same directory as Dockerfile. +
+docker build --tag NAME:VERSION . ie docker build --tag wsb:1.0 . ++You will be presented with a message +
+Successfully built ID +Successfully tagged wsb:1.0 ++Then run +
+docker run -ti ID bash +Once inside +python /opt/wsb/market_scanner.py ++ +Alternatively, +1) run the market_scanner.py and it will print out results into the terminal +2) you can also graph any ticker's volume in grapher.py ## Controlling the Script --Line 17 controls the amount of months of historical volume the script gets +Line 17 controls the amount of months of historical volume the script gets --Line 75 controls the amount of days before today that it will alert you +Line 75 controls the amount of days before today that it will alert you --Line 84 controls the number of standard deviations away from the mean volume +Line 84 controls the number of standard deviations away from the mean volume diff --git a/market_scanner.py b/market_scanner.py index 1029bd66..0939cf06 100644 --- a/market_scanner.py +++ b/market_scanner.py @@ -9,9 +9,6 @@ from stocklist import NasdaqController from tqdm import tqdm -from joblib import Parallel, delayed -import multiprocessing - class mainObj: def getData(self, ticker): @@ -65,21 +62,18 @@ def days_between(self, d1, d2): d2 = datetime.datetime.strptime(d2, "%Y-%m-%d") return abs((d2 - d1).days) - def parallel_wrapper(self,x, cutoff, currentDate): - d = (self.find_anomalies_two(self.getData(x), cutoff)) - if d['Dates']: - for i in range(len(d['Dates'])): - if self.days_between(str(currentDate)[:-9], str(d['Dates'][i])) <= 3: - self.customPrint(d, x) - def main_func(self, cutoff): StocksController = NasdaqController(True) list_of_tickers = StocksController.getList() currentDate = datetime.datetime.strptime( date.today().strftime("%Y-%m-%d"), "%Y-%m-%d") start_time = time.time() - - Parallel(n_jobs=multiprocessing.cpu_count())(delayed(self.parallel_wrapper)(x, cutoff, currentDate) for x in tqdm(list_of_tickers) ) + for x in tqdm(list_of_tickers): + d = (self.find_anomalies_two(self.getData(x), cutoff)) + if d['Dates']: + for i in range(len(d['Dates'])): + if self.days_between(str(currentDate)[:-9], str(d['Dates'][i])) <= 3: + self.customPrint(d, x) print("\n\n\n\n--- this took %s seconds to run ---" % (time.time() - start_time)) diff --git a/requirements.txt b/requirements.txt index 98894fb6..770ee0cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,3 @@ numpy==1.18.4 mplcursors==0.3 python_dateutil==2.8.1 tqdm==4.48.0 -joblib diff --git a/stocklist.py b/stocklist.py index 4035068f..457c8407 100644 --- a/stocklist.py +++ b/stocklist.py @@ -47,8 +47,7 @@ def __init__(self, update=True): line = line.strip().split("|") - #line[6] and line[4] is for ETFs. Let's skip those to make this faster. - if line[0] == "" or line[1] == "" or (filename == 'nasdaqlisted' and line[6] == 'Y') or (filename == 'otherlisted' and line[4] == 'Y'): + if line[0] == "" or line[1] == "": continue all_listed.write(line[0] + ",")