nictra23 / Project

0 stars 0 forks source link

Autocorrelation for Multi-Factor strategy in different industry #6

Open nictra23 opened 11 months ago

nictra23 commented 11 months ago

Based on our analysis by industry, let's further analyze the trend of returns. Autocorrelation is typically used in signal processing to identify repeating patterns or in finance to identify trends in stock prices or economic cycles.

For example, if there is a high autocorrelation at lag 1 in a time series, it suggests that the value of a variable in a certain period heavily depends on the value of the same variable in the previous period.

Positive autocorrelation implies that an upward trend in the time series might be followed by another upward trend, while a downward trend might be followed by another downward trend. On the other hand, negative autocorrelation indicates that an increase might be followed by a decrease and vice versa.

I download all the data from the web and get the profit for each month. Make those data for ACF.

CODE: import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.graphics.tsaplots import plot_acf import matplotlib.pyplot as plt import matplotlib.font_manager as fm

    # Set the font that supports Chinese. Replace 'SimHei' with the font on your machine that supports Chinese.
    plt.rcParams['font.sans-serif'] = ['SimHei']
    plt.rcParams['axes.unicode_minus'] = False
    # Creating a time series
    np.random.seed(0)  # for reproducibility
    time_series =[1150263.24, 1175341.69, 1041199.29, 973854.1, 1052500.4, 1057194.13, 1227032.2, 1389029.19, 1217352.8, 1395744.46, 1437465.54, 1291011.96, 1411755.26, 1462511.48, 1272795.23, 1377860.12, 1242858.71, 1298162.83, 1355209.46, 1292613.53] #set this list for profit present from the data.

    fig, ax = plt.subplots(figsize=(10,5))
    plot_acf(time_series, lags=19, ax=ax)
    plt.title("Autocorrelation OF 'Energy'")
    plt.xlabel("Lag in Months")
    plt.grid(True)

    # Set x-ticks to show a label for each month
    ax.set_xticks(np.arange(20))
    ax.set_xticklabels(np.arange(20))
    plt.show()
nictra23 commented 11 months ago

Energy Sector Analysis:

Here, the data is still based on the initial data from 2021 to 2023, with monthly backtesting conducted. The selected interval is the top 10%, as this approach can better showcase the significance of the strategy.

Let's begin the analysis with a focus on the energy sector:

Image

Image

In the generated graph, the x-axis represents the lag, while the y-axis represents the autocorrelation at that specific lag. The blue shaded area represents the confidence interval. If the autocorrelation at a given lag falls within this area, it is not statistically significant.

In your description, you mentioned that at lag 1, the autocorrelation is relatively high and then gradually decreases. This is a typical pattern for a random walk time series. Towards the end, the autocorrelation has approached 0, indicating that its autocorrelation is effectively negligible.

nictra23 commented 11 months ago

Industrial Sector Analysis:

Similar to the energy sector analysis, the data for the industrial sector is based on the initial data from 2021 to 2023, with monthly backtesting conducted. The selected interval is the top 10%, as this approach helps to highlight the significance of the strategy.

Image

Image

Cyclical Analysis: If bars appear significantly at fixed intervals, it shows the presence of seasonality in the data.

nictra23 commented 11 months ago

Real Estate Sector Analysis:

Similar to the previous sectors, the data for the real estate sector is based on the initial data from 2021 to 2023, with monthly backtesting conducted. The selected interval is the top 10%, as this approach helps to effectively demonstrate the significance of the strategy.

Image

Image

nictra23 commented 11 months ago

Optional Consumption Sector Analysis:

Just like the previous sectors, the data for the optional consumption sector is based on the initial data from 2021 to 2023, with monthly backtesting conducted. The selected interval is the top 10%, as this approach helps emphasize the significance of the strategy.

Image

Image