Alpaca Pairs Trading Terminal

This CLI application allows the user to interact with the Alpaca API (stock brokerage), from the terminal manage and view positions, execute trades, run analyses, backtest strategies, and implement a pairs trading strategy.

This command line interface allows users to interact with their alpaca brokerage account through the terminal. Features include view current profits and positions, get asset price quotes, execute trades, run analyses, backtest strategies, and implement a pairs trading strategy all from the command line.

► Analysis Conduct the analysis required to find a suitable pair for statistical arbitrage.
Submit a CSV file of stock tickers and the program will download the stock data from the last year and check the correlation between all assets. If a pair has a sufficiently high correlation, it is placed through ADF test to check the stationarity of the time series and cointegration tests for the suitability of the pair. Once a suitable pair is chosen, we use a 60-day rolling regression on the asset prices allowing us to generate the hedge ratio; we then analyse the relative spread between assets. When the spread exceeds a certain boundary, we will buy one asset and short the other expecting the spread to retract. You will be presented with the option to backtest the strategy as well.

► Backtest strategy Dashboard that generates graphic representations of spread, zscored spread and strategy return. Allows you to test different strategies by adjusting take profits and stop loss.

► Execute Pairs Trading Strategy Once you have chosen a pair execute and manage a pairs trading strategy directly from your terminal.

► View current positions with profit and loss Dashboard for viewing all important metrics about current positions. ► Manual Trade Option to conduct a manual trade, market or limit order.

► Get Quote Option to conduct get the market price of an asset.

► Close All Positions Option to quickly exit all positions.

Project URL: Github

Technologies Used:

Python Pandas Docker
Alpaca Pairs Trading Terminal image