本文整理匯總了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)