Browse Source

New indicators: highest, lowest

master
Denis Tereshkin 7 years ago
parent
commit
323006a475
  1. 2
      src/naiback/indicators/__init__.py
  2. 19
      src/naiback/indicators/highest.py
  3. 19
      src/naiback/indicators/lowest.py

2
src/naiback/indicators/__init__.py

@ -2,3 +2,5 @@
from .ema import EMA from .ema import EMA
from .rsi import RSI from .rsi import RSI
from .intradaybarnumber import IntradayBarNumber from .intradaybarnumber import IntradayBarNumber
from .highest import Highest,HighestValue
from .lowest import Lowest,LowestValue

19
src/naiback/indicators/highest.py

@ -0,0 +1,19 @@
import numpy as np
def Highest(data, period):
result = np.zeros(len(data))
if len(result) == 0:
return result
result[0] = data[0]
for i in range(1, len(data)):
result[i] = max(data[max(0, i - period):(i+1)])
return result
def HighestValue(data, index, period):
if len(data) == 0 or index >= len(data):
return None
if index == 0:
return data[0]
return max(data[max(0, index - period):(index+1)])

19
src/naiback/indicators/lowest.py

@ -0,0 +1,19 @@
import numpy as np
def Lowest(data, period):
result = np.zeros(len(data))
if len(result) == 0:
return result
result[0] = data[0]
for i in range(1, len(data)):
result[i] = min(data[max(0, i - period):(i+1)])
return result
def LowestValue(data, index, period):
if len(data) == 0 or index >= len(data):
return None
if index == 0:
return data[0]
return min(data[max(0, index - period):(index+1)])
Loading…
Cancel
Save