Comments (2)
Python test code is here:
TA-Lib/ta-lib-python#435 (comment)
OK, I have showed my point theoretically (in the OP).
Now I just did the following test, it shows (actually proves) The MFI function has no unstable period (up to numeric calculation stability).
import pandas as pd
import numpy as np
def test():
# check RSI vs MFI unstable period.
fn = "SPY.csv"
df = pd.read_csv(fn)
df["ratio" ] = df["Adj Close"] / df["Close"]
df["Open" ] = df["Open" ] * df["ratio"]
df["High" ] = df["High" ] * df["ratio"]
df["Low" ] = df["Low" ] * df["ratio"]
df["Close" ] = df["Close" ] * df["ratio"]
o = np.array(df["Open"])
h = np.array(df["High"])
l = np.array(df["Low"])
c = np.array(df["Close"])
v = np.array(df["Volume"], dtype=np.double)
rsi = []
for n in [40, 50]:
r = talib.RSI(c[-n:])
print(r)
rsi.append(r)
m = 40 - 14
diff = np.abs(rsi[0][-m:] - rsi[1][-m:])
print(np.max(diff), np.mean(diff)) # 2.6424354952679963 1.1047087679412708
mfi = []
for n in [40, 50]:
m = talib.MFI(h[-n:], l[-n:], c[-n:], v[-n:])
print(m)
mfi.append(m)
m = 40 - 14
diff = np.abs(mfi[0][-m:] - mfi[1][-m:])
print(np.max(diff), np.mean(diff)) # 1.4210854715202004e-14 5.738999019600809e-15
assert(np.all(np.isclose(mfi[0][-m:], mfi[1][-m:]))) # pass!
As you can see the rsi diff (max() & mean()) is quite big (because of the EMA kind of memory -- the inherent difference caused by the algorithm); But the the mfi diff is every small (it should all be 0, the diff is caused by numeric computation stability, i.e. rounding error caused by operation sequence.)
You can try this code yourself.
from ta-lib.
Hey @mingwugmail , I cloned the repo from sourceforge to github to make sure I can add the project as a git submodule. I have no plan to maintain this project however. If you are interested in maintaining this project or if you can reach to the original developer, I'd like to transfer the ownership of the git org.
from ta-lib.
Related Issues (20)
- Error in installing TA-Lib by "Could not build wheels for TA-Lib, which is required to install pyproject.toml-based projects" error
- SAREXT is broken?
- Outdate CMakeLists
- About rust lib HOT 1
- test_imi failed
- Please conside making a release
- ARM support
- RVI indicator HOT 1
- ADR Indicator
- Koncorde Indicator
- Williams Alligator
- Connors RSI
- Awesome Oscillator
- Renko for Candlesticks
- Smoothed SMA
- KDJ Indicator
- PVT Indicator
- Problem with rate of change ratio (ROCR) and relevant indicators. HOT 1
- Investigate Sourceforge Tickets
- Release v0.5 (or v0.4.1) with the small values fix
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ta-lib.