backtrader.indicators.percentrank module

Percent Rank Indicator Module - Percentile ranking.

This module provides the Percent Rank indicator for calculating the percentile rank of current values within a period.

Classes:

PercentRank: Percent rank indicator (alias: PctRank).

示例

class MyStrategy(bt.Strategy):
def __init__(self):

# Calculate 50-period percent rank self.pctrank = bt.indicators.PctRank(self.data.close, period=50)

def next(self):

# Buy when price is in top 20% (percent rank > 0.8) if self.pctrank[0] > 0.8:

self.buy()

# Sell when price is in bottom 20% (percent rank < 0.2) elif self.pctrank[0] < 0.2:

self.sell()

class backtrader.indicators.percentrank.PercentRank[源代码]

基类:BaseApplyN

Measures the percent rank of the current value with respect to that of period bars ago

alias = ('PctRank',)
frompackages = ()
packages = ()
backtrader.indicators.percentrank.PctRank

PercentRank 的别名