Python talib.MEDPRICE Examples
The following are 6
code examples of talib.MEDPRICE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
talib
, or try the search function
.
Example #1
Source File: ao.py From jesse with MIT License | 7 votes |
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])
Example #2
Source File: medprice.py From jesse with MIT License | 6 votes |
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]
Example #3
Source File: acosc.py From jesse with MIT License | 6 votes |
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])
Example #4
Source File: ta_indicator_mixin.py From strategy with Apache License 2.0 | 5 votes |
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
Example #5
Source File: talib_wrapper.py From tia with BSD 3-Clause "New" or "Revised" License | 5 votes |
def MEDPRICE(frame, high_col='high', low_col='low'): return _frame_to_series(frame, [high_col, low_col], talib.MEDPRICE)
Example #6
Source File: talib_indicators.py From qtpylib with Apache License 2.0 | 5 votes |
def MEDPRICE(data, **kwargs): _check_talib_presence() _, phigh, plow, _, _ = _extract_ohlc(data) return talib.MEDPRICE(phigh, plow, **kwargs)