Before you start
What this module changes in your trading process.
Frame trading signals as a supervised learning problem with features and labels.
Machine learning is a tool, not magic. Frame market prediction as supervised learning and build the right conceptual pipeline.
Module outline
Before you start
Frame trading signals as a supervised learning problem with features and labels.
Lesson 1
Membingkai sinyal trading sebagai masalah supervised learning (fitur → label).
Supervised learning mempelajari pemetaan dari fitur (input) ke label (target) dari contoh historis. Dalam trading: • Fitur (X): apa pun yang diketahui saat keputusan — return masa lalu, indikator (RSI, MACD), volatilitas, volume, fitur makro. • Label (y): apa yang ingin diprediksi — mis. apakah return periode berikutnya positif (klasifikasi) atau besarnya return (regresi).
Tipe Target Contoh Klasifikasi Kategori Naik / turun / netral periode depan Regresi Angka kontinu Besar return 5 hari ke depan Sinyal-to-noise rendah Berbeda dari mengenali kucing di foto (sinyal kuat), prediksi pasar punya rasio sinyal-terhadap-kebisingan sangat rendah. Akurasi 53% pada arah harga bisa jadi sangat berharga — sementara 99% hampir pasti tanda kebocoran data.
Example
Contoh Klasifikasi Kategori Naik / turun / netral periode depan Regresi Angka kontinu Besar return 5 hari ke depan Sinyal-to-noise rendah Berbeda dari mengenali kucing di foto (sinyal kuat), prediksi pasar punya rasio sinyal-terhadap-kebisingan sangat rendah. Akurasi 53% pada arah harga bisa jadi sangat berharga — sementara 99% hampir pasti tanda kebocoran data.
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Lesson 2
Membedakan klasifikasi (arah) dan regresi (besar return).
Kualitas model ditentukan oleh kualitas fitur dan label — bukan algoritma canggih.
Example code: import pandas as pd # FITUR: hanya informasi yang tersedia hingga waktu t df["ret1"] = df["close"].pct_change() df["ret5"] = df["close"].pct_change(5) df["rsi"] = compute_rsi(df["close"], 14) df["vol"] = df["ret1"].rolling(20).std() # LABEL: arah return PERIODE BERIKUTNYA (digeser agar tidak bocor) df["future_ret"] = df["close"].pct_change().shift(-1) df["label"] = (df["future_ret"] > 0).astype(int) # Buang baris dengan NaN sebelum melatih data = df.dropna() X = data[["ret1","ret5","rsi","vol"]] y = data["label"] Data leakage — musuh nomor satu • Look-ahead via fitur: fitur yang diam-diam memuat info masa depan (mis. normalisasi memakai statistik seluruh dataset, termasuk masa depan). • Label bocor ke fitur: menyertakan kolom yang berkorelasi sempurna dengan target. • Scaling sebelum split: menghitung mean/std untuk standardisasi memakai data uji — bocor.
Selalu fit scaler hanya pada data latih. Tanda bahaya Akurasi yang "terlalu bagus" hampir selalu kebocoran, bukan penemuan. Saat model tampak ajaib, curigai pipeline Anda dulu — bukan rayakan.
Example
import pandas as pd # FITUR: hanya informasi yang tersedia hingga waktu t df["ret1"] = df["close"].pct_change() df["ret5"] = df["close"].pct_change(5) df["rsi"] = compute_rsi(df["close"], 14) df["vol"] = df["ret1"].rolling(20).std() # LABEL: arah return PERIODE BERIKUTNYA (digeser agar tidak bocor) df["future_ret"] = df["close"].pct_change().shift(-1) df["label"] = (df["future_ret"] > 0).astype(int) # Buang baris dengan NaN sebelum melatih data = df.dropna() X = data[["ret1","ret5","rsi","vol"]] y = data["label"]
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Lesson 3
Merancang fitur (indikator, return masa lalu) dan label (return masa depan) tanpa kebocoran.
Alur supervised learning yang sehat: • Siapkan data: fitur & label, tangani NaN, hindari kebocoran. • Split temporal: latih pada masa lalu, uji pada masa depan (BUKAN acak — lihat ML 302). • Latih model: mulai sederhana (regresi logistik, pohon keputusan, gradient boosting) sebelum yang kompleks. • Evaluasi: bukan hanya akurasi — lihat apakah sinyal model menghasilkan strategi yang menguntungkan setelah biaya.
Example code: from sklearn.ensemble import GradientBoostingClassifier # split temporal sederhana split = int(len(data)*0.7) Xtr, Xte = X.iloc[:split], X.iloc[split:] ytr, yte = y.iloc[:split], y.iloc[split:] model = GradientBoostingClassifier() model.fit(Xtr, ytr) pred = model.predict(Xte) # lalu ubah menjadi posisi & backtest net Akurasi ≠ profit Model bisa akurat memprediksi banyak gerakan kecil tetapi salah pada beberapa gerakan besar — dan rugi.
Selalu terjemahkan prediksi menjadi posisi, lalu evaluasi sebagai strategi (Sharpe, drawdown, net return), bukan sekadar metrik klasifikasi. Mulai sederhana: model linier/pohon yang dapat ditafsirkan sering kali pijakan terbaik sebelum melompat ke deep learning.
Example
from sklearn.ensemble import GradientBoostingClassifier # split temporal sederhana split = int(len(data)*0.7) Xtr, Xte = X.iloc[:split], X.iloc[split:] ytr, yte = y.iloc[:split], y.iloc[split:] model = GradientBoostingClassifier() model.fit(Xtr, ytr) pred = model.predict(Xte) # lalu ubah menjadi posisi & backtest net
Key points
Practice checkpoint
Apply this lesson to one market you actually watch. Write the rule, the data needed, the risk check, and the condition that invalidates the idea.
Before continuing
Fieldwork
Build one worksheet for Machine Learning for Trading I: state the market, the rule, the data input, the risk limit, the validation check, and the review note before using it live.
Glossary
Checkpoint quiz
Quiz results can add XP when you are signed in.
Progress action
Marking complete saves the module, updates streak activity, and awards XP only once per module.
Previous module
Quant trading is applied statistics. Build intuition for separating real patterns from randomness.
Next module
Wrong validation is the fastest way to fool yourself with ML. Learn validation techniques specific to financial time series.
Risk note: Metavulus learning content is for education and market preparation only. It is not financial advice, investment advice, or a trading recommendation.