Skip to main content

A python library for computing technical analysis indicators on streaming data.

Project description

Streaming Indicators

A python library for computing technical analysis indicators on streaming data.

Installation

pip install streaming-indicators

Why another TA library?

There are many other technical analysis python packages, most notably ta-lib, then why another library?
All other libraries work on static data, you can not add values to any indicator. But in real-time trading system, price values (ticks/candles) keeps streaming, and indicators should update on real-time. This library is for that purpose.

Usage

Each indicator is a class, and is statefull. It will have 3 main functions:

  1. Constructor: initialise all parameters such as period.
  2. update: To add new data point in the indicator computation. Returns the new value of the indicator.
  3. compute: Compute indicator value with a new data point, but don't update it's state. This is useful in some cases, for example, compute indictor on ltp, but don't update it.

List of indicators (and usage)

  • Simple Moving Average (SMA)
import streaming_indicators as si

period = 14
SMA = si.SMA(period)
for idx, candle in candles.iterrows():
    sma = SMA.update(candle['close'])
    print(sma)
  • Exponential Moving Average (EMA)
period = 14
EMA = si.EMA(period)
for idx, candle in candles.iterrows():
    ema = EMA.update(candle['close'])
    print(ema)
  • Weighted Moving Average (WMA)
  • Smoothed Moving Average (SMMA)
  • Relative Strength Index (RSI)
period = 14
RSI = si.RSI(period)
for idx, candle in candles.iterrows():
    rsi = RSI.update(candle['close'])
    print(rsi)
  • True Range (TRANGE)
  • Average True Range (ATR)
atr_period = 20
ATR = si.ATR(atr_period)
for idx, candle in candles.iterrows():
    atr = ATR.update(candle)  # Assumes candle to have 'open',high','low','close' - TODO: give multiple inputs to update.
    print(atr)
  • SuperTrend (SuperTrend)
st_atr_length = 10
st_factor = 3
ST = si.SuperTrend(st_atr_length, st_factor)
for idx, candle in candles.iterrows():
    st = ST.update(candle)
    print(st) # (st_direction:1/-1, band_value)

To use some historical candles to initiate, use: ST = si.SuperTrend(st_atr_length, st_factor, candles=initial_candles) where initial_candles is pandas dataframe with open,high,low,close columns.

  • Heikin Ashi Candlesticks (HeikinAshi)
HA = si.HeikinAshi()
for idx, candle in candles.iterrows():
    ha_candle = HA.update(candle)
    print(ha_candle) # {'close': float, 'open': float, 'high': float, 'low': float}
  • Renko Bricks (Renko)
# For fixed brick size
brick_size = 20
Renko = si.Renko()
for idx, candle in candles.iterrows():
    bricks = Renko.update(candle['close'], brick_size)
    print(bricks) # [{'direction': 1/-1, 'brick_num': int, 'wick_size': float, 'brick_size': float, 'brick_end_price': float, 'price': float}, {}]: list of bricks formed after this candle
# For brick size using ATR
atr_period = 20
ATR = si.ATR(atr_period)
Renko = si.Renko()
for idx, candle in candles.iterrows():
    atr = ATR.update(candle)
    print(atr)
    bricks = Renko.update(candle['close'], atr)
    print(bricks)
  • Order Checking (IsOrder) Checks if the running sequence is in a given order, eg increasing, decreasing, exponential, etc. Useful when checking if consecutive n candles/ltps were increasing.
period = 10
all_increasing = IsOrder('>', period)
for idx, candle in candles.iterrows():
    is_increasing = all_increasing.update(candle['close'])
    print(is_increasing) # True/False

TODO

  • Not all indicators currently support compute method.
  • Add documentation.
  • SuperTrend,HeikinAshi,ATR depends on key names, eg ('open','close'). Should be independent, i.e. given in input. (similar to pandas_ta)
  • Add initalisation to all indicators similar to SuperTrend.
  • Implement more indicators. MIT License

Copyright (c) [2023] [Rishabh Gupta]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streaming_indicators-0.0.8.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

streaming_indicators-0.0.8-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file streaming_indicators-0.0.8.tar.gz.

File metadata

  • Download URL: streaming_indicators-0.0.8.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.0

File hashes

Hashes for streaming_indicators-0.0.8.tar.gz
Algorithm Hash digest
SHA256 bd274dd767c043c231ce353d48bd649686704de093aeb0cbd05ed5eed57c0144
MD5 9b912e0c6542636fe63a6fa14db9df15
BLAKE2b-256 392dd327d0363d4289908598d9fbc4795ea17cfb5c312e41ebc90b4de23de863

See more details on using hashes here.

Provenance

File details

Details for the file streaming_indicators-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for streaming_indicators-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1453f2829b9ae5f26e8a642f46d890654efed1ba6dff12b86f314b83d9886067
MD5 03b7a41f33d8b626f76f782e398f3075
BLAKE2b-256 372d4b964c0b5808695d9fb1292144a148438216eb45704aa07d2eb21d95dedb

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page