Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using convention if .iloc instead of direct index seek #345

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements-core.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy==1.21.5
pandas==1.3.5
numpy==1.19.5
pandas==1.1.5
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements-core.txt

# clean code
black==23.10.1
prospector[with_mypy,with_bandit]==1.10.3
black==22.8.0
prospector[with_mypy,with_bandit]==1.7.7
10 changes: 5 additions & 5 deletions ta/trend.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def _run(self):

self._trs_initial = np.zeros(self._window - 1)
self._trs = np.zeros(len(self._close) - (self._window - 1))
self._trs[0] = diff_directional_movement.dropna().iloc[0 : self._window].sum()
self._trs[0] = diff_directional_movement.dropna().iloc[0:self._window].sum()
diff_directional_movement = diff_directional_movement.reset_index(drop=True)

for i in range(1, len(self._trs) - 1):
Expand All @@ -745,7 +745,7 @@ def _run(self):
neg = abs(((diff_down > diff_up) & (diff_down > 0)) * diff_down)

self._dip = np.zeros(len(self._close) - (self._window - 1))
self._dip[0] = pos.dropna().iloc[0 : self._window].sum()
self._dip[0] = pos.dropna().iloc[0:self._window].sum()

pos = pos.reset_index(drop=True)

Expand All @@ -757,7 +757,7 @@ def _run(self):
)

self._din = np.zeros(len(self._close) - (self._window - 1))
self._din[0] = neg.dropna().iloc[0 : self._window].sum()
self._din[0] = neg.dropna().iloc[0:self._window].sum()

neg = neg.reset_index(drop=True)

Expand Down Expand Up @@ -804,7 +804,7 @@ def adx(self) -> pd.Series:
directional_index[idx] = 0

adx_series = np.zeros(len(self._trs))
adx_series[self._window] = directional_index[0 : self._window].mean()
adx_series[self._window] = directional_index[0:self._window].mean()

for i in range(self._window + 1, len(adx_series)):
adx_series[i] = (
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def _run(self): # noqa
high1 = self._high.iloc[i - 1]
high2 = self._high.iloc[i - 2]
if high2 > self._psar.iloc[i]:
self._psar[i] = high2
self._psar.iloc[i] = high2
elif high1 > self._psar.iloc[i]:
self._psar.iloc[i] = high1

Expand Down
2 changes: 1 addition & 1 deletion ta/volatility.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _run(self):
close_shift = self._close.shift(1)
true_range = self._true_range(self._high, self._low, close_shift)
atr = np.zeros(len(self._close))
atr[self._window - 1] = true_range[0 : self._window].mean()
atr[self._window - 1] = true_range[0:self._window].mean()
for i in range(self._window, len(atr)):
atr[i] = (atr[i - 1] * (self._window - 1) + true_range.iloc[i]) / float(
self._window
Expand Down