1
0
Fork 0
ML4T/manual_strategy/manual_strategy.md

2.3 KiB

Indicators

SMA and EMA

SMA and EMA

SMA/Price

SMA/Price

Bollinger Band

Bollinger Band

RSI

RSI

MACD

MACD

Optimal Strategy

The optimal strategy works by applying every possible buy/sell action to the current positions. A position is cash value, the current amount of shares, and previous transactions.

The algorithm then starts with a single initial position with the initial cash amount, no shares, and no transactions. The algorithm first executes all possible trades (sell 2000, sell 1000, do nothing, buy 1000, buy 2000). Next, it filters the invalid holdings, i.e., the other ones where shares are not equal to -1000, 0, or 1000. Finally, the algorithm keeps the highest cash value for each amount of shares.

That is the critical insight that makes the algorithm work. Since the same amount of shares has the same future potential for creating cash, the only differentiating factor is the current cash value. Accordingly, for each day, the algorithm ends up with three new positions. The algorithm could drop the position with zero shares because buying and selling 2000 shares leverages future price movements optimally.

After each trading day, the positions have the same value. I did not expect that, but it makes sense because the algorithm only keeps the best position from the previous day. In other words, we can simplify the algorithm by selecting the best position and then compute the two different positions. Since we already established that holding zero shares does not make sense, the only two possibilities are buying or selling 2000 depending on the current amount of shares.

Optimal strategy versus holding 1000 shares

Date Range: 2008-01-02 00:00:00 to 2009-12-31 00:00:00

Sharpe Ratio of Optimal Strategy: 13.322769848217233
Sharpe Ratio of bench: 0.1569184064240322

Cumulative Return of Optimal Strategy: 5.7861
Cumulative Return of bench: 0.012299999999999978

Standard Deviation of Optimal Strategy: 0.004547823197907996
Standard Deviation of bench: 0.01700436627121376

Average Daily Return of Optimal Strategy: 0.0038167861508578214
Average Daily Return of bench: 0.00016808697819094233

Final Portfolio Value Optimal: 678610.0
Final Portfolio Value Bench: 101230.0