All Projects → WestXu → support_resistance_line

WestXu / support_resistance_line

Licence: MIT license
A well-tuned algorithm to generate & draw support/resistance line on time series. 根据时间序列自动生成支撑线压力线

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to support resistance line

ml monorepo
super-monorepo for machine learning and algorithmic trading
Stars: ✭ 43 (-18.87%)
Mutual labels:  time-series, quantitative-finance
Systemicrisk
A framework for systemic risk valuation and analysis.
Stars: ✭ 72 (+35.85%)
Mutual labels:  time-series, quantitative-finance
HistoricalVolatility
A framework for historical volatility estimation and analysis.
Stars: ✭ 22 (-58.49%)
Mutual labels:  time-series, quantitative-finance
Strategems.jl
Quantitative systematic trading strategy development and backtesting in Julia
Stars: ✭ 106 (+100%)
Mutual labels:  time-series, quantitative-finance
Time Series Machine Learning
Machine learning models for time series analysis
Stars: ✭ 261 (+392.45%)
Mutual labels:  time-series, quantitative-finance
okama
Investment portfolio and stocks analyzing tools for Python with free historical data
Stars: ✭ 87 (+64.15%)
Mutual labels:  time-series, quantitative-finance
Machine-Learning-Projects-2
No description or website provided.
Stars: ✭ 23 (-56.6%)
Mutual labels:  time-series
QuoraBooks
A GitHub repo for Quant Finance resources
Stars: ✭ 17 (-67.92%)
Mutual labels:  quantitative-finance
pomp
R package for statistical inference using partially observed Markov processes
Stars: ✭ 88 (+66.04%)
Mutual labels:  time-series
Human Activity Recognition
A new and computationally cheap method to perform human activity recognition using PoseNet and LSTM. Where we use PoseNet for Preprocessing and LSTM for understand the sequence.
Stars: ✭ 25 (-52.83%)
Mutual labels:  time-series
svg-time-series
SVG time-series charting library
Stars: ✭ 18 (-66.04%)
Mutual labels:  time-series
mongofluxd
Real time sync from MongoDB into InfluxDB
Stars: ✭ 33 (-37.74%)
Mutual labels:  time-series
storage
Multi-Factor Least Squares Monte Carlo energy storage valuation model (Python and .NET).
Stars: ✭ 24 (-54.72%)
Mutual labels:  quantitative-finance
Quant-Finance
Some notebooks with powerful trading strategies.
Stars: ✭ 42 (-20.75%)
Mutual labels:  quantitative-finance
influxdb-ha
High-availability and horizontal scalability for InfluxDB
Stars: ✭ 45 (-15.09%)
Mutual labels:  time-series
modeltime.gluonts
GluonTS Deep Learning with Modeltime
Stars: ✭ 31 (-41.51%)
Mutual labels:  time-series
AltoTrader
Automated crypto currency trading bot
Stars: ✭ 29 (-45.28%)
Mutual labels:  quantitative-finance
sugrrants
SUpporting GRaphics with R for ANalysing Time Series
Stars: ✭ 79 (+49.06%)
Mutual labels:  time-series
imputeFin
Imputation of Financial Time Series with Missing Values and/or Outliers
Stars: ✭ 17 (-67.92%)
Mutual labels:  time-series
ConvLSTM-PyTorch
ConvLSTM/ConvGRU (Encoder-Decoder) with PyTorch on Moving-MNIST
Stars: ✭ 202 (+281.13%)
Mutual labels:  time-series

Support Resistance Line

pypi

Installation

You can install from pypi using pip install support_resistance_line, or install from source using python3 setup.py install

How to Use

One-Liner

SupportResistanceLine(pd.Series(some_data)).plot_both()

example

Runnable Example

import numpy as np
import pandas as pd
from support_resistance_line import SupportResistanceLine


# Generate a random series
sr = pd.Series(np.random.random(size=250))
# ... moving avg to make it more trending
sr = sr.rolling(50).mean().dropna()

# Init. Index will be ignored
srl = SupportResistanceLine(sr, kind='support')

# Plot the best 3 support lines
srl.plot_top_lines()
# Plot the best 3 resistance lines
srl.twin.plot_top_lines()

# Plot the best support & resistance lines
srl.plot_both()

# View the logic steps if you want
srl.plot_steps()

Incentive

支撑线(support line)又称为抵抗线。当股价跌到某个价位附近时,股价停止下跌,甚至有可能还有回升,这是因为多方在此买入造成的。支撑线起阻止股价继续下跌的作用。这个起着阻止股价继续下跌或暂时阻止股价继续下跌的位置就是支撑线所在的位置。

压力线(resistance line)又称为阻力线。当股价上涨到某价位附近时,股价会停止上涨,甚至回落,这是因为空方在此抛出造成的。压力线起阻止股价继续上升的作用。这个起着阻止或暂时阻止股价继续上升的位置就是压力线所在的位置。

因为支撑线压力线的定义不够精确,有较强的主观差异,所以不同的人在同一条时间序列数据上可能会作出完全不同的支撑线压力线。

这里我们采用精确的数学算法来绘制支撑线压力线。

这套算法主要有四个步骤:多项式拟合、寻找极值、聚类分析、图像绘制。

Logic

1.多项式拟合

这里以30分之一序列长度作为窗口的移动平均线作为参考线,从项数取40分之一时间序列长度开始迭代,整体误差在移动平均线的0.6倍以内时停止迭代。

2.遍历多项式曲线取极值

不管画支撑线还是压力线都同时计算极大值和极小值。极值的计算采用一阶导数取零点、二阶导数区分的方式。以支撑线为例,遍历极小值,以任意一个极小值两边的极大值之内的区间,对原序列取最小值,作为支撑点。

3.邻近聚类

对极值聚类,把相距非常近的极值剔除。

4.找线

从最后一个支撑点出发,和其之前的所有支撑点连线。对斜率用Kmeans聚类,每类取最下方一条线,该类点个数为,该类所有点到该直线的平均距离为,该类所有点的横坐标标准差为,平均值为,评分公式为

最终线为所有聚类的线评分最小的。 对序列后四分之一的所有支撑点遍历以上过程,寻找最好的线。

Demo

Demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].