當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。