当前位置: 首页>>代码示例>>Python>>正文


Python talib.SAR属性代码示例

本文整理汇总了Python中talib.SAR属性的典型用法代码示例。如果您正苦于以下问题:Python talib.SAR属性的具体用法?Python talib.SAR怎么用?Python talib.SAR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在talib的用法示例。


在下文中一共展示了talib.SAR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_SAR

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def add_SAR(self, acceleration=0.02, maximum=0.20,
            type='scatter', color='tertiary', **kwargs):
    """Parabolic SAR."""

    if not (self.has_high and self.has_low):
        raise Exception()

    utils.kwargs_check(kwargs, VALID_TA_KWARGS)
    if 'kind' in kwargs:
        type = kwargs['kind']

    name = 'SAR({},{})'.format(str(acceleration), str(maximum))
    self.pri[name] = dict(type=type, color=color)
    self.ind[name] = talib.SAR(self.df[self.hi].values,
                               self.df[self.lo].values,
                               acceleration, maximum) 
开发者ID:plotly,项目名称:dash-technical-charting,代码行数:18,代码来源:ta.py

示例2: sar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def sar(candles: np.ndarray, acceleration=0.02, maximum=0.2, sequential=False) -> Union[float, np.ndarray]:
    """
    SAR - Parabolic SAR

    :param candles: np.ndarray
    :param acceleration: float - default: 0.02
    :param maximum: float - default: 0.2
    :param sequential: bool - default=False

    :return: float | np.ndarray
    """
    if not sequential and len(candles) > 240:
        candles = candles[-240:]

    res = talib.SAR(candles[:, 3], candles[:, 4], acceleration=acceleration, maximum=maximum)

    return res if sequential else res[-1] 
开发者ID:jesse-ai,项目名称:jesse,代码行数:19,代码来源:sar.py

示例3: test_psar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def test_psar(self):
        result = pandas_ta.psar(self.high, self.low)
        self.assertIsInstance(result, DataFrame)
        self.assertEqual(result.name, 'PSAR_0.02_0.2')

        # Combine Long and Short SAR's into one SAR value
        psar = result[result.columns[:2]].fillna(0)
        psar = psar[psar.columns[0]] + psar[psar.columns[1]]
        psar.name = result.name

        try:
            expected = tal.SAR(self.high, self.low)
            pdt.assert_series_equal(psar, expected)
        except AssertionError as ae:
            try:
                psar_corr = pandas_ta.utils.df_error_analysis(psar, expected, col=CORRELATION)
                self.assertGreater(psar_corr, CORRELATION_THRESHOLD)
            except Exception as ex:
                error_analysis(psar, CORRELATION, ex) 
开发者ID:twopirllc,项目名称:pandas-ta,代码行数:21,代码来源:test_indicator_trend.py

示例4: handle_data

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def handle_data(context):
    global mySAR, OParCl2,OParOp2,OPosition2,OTRansition2
    afStep  = runsVar / 100 
    afLimit = afStep  * 10
    sar = talib.SAR(High(), Low(), afStep,afLimit)

    OParCl, OParOp, OPosition, OTRansition = ParabolicSAR(High(), Low(), afStep, afLimit)

    #OParCl2[-1], OParOp2[-1], OPosition2[-1], OTRansition2[-1] = mySAR.U_SAR(High(), Low(), afStep, afLimit)
    OParCl3, OParOp3, OPosition3, OTRansition3 = mySAR.U_SAR(High(), Low(), afStep, afLimit)
    
    #LogInfo("SAR", Date(), Time(), sar[-1], OParCl[-1])
    PlotNumeric("SAR", sar[-1])
    PlotNumeric("ESAR", OParCl[-1], color=RGB_Blue())
    PlotNumeric("USAR", OParCl3, color=RGB_Green())
    #LogInfo("BBBB:", Date(), Time(), High()[-1], Low()[-1], sar[-1], OParCl[-1], OParCl3)
    #LogInfo("AAAA:", Date(), Time(), OParCl[-1], OParOp[-1], OPosition[-1], OTRansition[-1]) 
开发者ID:epolestar,项目名称:equant,代码行数:19,代码来源:TestSAR.py

示例5: calculate_sar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def calculate_sar(self, period_name, highs, lows):
        sar = talib.SAR(highs, lows)

        self.current_indicators[period_name]['sar'] = sar[-1] 
开发者ID:mcardillo55,项目名称:cbpro-trader,代码行数:6,代码来源:IndicatorSubsystem.py

示例6: DX

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def DX(DataFrame, N=14):
    res = talib.DX(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)
    return pd.DataFrame({'DX': res}, index=DataFrame.index)


# SAR - Parabolic SAR 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:8,代码来源:talib_indicators.py

示例7: SAR

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def SAR(DataFrame, acceleration=0, maximum=0):
    res = talib.SAR(DataFrame.high.values, DataFrame.low.values, acceleration, maximum)
    return pd.DataFrame({'SAR': res}, index=DataFrame.index) 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:5,代码来源:talib_indicators.py

示例8: sar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def sar(self, sym, frequency, *args, **kwargs):
        if not self.kbars_ready(sym, frequency):
            return []

        highs = self.high(sym, frequency)
        lows = self.low(sym, frequency)

        return ta.SAR(highs, lows, *args, **kwargs) 
开发者ID:myquant,项目名称:strategy,代码行数:10,代码来源:ta_indicator_mixin.py

示例9: add_SAREXT

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def add_SAREXT(self, startvalue=0, offsetonreverse=0,
               accelerationinitlong=0.02, accelerationlong=0.02,
               accelerationmaxlong=0.20, accelerationinitshort=0.02,
               accelerationshort=0.02, accelerationmaxshort=0.20,
               type='scatter', color='tertiary', **kwargs):
    """Parabolic SAR Extended."""

    if not (self.has_high and self.has_low):
        raise Exception()

    utils.kwargs_check(kwargs, VALID_TA_KWARGS)
    if 'kind' in kwargs:
        type = kwargs['kind']

    name = ('SAREXT({},{},{},{},'
            '{},{},{},{})'.format(str(startvalue), str(offsetonreverse),
                                  str(accelerationinitlong),
                                  str(accelerationlong),
                                  str(accelerationmaxlong),
                                  str(accelerationinitshort),
                                  str(accelerationshort),
                                  str(accelerationmaxshort)))
    self.pri[name] = dict(type=type, color=color)
    self.ind[name] = talib.SAREXT(self.df[self.hi].values,
                                  self.df[self.lo].values,
                                  startvalue, offsetonreverse,
                                  accelerationinitlong,
                                  accelerationlong,
                                  accelerationmaxlong,
                                  accelerationinitshort,
                                  accelerationshort,
                                  accelerationmaxshort)
    self.ind[name] = self.ind[name].abs()  # Bug right now with negative value


# Momentum indicators 
开发者ID:plotly,项目名称:dash-technical-charting,代码行数:38,代码来源:ta.py

示例10: sar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def sar(high, low, acceleration=0, maximum=0):
    return talib.SAR(high, low, acceleration, maximum) 
开发者ID:noda-sin,项目名称:ebisu,代码行数:4,代码来源:__init__.py

示例11: test_sar

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def test_sar():
    """test TA.SAR"""

    sar = TA.SAR(ohlc)
    talib_sar = talib.SAR(ohlc.high, ohlc.low)

    # assert sar.values[-1] == talib_sar.values[-1]
    # 1466.88618052864 == 1468.3663877395456
    # close enough
    pass 
开发者ID:peerchemist,项目名称:finta,代码行数:12,代码来源:test_reg.py

示例12: init

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def init(context):
    # context内引入全局变量:沪深主力连续合约(偷懒直接用米筐主力了。。。)
    context.s1 = "IF88"

    context.window = 80

    context.selOpen_Flag = False
    context.buyOpen_Flag = False

    # 据说SAR的使用需要根据势头改变大小哈,
    context.acceleration = 0.05

    # 初始化时订阅合约行情。订阅之后的合约行情会在handle_bar中进行更新。
    subscribe(context.s1)

    # 判断指标(搓键盘方便,无实际意义)
    context.JQ_selOpen = False
    context.JW_selOpen = False
    context.JE_selOpen = False
    context.JR_selOpen = False
    context.JQ_buyOpen = False
    context.JW_buyOpen = False
    context.JE_buyOpen = False
    context.JR_buyOpen = False
    context.JQ_selClos = False
    context.JW_selClos = False
    context.JE_selClos = False
    context.JR_selClos = False
    context.JQ_buyClos = False
    context.JW_buyClos = False
    context.JE_buyClos = False
    context.JR_buyClos = False

    scheduler.run_weekly(ADX, weekday=5) 
开发者ID:DingTobest,项目名称:Rqalpha-myquant-learning,代码行数:36,代码来源:ADXSAR.py

示例13: before_trading

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def before_trading(context):
    prices = history_bars(context.s1, context.window, '1d', fields=['high', 'low', 'close', 'open'])
    highP = prices['high']
    lowP = prices['low']
    closeP = prices['close']
    openP = prices['open']

    context.ADX = ta.ADXR(highP, lowP, closeP, timeperiod=14)
    context.Pdi = ta.PLUS_DI(highP, lowP, closeP, timeperiod=14)
    context.Ndi = ta.MINUS_DI(highP, lowP, closeP, timeperiod=14)

    context.MA_tw = ta.MA(closeP, timeperiod=20)[-5:]
    context.MA_fi = ta.MA(closeP, timeperiod=50)[-5:]
    context.MA_fork = context.MA_tw > context.MA_fi

    context.SAR = ta.SAR(highP, lowP, acceleration=context.acceleration, maximum=0.2)

    # context.JQ_selOpen = (context.ADX[-1]>=20) #& (context.ADX[-2]>=20) & (context.ADX[-1]<=30) & (context.ADX[-2]<=30)
    context.JW_selOpen = (context.Pdi[-1] <= context.Ndi[-1]) & (context.Pdi[-2] >= context.Ndi[-2])
    context.JE_selOpen = (context.MA_fork[-1]) & (context.MA_fork[-2]) & (not context.MA_fork[-3])
    context.JR_selOpen = (context.SAR[-1] >= 0.95 * openP[-1]) & (context.SAR[-2] <= 1.05 * closeP[-2])
    context.J_selOpen = context.JQ_selOpen & context.JW_selOpen & context.JE_selOpen & context.JR_selOpen

    # context.JQ_buyOpen = context.JQ_selOpen
    context.JW_buyOpen = (context.Pdi[-1] >= context.Ndi[-1]) & (context.Pdi[-2] <= context.Ndi[-2])
    context.JE_buyOpen = (not context.MA_fork[-1]) & (not context.MA_fork[-2]) & (not context.MA_fork[-3])
    context.JR_buyOpen = (context.SAR[-2] >= 0.95 * openP[-2]) & (context.SAR[-1] <= 1.05 * closeP[-1])
    context.J_buyOpen = context.JQ_buyOpen & context.JW_buyOpen & context.JE_buyOpen & context.JR_buyOpen


# 你选择的期货数据更新将会触发此段逻辑,例如日线或分钟线更新 
开发者ID:DingTobest,项目名称:Rqalpha-myquant-learning,代码行数:33,代码来源:ADXSAR.py

示例14: SAR

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def SAR(frame, acc_fator=.02, max_acc_factor=.2, high_col='high', low_col='low'):
    return _frame_to_series(frame, [high_col, low_col], talib.SAR, acc_fator, max_acc_factor) 
开发者ID:bpsmith,项目名称:tia,代码行数:4,代码来源:talib_wrapper.py

示例15: SAR

# 需要导入模块: import talib [as 别名]
# 或者: from talib import SAR [as 别名]
def SAR(data, **kwargs):
    _check_talib_presence()
    _, phigh, plow, _, _ = _extract_ohlc(data)
    return talib.SAR(phigh, plow, **kwargs) 
开发者ID:ranaroussi,项目名称:qtpylib,代码行数:6,代码来源:talib_indicators.py


注:本文中的talib.SAR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。