本文整理汇总了Python中talib.MEDPRICE属性的典型用法代码示例。如果您正苦于以下问题:Python talib.MEDPRICE属性的具体用法?Python talib.MEDPRICE怎么用?Python talib.MEDPRICE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类talib
的用法示例。
在下文中一共展示了talib.MEDPRICE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: medprice
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def medprice(candles: np.ndarray, sequential=False) -> Union[float, np.ndarray]:
"""
MEDPRICE - Median Price
:param candles: np.ndarray
:param sequential: bool - default=False
:return: float | np.ndarray
"""
if not sequential and len(candles) > 240:
candles = candles[-240:]
res = talib.MEDPRICE(candles[:, 3], candles[:, 4])
if sequential:
return res
else:
return None if np.isnan(res[-1]) else res[-1]
示例2: acosc
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def acosc(candles: np.ndarray, sequential=False) -> AC:
"""
Acceleration / Deceleration Oscillator (AC)
:param candles: np.ndarray
:param sequential: bool - default=False
:return: AC(osc, change)
"""
if not sequential and len(candles) > 240:
candles = candles[-240:]
med = talib.MEDPRICE(candles[:, 3], candles[:, 4])
ao = talib.SMA(med, 5) - talib.SMA(med, 34)
res = ao - talib.SMA(ao, 5)
mom = talib.MOM(res, timeperiod=1)
if sequential:
return AC(res, mom)
else:
return AC(res[-1], mom[-1])
示例3: ao
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def ao(candles: np.ndarray, sequential=False) -> AO:
"""
Awesome Oscillator
:param candles: np.ndarray
:param sequential: bool - default=False
:return: AO(osc, change)
"""
if not sequential and len(candles) > 240:
candles = candles[-240:]
med = talib.MEDPRICE(candles[:, 3], candles[:, 4])
res = talib.SMA(med, 5) - talib.SMA(med, 34)
mom = talib.MOM(res, timeperiod=1)
if sequential:
return AO(res, mom)
else:
return AO(res[-1], mom[-1])
示例4: med_price
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def med_price(self, sym, frequency):
if not self.kbars_ready(sym, frequency):
return []
highs = self.high(sym, frequency)
lows = self.low(sym, frequency)
v = ta.MEDPRICE(highs, lows)
return v
示例5: MEDPRICE
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def MEDPRICE(frame, high_col='high', low_col='low'):
return _frame_to_series(frame, [high_col, low_col], talib.MEDPRICE)
示例6: MEDPRICE
# 需要导入模块: import talib [as 别名]
# 或者: from talib import MEDPRICE [as 别名]
def MEDPRICE(data, **kwargs):
_check_talib_presence()
_, phigh, plow, _, _ = _extract_ohlc(data)
return talib.MEDPRICE(phigh, plow, **kwargs)