rates of change — Перевод на русский — примеры английский | Reverso Context

✊купи и держи по roc(200)

Проверять будем на SPY, но помним, что все активы ведут себя по разному. Условия:

  • Период: 2004-2021.
  • Время сделки: за 1 час до закрытия рынка.
  • Капитал: $100K.
  • Покупка, когда ROC(200) >= 0.
  • Продажа, когда ROC(200) < 0.

Код условия на Quantopian:

# получаем цены и рассчитываем ROC(200)
price_hist = data.history(context.asset, 'close', 400, '1d')
roc = talib.ROC(price_hist, timeperiod=200)

# сигнал на значении выше нуля
allow = roc[-1] >= 0

# ...

if data.can_trade(context.asset):
    if allow:
        # покупаем актив на 100% портфеля, если разрешено
        order_target_percent(context.asset, 1.)
    else:
        # закрываем позицию при запрете
        order_target_percent(context.asset, 0.)

Результаты ROC(200) и сравнение с пересечением SMA(50) и SMA(200):

С 2004 год SPY вырос на 230% имея просадку в 2008 году около -55%. Рядом с этим показателем только пересечение SMA(50) и SMA(200) с меньшей просадкой. ROC(200) оказался даже хуже пересечения цены и SMA(200), показав чуть меньшее количество сделок за весь период. Внизу показан результат сглаженного ROC по формуле из этой статьи, который показал наихудший результат.

Rapid rate — перевод на русский — примеры английский | reverso context

Посмотреть примеры с переводом высокие темпы
vysokiye tempy
(6 примеров, содержащих перевод)

Посмотреть примеры с переводом быстрых темпов
bystrykh tempov
(4 примеров, содержащих перевод)

Посмотреть примеры с переводом стремительных темпов
stremitel’nykh tempov
(4 примеров, содержащих перевод)

Посмотреть примеры с переводом ускоренными темпами
uskorennymi tempami
(2 примеров, содержащих перевод)

Посмотреть примеры с переводом быстрым темпам
bystrym tempam
(2 примеров, содержащих перевод)

Посмотреть примеры, содержащие стремительно
stremitel’no
(5 примеров, содержащих перевод)

Посмотреть примеры, содержащие месте почвенные массы
meste pochvennye massy
(2 примеров, содержащих перевод)


The new relationship would allow developing countries to achieve economic growth at a rapid rate, enabling them to become full partners with the developed countries in an international economic environment based on equality, common interests and participation, thereby ensuring their continued efforts towards sustainable development.


Lastly, he underscored the rapid rate of ratification of the Convention on the Rights of Persons with Disabilities, a trend which would likely continue, and hoped that States would be committed to its implementation.


Noting the rapid rate of urbanization of small island developing States, which is accompanied by the growth of slums, poverty, and rising insecurity,

Rate of change and its relationship with price

The rate of change is most often used to measure the change in a security’s price over time. This is also known as the price rate of change (ROC). The price rate of change can be derived by taking the price of a security at time B minus the price of the same security at time A and dividing that result by the price at time A.


Price ROC

=

B

A

A

×

1

0

0

where:

B

=

price at current time

A

=

price at previous time

begin{aligned} &

text{Price ROC} = frac{B — A}{A} times 100 \ &textbf{where:}\ &B=text{price at current time}\ &A=text{price at previous time}\ end{aligned}
​Price ROC=AB−A​×100where:B=price at current timeA=price at previous time​

This is important because many traders pay close attention to the speed at which one price changes relative to another. For example, option traders study the relationship between the rate of change in the price of an option relative to a small change in the price of the underlying asset, known as an options delta.

The importance of measuring rate of change

Rate of change is an extremely important financial concept because it allows investors to spot security momentum and other trends. For example, a security with high momentum, or one that has a positive ROC, normally outperforms the market in the short term.

Rate of change is also a good indicator of market bubbles. Even though momentum is good and traders look for securities with a positive ROC, if a broad-market ETF, index, or mutual fund has a sharp increase in its ROC in the short term, it may be a sign that the market is unsustainable. If the ROC of an index or other broad-market security is over 50%, investors should be wary of a bubble.

Understanding rate of change (roc)

Rate of change is used to mathematically describe the percentage change in value over a defined period of time, and it represents the momentum of a variable. The calculation for ROC is simple in that it takes the current value of a stock or index and divides it by the value from an earlier period. Subtract one and multiply the resulting number by 100 to give it a percentage representation.


R

O

C

=

(

current value

previous value

1

)

1

0

0

ROC = (frac{text{current value}}{text{previous value}} — 1)

*100
ROC=(previous valuecurrent value​−1)∗100

What is rate of change (roc)

The rate of change (ROC) is the speed at which a variable changes over a specific period of time. ROC is often used when speaking about momentum, and it can generally be expressed as a ratio between a change in one variable relative to a corresponding change in another; graphically, the rate of change is represented by the slope of a line. The ROC is often illustrated by the Greek letter delta.

Как получить результаты без бэктеста?

Тесты дают более точную картину и это актуально при сложных стратегиях. Но для стратегий с редкими ребалансировками, где можно использовать цену закрытия, мы получим максимально приближенные результаты используя Jupyter, pandas и numpy.

Получение доходности

Получая итоговую доходность для серии pandas, мы проходим следующие шаги:

  1. Получаем ежедневную доходность chg=prices/prices.shift(1).
  2. Устанавливаем первое значение chg.iloc[0]=1.
  3. При необходимости применяем фильтр и смещаем условия на один день (сделка проходит после получения сигнала)  sma200=chg[(df.close>sma200).shift(1)]. Это важно запомнить, чтобы не заглядывать в будущее.
  4. Считаем доходность перемножив все значения result=np.prod(sma200) .

Код есть в telegram-канале: @quantiki.

Получение просадки

Получить максимальную просадку можно так:

  1. Получаем ежедневную доходность chg=prices/prices.shift(1).
  2. Получаем доходность на каждый день
    series.rolling(total, min_periods=1).apply(np.prod).
  3. Получаем абсолютный максимум на каждый день
    series.rolling(total, min_periods=1).max().
  4. Получаем просадку на каждый день относительно последнего максимума series/rolling_max — 1.0.
  5. Получаем максимальную просадку на каждый день daily_drawdown.rolling(total, min_periods=1).min().

В итоге имеем следующий код для расчёта простых стратегий и их просадки:Код на Quantrum.me

Результаты выглядят следующим образом:

  • bench — бенчмарк, результат удержания актива в течение всего времени.
  • * dd — максимальная просадка при каждом условии.
  • roc200 — удержание при ROC(200) больше нуля.
  • roc200s — использование сглаженного ROC(200).
  • s200 — пересечение цены и SMA(200).
  • s50x200 — пересечение SMA(50) и SMA(200).

Сравнив результаты с тестами на Quantopian видна разница, которой можно принебречь для принятия первичных решений. В некоторых случаях разница в доли процентов. Высока вероятность, что расхождение связано со временем ребалансировки стратегий (за 1 час до закрытия рынка). Мы же делаем расчёт по цене закрытия.

Вывод

Мы увидели, что использование ROC(200), как фильтра трендов, является невыгодным. Также научились быстро получать доходность и просадку для простых стратегий, достаточные для принятия решений, а работающие на порядок быстрее.

В следующий раз мы ещё немного помучаем ROC. Проверим доходность, используя силу тренда, пересечение разных периодов ROC и создадим индикатор Know Sure Thing (KST), созданный Мартином Прингом на основе ROC.

В комментариях пишите, ваши вопросы по тесту и коду. Запрашивайте полный код стратегии и блокнота.

Александр Румянцев
Автор на Quantrum.me
Telegram-канал: @quantiki

Интересуетесь алготрейдингом на Python? Присоединяйтесь к команде.

Оставьте комментарий

Войти