Overall Statistics
Total Orders
24
Average Win
1.31%
Average Loss
-2.43%
Compounding Annual Return
-10.914%
Drawdown
13.500%
Expectancy
-0.359
Start Equity
100000
End Equity
89405.78
Net Profit
-10.594%
Sharpe Ratio
-1.534
Sortino Ratio
-0.559
Probabilistic Sharpe Ratio
0.321%
Loss Rate
58%
Win Rate
42%
Profit-Loss Ratio
0.54
Alpha
-0.145
Beta
0.226
Annual Standard Deviation
0.084
Annual Variance
0.007
Information Ratio
-1.36
Tracking Error
0.147
Treynor Ratio
-0.567
Total Fees
$24.00
Estimated Strategy Capacity
$1700000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
Portfolio Turnover
6.74%
Drawdown Recovery
28
#region imports
from AlgorithmImports import *
#endregion
# https://quantpedia.com/Screener/Details/41

class TurnOfMonthSPY(QCAlgorithm):
    def initialize(self):
        self.set_start_date(datetime.now() - timedelta(354))

        self._spy = self.add_equity("SPY", Resolution.DAILY)
        self._spy.ticket = None

        # This event triggers the algorithm to purchase during the last trading day of the month
        self.schedule.on(self.date_rules.month_end(self._spy), self.time_rules.midnight, self._purchase)

    def _purchase(self):
        ''' Immediately purchases the ETF at market opening '''
        self._spy.ticket = self.set_holdings(self._spy, 1)[0]

    def on_data(self, data):
        if self._spy.ticket and (self.utc_time - self._spy.ticket.time).days > 3:
            self.liquidate(self._spy, 'Liquidate after 3 days')
            self._spy.ticket = None