Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Apply popular TA tools and charts to candlestick data with NumPy.

License

NotificationsYou must be signed in to change notification settings

pegahcarter/TAcharts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

By: Carter Carlson

This repository provides technical tools to analyze OHLCV data, along with severalTA chart functionalities. These functions are optimized for speed and utilize numpyvectorization over built-in pandas methods when possible.

Methods

Indicators With Chart Functionality

  • Bollinger(df=None, filename=None, interval=None, n=20, ndev=2): Bollinger Bands
  • Ichimoku(df=None, filename=None, interval=None): Ichimoku Cloud
  • Renko(df=None, filename=None, interval=None): Renko Chart

Indicators Without Chart Functionality

  • atr(high, low, close, n=2): average true range from candlestick data
  • cmf(df, n=2): Chaikin Money Flow of an OHLCV dataset
  • double_smooth(src, n_slow, n_fast): The smoothed value of two EMAs
  • ema(src, n=2): exponential moving average for a list ofsrc acrossn periods
  • macd(src, slow=25, fast=13): moving average convergence/divergence ofsrc
  • mmo(src, n=2): Murrey Math oscillator ofsrc
  • roc(src, n=2): rate of change ofsrc acrossn periods
  • rolling(src, n=2, fn=None, axis=1): rollingsum,max,min,mean, ormedian ofsrc acrossn periods
  • rsi(src, n=2): relative strength index ofsrc acrossn periods
  • sdev(src, n=2): standard deviation across n periods
  • sma(src, n=2): simple moving average ofsrc acrossn periods
  • td_sequential(src, n=2): TD sequential ofsrc acrossn periods
  • tsi(src, slow=25, fast=13): true strength indicator

utils

  • area_between(line1, line2): find the area between line1 and line2
  • crossover(x1, x2): find all instances of intersections between two lines
  • draw_candlesticks(ax, df): add candlestick visuals to a matplotlib chart
  • fill_values(averages, interval, target_len): Fill missing values with evenlyspaced samples.
    • Example: You're using 15-min candlestick data to find the 1-hour moving averageand want a value at every 15-min mark, and not every 1-hour mark.
  • group_candles(df, interval=4): combine candles so instead of needing a differentdataset for each time interval, you can form time intervals using more precisedata.
    • Example: you have 15-min candlestick data but want to test a strategy basedon 1-hour candlestick data (interval=4).
  • intersection(a0, a1, b0, b1): find the intersection coordinates between vectorA and vector B

How it works

Create your DataFrame

# NOTE: we are using 1-hour BTC OHLCV data from 2019.01.01 00:00:00 to 2019.12.31 23:00:00fromTAcharts.utils.ohlcvimportOHLCVdf=OHLCV().btcdf.head()
 dateopenhighlowclosevolume
02019-01-01 00:00:003699.953713.933697.003703.56660.279771
12019-01-01 01:00:003703.633726.643703.343713.83823.625491
22019-01-01 02:00:003714.193731.193707.003716.70887.101362
32019-01-01 03:00:003716.983732.003696.143699.95955.879034
42019-01-01 04:00:003699.963717.113698.003713.07534.113945

Bollinger Bands

fromTAcharts.indicators.bollingerimportBollingerb=Bollinger(df)b.build(n=20,ndev=2)b.plot()

bollinger

Ichimoku

fromTAcharts.indicators.ichimokuimportIchimokui=Ichimoku(df)i.build(20,60,120,30)i.plot()

ichimoku

Renko

fromTAcharts.indicators.renkoimportRenkor=Renko(df)r.set_brick_size(auto=True,atr_interval=2)r.build()r.plot()

renko


wrappers

  • @args_to_dtype(dtype): Convert all function arguments to a specific data type

    fromTAcharts.wrappersimportargs_to_dtype# Example: `src` is converted to a list@args_to_dtype(list)defrsi(src,n=2):pass
  • @pd_series_to_np_array: Convert function arguments frompd.Series tonp.array usingpd.Series.values. This wrapper is 10x quicker than using@args_to_dtype(np.array) when working with Pandas series.

    fromTAcharts.wrappersimportpd_series_to_np_array# Example: `high`, `low`, and `close` are all converted into `np.array` data types@pd_series_to_np_arraydefatr(high,low,close,n=14):pass

[8]ページ先頭

©2009-2025 Movatter.jp