sleep-at-night implements a parallelized trailing stop loss algorithm; a commonly used strategy for preventing a portfolio's value from decreasing by more than X%, while allowing for unbounded gains.
A trailing stop order sets the stop price at a fixed amount below the market price with an attached "trailing" amount. As the market price rises, the stop price rises by the trail amount, but if the stock price falls, the stop loss price doesn't change, and a market order is submitted when the stop price is hit.
Due to the proprietary nature of the trader_client
package, it is not included in this project. In order to use this algo, you will need to implement two methods in a TraderClient
class, get_holdings
and sell_all
.