INNER CODE UNIT · Python

plot_results

dmarienko/QuantTradingResearch · models/helpers.py:107

def plot_results(m: mstruct):
    """
    Plot results for train/test periods with it's tracking errors
    """
    yn, yn_h = (m.train.y, m.train.yh) if m.mode.startswith('price') else (norm(returns_to_prices(m.train.y)), norm(returns_to_prices(m.train.yh)))
    yt, yt_h = (m.test.y, m.test.yh) if m.mode.startswith('price') else (norm(returns_to_prices(m.test.y)), norm(returns_to_prices(m.test.yh)))
    sbp(13, 1, c=2);
    plt.plot(yn, lw=1, c='blue', label='Index')
    plt.plot(yn_h, lw=1, ls='--', c='g', label='Tracking Model')
    plt.legend(loc=2)
    plt.title(f'{m.description}: InSample: $\omega$: {m.train.w: 0.2f}')
    
    sbp(13, 3, c=1);
    plt.plot(yt, lw=1, c='blue', label='Index')
    plt.plot(yt_h, lw=1, ls='--', c='g', label='Tracking Model')
    plt.legend(loc=2)
    plt.title(f'{m.description}: OutOfSample: $\omega$: {m.test.w: 0.2f}')
    print(yellow(f' -> TE (train): {m.train.w:.2f}%'), ' | ', green(f'TE (test): {m.test.w:.2f}%'))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…