Library / SDK
mpquant/MyTT avatar
mpquant/MyTT

MyTT: Tongdaxin and Tonghuashun Indicator Formulas Ported to Python

MyTT ports Tongdaxin/Tonghuashun/Wenhua indicator formulas to pure Python in a single ~100-line file with about a dozen core functions, implementing common technical indicators (MACD, RSI, BOLL, ATR, KDJ, CCI, PSY, etc.) without TA-Lib, built on pandas for simplicity and performance. A Python library covering most stock market indicators.

2,895 stars734 forksPythonLicense varies

At a glance

What is it?
MyTT is a single-file Python library that reimplements common Chinese trading-platform indicator formulas with pandas and numpy, avoiding a TA-Lib install. It suits people porting existing formula code, not people who need a maintained, versioned indicator package.
Who is it for?
Adopt MyTT if you already have Tongdaxin, Tonghuashun or WenHua formula text and want the same numbers in a pandas pipeline, or if a TA-Lib build is the thing blocking you. Do not adopt it if you need a versioned package with a documented release history, a stated licence, or a supported API surface: the repository shows no releases, and the README carries a GPL badge but no licence file among the top-level entries.
Can I use it commercially?
Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
Is it still maintained?
Yes. The repository last received commits 165 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • mpquant/MyTT2,895 ★ · +25
Star history
Repository2026-10-042026-11-24
mpquant/MyTT2.9k2.9k

25 Stars in the last 51 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The problem MyTT solves is formula translation, not indicator coverage

Chinese retail trading platforms ship their own formula language. A user writes MACD, KDJ or BOLL as a short expression in Tongdaxin, Tonghuashun or WenHua's Mai language, and that expression is not Python. Moving a strategy into a pandas workflow normally means rewriting each formula by hand, and hand rewrites drift: a different EMA seeding convention, a different handling of the first N bars, and the Python number no longer matches the platform the trader has been staring at for years. MyTT's stated job is to close that gap. The README describes it as a minimal port of those formula languages into Python, with the core library in a single file, MyTT.py, at roughly a hundred lines, exposing a dozen or so core functions. The audience is narrow and specific: someone with working platform formulas and a Python analysis or execution stack. It is not aimed at someone who wants a general-purpose technical analysis library with hundreds of indicators and a plugin ecosystem.

Sequence in, sequence out: how the indicator functions are built

The design is deliberately flat. Every helper takes a numpy array or list and returns an array of the same length, which the README calls the same convention as TA-Lib: multiple days in, multiple days of indicator out. That convention is what makes the port mechanical. A platform formula such as REF(CLOSE, 1) becomes a call to REF, and MA(CLOSE, 5) becomes MA. The primitives listed in the README cover the vocabulary the formula languages share: REF, MA, EMA, SMA, STD, AVEDEV, CROSS, MAX, MIN, COUNT, EVERY, LAST, EXIST, BARSLAST, SLOPE, FORCAST, HHV, LLV and IF. Composite indicators are then written as ordinary Python functions on top of those primitives. MACD is DIF = EMA(CLOSE,SHORT) - EMA(CLOSE,LONG), DEA = EMA(DIF,M), MACD = (DIF-DEA)*2. KDJ computes RSV from LLV and HHV over N bars, then smooths with EMA using (M1*2-1) and (M2*2-1) as periods. RSI uses SMA of the positive part divided by SMA of the absolute difference. BOLL is a moving average plus or minus a standard deviation multiple. The arithmetic is not new; the value is that the arithmetic is expressed the way the platform expresses it, and that no loop appears in the implementations, since the README states the functions are built on numpy and pandas built-ins. One consequence worth noting: because these are plain functions over arrays, there is no index alignment, no symbol registry and no caching. You supply the close, high, low and open series yourself, and you keep them in the right order.

Installing MyTT and computing a first MACD

There are two documented routes. The first is to copy MyTT.py into your project directory and import it; the README presents this as the no-setup option and notes the file can be trimmed freely. The second is the conventional package install. The README gives the package name in mixed case and warns about it explicitly, so keep the capitalisation as written.

bash
pip install MyTT

With the library importable, the README's own minimal example generates a random integer series and runs a six-period EMA over it. That is the fastest way to confirm the import works before touching real price data.

python
from MyTT import *
S = np.random.randint(1, 99, [10])
EMA(S, 6)

The README's fuller example assumes a price frame with open, close, high, low and vol columns, and pulls the arrays out before calling the indicators. The pattern is the same for any data source: get a series, pass it in, take the last element or the whole array.

python
CLOSE = df.close.values
OPEN = df.open.values
HIGH = df.high.values
LOW = df.low.values
MA5 = MA(CLOSE, 5)
MA10 = MA(CLOSE, 10)
print('BTC5日均线', MA5[-1])
print('今天5日线是否上穿10日线', RET(CROSS(MA5, MA10)))

The README also shows MACD, KDJ, RSI, WR, BIAS, BOLL, PSY, CCI, ATR, BBI, TAQ and KTN as ready-made functions in the same file, so a first real use is usually calling one of those rather than writing one. If you are porting your own formula, write it against the primitives and compare the output against the platform chart. The README states MyTT's indicators match Tongdaxin, Tonghuashun and Xueqiu to two decimal places, and that EMA and SMA need at least 120 periods for that precision. Treat the 120-period note as an operating constraint, not a suggestion.

Two MyTT files, no releases, and a licence the repository does not spell out

The repository layout is small: MyTT.py, MyTT_plus.py, MyTT_python2.py, README.md, example1.py, hb_hq_api.py, an img directory and a .vscode directory. MyTT_plus.py is described as the advanced version holding more complex usages and experimental validation functions, and MyTT_python2.py is a separate file for running under Python 2 with an older pandas. That is three parallel copies of the same idea, which is a maintenance fact rather than a criticism: a fix to an indicator in MyTT.py does not automatically reach the other two files, and the README does not describe any sync process between them. The repository has no published GitHub releases, so there is no version number to pin and no changelog to read. The last push to the repository was on 2026-06-13. The README carries a GPL licence badge, but no licence file appears among the top-level repository entries, so anyone who needs the exact terms should read the badge link and the source headers rather than assume. The README also points to a set of tutorial posts on JoinQuant covering formula conversion, integration and precision verification; those posts, not the repository, are where the worked examples live.

Where MyTT is the wrong tool

MyTT has no data layer. The README's example imports hb_hq_api for a get_price call, and that module is a companion file in the repository rather than something MyTT provides; if you have no equivalent, you supply OHLCV yourself. There is no streaming path, no incremental update, and no state carried between calls. Every indicator recomputes over the full array you hand it, which is fine for a research frame and awkward for a live loop that appends one bar at a time. Precision is also bounded by input length. The README is explicit that EMA and SMA want at least 120 periods for accuracy, so a freshly listed instrument with 40 bars will not reproduce the platform's number, and nothing in the library warns you. Finally, the scope is the formula vocabulary, not analysis. There is no backtesting engine, no position accounting, no order handling. If your actual problem is running a strategy end to end, MyTT is one small piece of it, and the README presents it that way.

MyTT versus TA-Lib: the difference is the formula dialect

TA-Lib is the obvious comparison, and the README makes it directly, noting that MyTT is pure Python and that many people find installing TA-Lib painful. The difference in approach goes deeper than the install. TA-Lib is a compiled C library with a fixed catalogue of indicators and a wrapper API; you choose from what it implements, and a formula that is not in the catalogue has to be written outside it. MyTT is the opposite shape: a small set of primitives that mirror the platform formula language, plus composite indicators assembled from them, all in readable Python. If your indicator is standard and your environment already has TA-Lib, TA-Lib gives you a tested, versioned, widely deployed implementation. If your indicator came from a Tongdaxin or Tonghuashun chart and you need the same line, MyTT's primitives are a shorter path, because the port is close to a transliteration. The trade-off is real in both directions: TA-Lib buys you a release history and a build step, MyTT buys you editability and no build step, at the cost of a single file you may end up maintaining yourself.

Who should take MyTT and what to check before you depend on it

The fit is a quant or analyst who already has platform formulas, works in pandas, and wants those formulas running in Python without a TA-Lib build. The mismatch is anyone who needs a pinned dependency, a documented release process, or a defined licence before shipping. The pragmatic path is to test before you commit: copy MyTT.py into a scratch project, run MACD and KDJ over a series whose platform values you already trust, and check the two-decimal agreement the README claims. If you need the extra functions, read MyTT_plus.py separately, since it is a distinct file. If you are on Python 2 with an old pandas, use MyTT_python2.py. And if you plan to rely on it in production, read the GPL badge link and the source headers, because the repository's top-level entries do not include a licence file.

Editorial conclusion

Adopt MyTT if you already have Tongdaxin, Tonghuashun or WenHua formula text and want the same numbers in a pandas pipeline, or if a TA-Lib build is the thing blocking you. Do not adopt it if you need a versioned package with a documented release history, a stated licence, or a supported API surface: the repository shows no releases, and the README carries a GPL badge but no licence file among the top-level entries. Before relying on it, copy MyTT.py into a scratch directory, run MACD and KDJ against a series you have already validated elsewhere, and confirm the outputs match to two decimals as the README claims.

Frequently asked questions

Does MyTT require TA-Lib to be installed?

No. The README states the core logic is pure Python and that TA-Lib is not needed, which it presents as an advantage because installing TA-Lib is often difficult. The indicator functions are built on numpy and pandas instead.

How do I install MyTT?

The README gives two routes: copy MyTT.py into your project and import it, or run pip install MyTT. The README warns that the package name is case-sensitive, so write it as MyTT.

Why does MyTT's EMA or SMA not match my platform exactly?

The README notes that EMA and SMA need at least 120 periods to reach the stated precision, and that MyTT's indicators match Tongdaxin, Tonghuashun and Xueqiu to two decimal places. Short series will not reproduce the platform value.

Official sources

  1. Issues
  2. mpquant/MyTT on GitHub
  3. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/mpquant-mytt.svg)](https://hysenlabs.com/projects/mpquant-mytt)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/mpquant-mytt.svg)](https://hysenlabs.com/projects/mpquant-mytt)

Was this useful?