9/19/2023 0 Comments 21 ema stock![]() ![]() Simple_cum_relative_return_exact = simple_cum_strategy_asset_relative_returns.sum(axis=1)Īx.plot(cum_relative_return_exact.index, 100*cum_relative_return_exact, label='EMA strategy')Īx.plot(simple_cum_relative_return_exact.index, 100*simple_cum_relative_return_exact, label='Buy and hold')Īx.set_ylabel('Total cumulative relative returns (%)')Īx.xaxis. Simple_cum_strategy_asset_relative_returns = np.exp(simple_cum_strategy_asset_log_returns) - 1 # Transform the cumulative log returns to relative returns When prices reverse and fall back down through the 21day EMA, closing below the 8day EMA, an entry alert is given. Simple_cum_strategy_asset_log_returns = simple_strategy_asset_log_returns.cumsum() # Get the cumulative log-returns per asset ![]() Simple_strategy_asset_log_returns = simple_weights_matrix * asset_log_returns # Get the buy-and-hold strategy log returns per asset Simple_weights_matrix = pd.DataFrame(1/3, index = data.index, columns=lumns) # Define the weights matrix for the simple buy-and-hold strategy To get all the strategy log-returns for all days, one needs simply to multiply the strategy positions with the asset log-returns. How much is this lag $L$? For a SMA moving average calculated using $M$ days, the lag is roughly $\frac$. However, this comes at a cost: SMA timeseries lag the original price timeseries, which means that changes in the trend are only seen with a delay (lag) of $L$ days. It is straightforward to observe that SMA timeseries are much less noisy than the original price timeseries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |