ptrstn / apocarich

An apocalyptic stock market analyzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status codecov

apocarich

An apocalyptic stock market analyzer.

alt text

Requirements

This project requires:

R

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.

Install instructions

git clone https://github.com/ptrstn/apocarich
cd apocarich
python -m venv venv
. venv/bin/activate
pip install -e .

Usage

Help

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

Retrieve 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

Process data

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

Create plots

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

Example

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

About

An apocalyptic stock market analyzer


Languages

Language:R 66.8%Language:Python 33.2%