Skip to content
Back to search

polars-ta-extension

MarketplaceWorks with Claude CodeGitHub

Polars TA-Lib coding skills.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/yvictor--polars-ta-extension/badge.svg)](/listings/yvictor--polars-ta-extension)

HTML

<a href="/listings/yvictor--polars-ta-extension"><img src="/api/listings/yvictor--polars-ta-extension/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

pip install 'polars-talib==0.2.1'
# or, in a uv project
uv add 'polars-talib==0.2.1'

and

import polars
import polars_talib as plta

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 16 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "polars-ta-extension",
  3. "owner": {
  4. "name": "Yvictor",
  5. "url": "https://github.com/Yvictor"
  6. },
  7. "description": "Polars TA-Lib coding skills.",
  8. "plugins": [
  9. {
  10. "name": "polars-talib",
  11. "source": "./plugins/polars-talib",
  12. "description": "Use all 201 TA-Lib indicators in native Polars expressions, grouped time series and lazy pipelines.",
  13. "version": "0.2.1"
  14. }
  15. ]
  16. }
README.md · README · 195 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Polars Extension for Ta-Lib
  2. Version **0.2.1** bundles **TA-Lib 0.8.1**: all **201 batch indicators**,
  3. including SuperTrend, VWAP, HMA, KDJ and Heikin-Ashi. Python 3.10+; Polars 1.20+
  4. and 2.x.
  5. Binary wheels include the C library.
  6. - [Upgrade notes, platform matrix and source builds](docs/upgrade-0.2.0.md)
  7. - [Install the skill for Codex, Claude Code or Cursor](docs/skills.md)
  8. - [Reproducible performance results](docs/performance.md)
  9. ## Native AI plugin installation
  10. The repository supports the same native marketplace/install flow as
  11. [Shioaji](https://github.com/Sinotrade/Shioaji#ai-coding-agent-skills):
  12. ```sh
  13. # Claude Code
  14. claude plugin marketplace add Yvictor/polars_ta_extension
  15. claude plugin install polars-talib@polars-ta-extension
  16. # Codex
  17. codex plugin marketplace add Yvictor/polars_ta_extension
  18. codex plugin add polars-talib@polars-ta-extension
  19. ```
  20. See [skill installation](docs/skills.md) for invocation, updates, local checkouts,
  21. standalone installation, and Cursor support. The plugin supplies coding guidance;
  22. install the Python library separately.
  23. ## Getting Started
  24. ``` bash
  25. pip install 'polars-talib==0.2.1'
  26. # or, in a uv project
  27. uv add 'polars-talib==0.2.1'
  28. ```
  29. and
  30. ```
  31. import polars
  32. import polars_talib as plta
  33. ```
  34. ## Usage
  35. ### single symbol usage
  36. ``` python
  37. df.with_columns(
  38. pl.col("close").ta.ema(5).alias("ema5"),
  39. pl.col("close").ta.macd(12, 26, 9).struct.field("macd"),
  40. pl.col("close").ta.macd(12, 26, 9).struct.field("macdsignal"),
  41. pl.col("open").ta.cdl2crows(pl.col("high"), pl.col("low"), pl.col("close")).alias("cdl2crows"),
  42. pl.col("close").ta.wclprice("high", "low").alias("wclprice"),
  43. )
  44. ```
  45. ### typed namespace access
  46. `plta.col(...)` returns the same `.ta` namespace with a static return type, so
  47. editors and type checkers resolve every indicator method:
  48. ``` python
  49. df.with_columns(
  50. plta.col("close").ema(5).alias("ema5"),
  51. plta.col(pl.col("close") * 2).rsi(14).alias("rsi_doubled"),
  52. )
  53. ```
  54. ### multiple symbol usage using over syntax
  55. Sort by symbol and timestamp before computing history-dependent indicators.
  56. ``` python
  57. df.with_columns(
  58. pl.col("close").ta.ema(5).over("symbol").alias("ema5"),
  59. pl.col("close").ta.macd(12, 26, 9).over("symbol").struct.field("macd"),
  60. pl.col("close").ta.macd(12, 26, 9).over("symbol").struct.field("macdsignal"),
  61. pl.col("open").ta.cdl2crows(
  62. pl.col("high"), pl.col("low"), pl.col("close")
  63. ).over("symbol").alias("cdl2crows"),
  64. pl.col("close").ta.wclprice("high", "low").over("symbol").alias("wclprice"),
  65. )
  66. ```
  67. ### missing values
  68. A Polars null marks a missing observation. Leading nulls are skipped as warm-up.
  69. After that, every output row that can depend on a null input is null: to the end
  70. of the partition for recursive indicators such as RSI, EMA, MACD or OBV, and for
  71. the indicator's lookback window for window-bounded ones such as MAX, WILLR or the
  72. math operators. A null never turns into a plausible number, and under
  73. `.over("symbol")` it only affects its own symbol. NaN and infinity are ordinary
  74. float values and are passed to TA-Lib unchanged, so its results for them are
  75. undefined; use `pl.col("close").fill_nan(None)` when NaN means missing. To
  76. restart an indicator after each gap instead, or to skip gaps:
  77. ``` python
  78. # restart after every gap, per symbol
  79. gap = pl.col("close").is_null().cum_sum()
  80. df = df.with_columns(pl.col("close").ta.rsi(14).over("symbol", gap).alias("rsi_restart"))
  81. # compute over observed rows only (e.g. market-closed days), then join back
  82. observed = df.filter(pl.col("close").is_not_null()).with_columns(
  83. pl.col("close").ta.rsi(14).over("symbol").alias("rsi_observed")
  84. )
  85. df = df.join(observed.select("symbol", "date", "rsi_observed"), on=["symbol", "date"], how="left")
  86. ```
  87. ### usage just like talib.abstract with more flexible
  88. ``` python
  89. df.with_columns(
  90. plta.ht_dcperiod(),
  91. plta.ht_dcperiod(pl.col("close")),
  92. plta.aroon(),
  93. plta.aroon(pl.col("high"), pl.col("low"), timeperiod=10),
  94. plta.wclprice(),
  95. plta.wclprice(
  96. pl.col("high"), pl.col("low"), pl.col("close"),
  97. timeperiod=10
  98. ),
  99. )
  100. ```
  101. ## Performance
  102. See the [0.2.0 release benchmark](docs/performance.md) for a controlled comparison
  103. against 0.1.6, raw samples and a reproducible script. The notebook comparison
  104. below is historical and measures a different workload.
  105. ### Polars with polars_talib
  106. ``` python
  107. %%timeit
  108. df = p.with_columns(
  109. plta.sma(timeperiod=5).over("Symbol").alias("sma5"),
  110. plta.macd(fastperiod=10, slowperiod=20, signalperiod=5).over("Symbol").alias("macd"),
  111. plta.stoch(pl.col("high"), pl.col("low"), pl.col("close"), fastk_period=14, slowk_period=7, slowd_period=7).over("Symbol").alias("stoch"),
  112. plta.wclprice().over("Symbol").alias("wclprice"),
  113. ).with_columns(
  114. pl.col("macd").struct.field("macd"),
  115. pl.col("macd").struct.field("macdsignal"),
  116. pl.col("macd").struct.field("macdhist"),
  117. pl.col("stoch").struct.field("slowk"),
  118. pl.col("stoch").struct.field("slowd"),
  119. ).select(
  120. pl.exclude("stoch")
  121. ).filter(
  122. pl.col("Symbol") == "AAPL"
  123. ).collect()
  124. ```
  125. 135 ms ± 5.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  126. ### Pandas with talib
  127. ```python
  128. %%timeit
  129. df["sma5"] = df.groupby("Ticker")["close"].transform(lambda x: ta.SMA(x, timeperiod=5))
  130. df["macd"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[0])
  131. df["macdsignal"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[1])
  132. df["macdhist"] = df.groupby("Ticker")["close"].transform(lambda x: ta.MACD(x, fastperiod=10, slowperiod=20, signalperiod=5)[2])
  133. df["slowk"] = df.groupby("Ticker").apply(lambda x: ta.STOCH(x, fastk_period=14, slowk_period=7, slowd_period=7)).droplevel(0)["slowk"]
  134. df["slowd"] = df.groupby("Ticker").apply(lambda x: ta.STOCH(x, fastk_period=14, slowk_period=7, slowd_period=7)).droplevel(0)["slowd"]
  135. df["wclprice"] = df.groupby("Ticker").apply(lambda x: ta.WCLPRICE(x)).droplevel(0)
  136. df.loc["AAPL"]
  137. ```
  138. 19.2 s ± 367 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  139. That historical notebook measured about 150x for this workload; see [basic.ipynb](./examples/basic.ipynb)
  140. ## Supported Indicators and Functions
  141. ``` python
  142. import polars_talib as plta
  143. # list of functions
  144. plta.get_functions()
  145. # dict of functions by group
  146. plta.get_function_groups()
  147. ```
  148. The complete [201-indicator catalog](docs/indicators.md) includes every function
  149. in the pinned upstream release. New examples:
  150. ```python
  151. df.with_columns(
  152. plta.supertrend().alias("supertrend"),
  153. plta.vwap().alias("vwap"),
  154. pl.col("close").ta.hma(timeperiod=20).alias("hma"),
  155. plta.kdj().alias("kdj"),
  156. )
  157. ```
  158. Multi-output indicators return Struct columns. For example,
  159. `plta.supertrend().struct.field("trend")` returns the Int32 trend flag.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.