An apocalyptic stock market analyzer.
This project requires:
- Python version 3.6 or greater
- R language
Plots are created using the R language.
Under arch linux you can install it with:
sudo pacman -S r
If you use a different operating system, then check this link.
git clone https://github.com/ptrstn/apocarich
cd apocarich
python -m venv venv
. venv/bin/activate
pip install -e .
apocarich --help
Output:
usage: apocarich [-h] [--version] [--retrieve-data] [--start DATE] [--end DATE] [--update-csv]
Analyzing the stock market
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
Retrieving data from Xetra:
--retrieve-data Retrieve data from Xetra using the Amazon aws-cli
--start DATE Start date (default is 2019-11-01)
--end DATE End date (default is today)
Updating exported data.csv by retrieved data:
--update-csv Generates an updated data.csv by regrouping previously retrieved data
First you have to retrieve some data. The following command downloads data from Xetra using the Amazon aws-cli.
apocarich --retrieve-data
If you want to specify specific dates, then you can use the --start
and --end
arguments:
apocarich --retrieve-data --start 2020-01-01 --end 2020-03-26
For the next step you have to regroup the raw data, to be able to visualize them later.
Create the grouped CSV file, based on previously retrieved data:
apocarich --update-csv
Once the data is processed you can run the R script that generates a plot for you. You can specify different arguments to further filter your data.
argument | Description |
---|---|
--start |
Start date |
--end |
End date |
--apocalypse |
Date of when shit hit the fan |
--stocktype |
"Common stock", "ETF", "ETC", "ETN" or "Other" |
--numstocks |
Number of stocks to visualize at once |
--windowsize |
Moving average window size |
--numchars |
Number of characters to display per subtitle |
--outdir |
Path of the output directory |
--untilrecent |
Calculate loss by biggest drop after apocalypse day or until most recent day |
--nolossuntilapo |
Filter to stocks with no loss from starting day until apocalypse day |
--nmosttraded |
Filter to n most traded stocks |
--nmostvolume |
Filter to n stocks with highest volume |
Run the R script:
Rscript R/apocarich.R
You can also specify the arguments described above as follows:
Rscript R/apocarich.R \
--start 2020-02-01 \
--end 2020-03-26 \
--apocalypse 2020-02-15 \
--numchars 5 \
--outdir images \
--windowsize 10 \
--stocktype ETF
Full example of how to create a plot
git clone https://github.com/ptrstn/apocarich
cd apocarich
python -m venv venv
. venv/bin/activate
pip install .
apocarich --retrieve-data --start 2020-02-10 --end 2020-02-26
apocarich --update-csv
apocarich.R