The goal of the project is as follows:
clap
: crate is used for building flexible command line interface applications. [Link]
yahoo_finance_api
: has been used in this project to fetch the stock quotes of the past six months using the yahoo! finance API. [Link]
tokio
: A runtime for writing reliable asynchronous applications in Rust.
lazy_static
: A crate for declaring lazily evaluated static variables
log
: A crate used for providing a single API that abstracts various logging implementations
log4rs
: Logging implementation used for our application, modelled after popular Java logging libraries like logback
and log4j
plotters
: crate is used to plot various types of graphs like line chart, histogram, candlesticks plot etc. [Link]
chrono
: The ‘chrono’ crate is a library which contains a list of functions which can be used to perform various operations on dates and times in the Proleptic Gregorian calendar. [Link]
ta
: crate is used for technical analysis tasks. We have used this crate to calculate a variety of financial analysis indicators like RSI (Relative Strength Index), MACD (Moving Average Convergence Divergence) etc.
On the stock chart volatile days are plotted in order to indicate the days where stock price varied by more than 2% of the total price.
We have implemented the Bollinger Bands Indicators by using the ta crate. For Bollinger Bands, three lines are plotted (middle band, upper band, lower band). The middle band is usually calculated as a simple moving average over a particular period (a period of 20 has been used in our program). The upper band and lower band are calculated by adding and subtracting the multiple of standard deviation respectively to the average value. Mathematically, these bands can be written as follows:
BollingerBands_Middle Band = Simple Moving Average (SMA).
BollingerBands_Upper Band = SMA + Standard_Deviation of observation * multiplier
BollingerBands_Lower Band = SMA - Standard_Deviation of observation * multiplier
In this project, the multiplier is taken as 2.
We have implemented the Relative Strength Index (RSI) Indicators by using the ta crate. Mathematically RSI can be defined as follows:
RSIt = EMAUt * 100 / (EMAUt + EMADt)
where
The RSI indicator is studied in order to identify the oversold or overbought conditions of a stock. A period of 14 has been used in this project to calculate the RSI.
We have implemented the Fast/Slow SMA Indicators by using the ta crate. And fast period is set to 20 and slow period is set to 50.
We have implemented the Fast/Slow SMA Indicators by using the ta crate. And fast period is set to 20 and slow period is set to 50.
We have implemented the MACD Indicators by using the ta crate. For calculating the MACD we have used a slow period of 26, fast period of 12 and a signal period of 9.
For plotting all the charts we used plotters and labelled the x and y axis where and when needed.
We have used Line and Histogram Charts primarily. The charts looks like as follows:
Autoscaling is supported for height not width, width is fixed.
To setup the project lets look at the project setup that you might have:
After you extract the file your file directory should something as above. Follow the steps.
cd ./stock_market
cargo build --release
target
directorycd ./target/release
./stock_marker.exe --name AAPL
Note: All errors are logged to a log file under the 'log' directory
./stock_market.exe --help
or
./stock_market.exe -h
Output:
./stock_market.exe --version
or
./stock_market.exe -v
./stock_market --name <STOCK_TICKER_NAME>
This shows the daily stock quotes for the last 6 months
./stock_market --name <STOCK_TICKER_NAME> --range <range> --interval <interval>
The above example works only if you supported ranges and intervals as shown in the below table.