דלגו לתוכן
פתיחת RaamTrade

RC2_LEARNING_SET_RUN

תוכן זה אינו זמין עדיין בשפה שלך.

In <set>, test="<value>" must be one of the run form’s period sizes: “3M”, “6M” or “1y”.

What it means

A learning set can carry its walk-forward setup: run=WalkForward(train="2y", test="1y", windows="rolling"). Each part is optional, but the ones you write must be values the walk-forward form offers:

Part Values
train The first training period, in whole years: "1y" to "15y".
test The size of each test period: "3M", "6M" or "1y".
windows "rolling" (each training period has the same length) or "anchored" (each training period starts at the beginning of the range and grows).

WalkForward(...) names each part, gives each one once, writes each in quotes, and goes in run=.

Why it happens

A test period the form does not offer:

class TwoYearTests(Strategy):
trade = Symbol()
sizing = FixedCapital()
fast = Param(10, min=2, max=100, opt_min=5, opt_max=30)
slow = Param(30, min=10, max=200, opt_min=20, opt_max=80, opt_step=5)
learning_set_2 = LearningSet(fast=Range(5, 15), run=WalkForward(test="2y"))
def execute(self):
f = SMA(self.fast, on=self.trade)
s = SMA(self.slow, on=self.trade)
if f.value > s.value and self.trade.is_flat:
self.buy(self.trade)

A window type that is not "rolling" or "anchored":

class GrowingWindows(Strategy):
trade = Symbol()
sizing = FixedCapital()
fast = Param(10, min=2, max=100, opt_min=5, opt_max=30)
slow = Param(30, min=10, max=200, opt_min=20, opt_max=80, opt_step=5)
learning_set_2 = LearningSet(fast=Range(5, 15), run=WalkForward(windows="expanding"))
def execute(self):
f = SMA(self.fast, on=self.trade)
s = SMA(self.slow, on=self.trade)
if f.value > s.value and self.trade.is_flat:
self.buy(self.trade)

How to fix it

Use the form’s values, and put the setup in run=:

class OneSetup(Strategy):
trade = Symbol()
sizing = FixedCapital()
fast = Param(10, min=2, max=100, opt_min=5, opt_max=30)
slow = Param(30, min=10, max=200, opt_min=20, opt_max=80, opt_step=5)
learning_set_2 = LearningSet(
fast=Range(5, 15),
run=WalkForward(train="2y", test="1y", windows="anchored"),
)
def execute(self):
f = SMA(self.fast, on=self.trade)
s = SMA(self.slow, on=self.trade)
if f.value > s.value and self.trade.is_flat:
self.buy(self.trade)
  • Learning sets
  • RC2_LEARNING_SET_SHAPE — the line itself is not LearningSet(param=value, ...).