0%

DevRecord-TradingView技术分析指标API

介绍:

Technical Ratings是一种技术分析工具,它结合了几种技术指标的评级,使交易者和投资者更容易找到有利可图的交易。
URL:https://www.tradingview.com/symbols/BTCUSDT/technicals/

20221213162900
20221213162917
通过几个技术指标,来分析出买卖信号,具体的计算方法可见网页
大致有以下指标:

  • MACD

  • RSI

  • 移动平均线

  • 布林带

  • 等等

相关github仓库:

python版本:

仓库地址:python-tradingview-ta
演示界面:TradingView-TA Demo

20221213163254
示例代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from tradingview_ta import TA_Handler, Interval, Exchange

tesla = TA_Handler(
symbol="BTCUSDT",
screener="CRYPTO",
exchange="BINANCE",
interval=Interval.INTERVAL_1_HOUR,
# proxies={'http': 'http://example.com:8080'} # Uncomment to enable proxy (replace the URL).
)
print(tesla.get_analysis().summary)

# Example output: {"RECOMMENDATION": "BUY", "BUY": 8, "NEUTRAL": 6, "SELL": 3}

res = tesla.get_indicators()
print(res)

输出的结果:

1
2
{'RECOMMENDATION': 'BUY', 'BUY': 10, 'SELL': 6, 'NEUTRAL': 10}
{'Recommend.Other': 0, 'Recommend.All': 0.13333333, 'Recommend.MA': 0.26666667, 'RSI': 50.48192749, 'RSI[1]': 58.39674711, 'Stoch.K': 61.87618536, 'Stoch.D': 68.87650451, 'Stoch.K[1]': 72.05141966, 'Stoch.D[1]': 71.27973346, 'CCI20': 16.16247248, 'CCI20[1]': 65.48078005, 'ADX': 28.61095394, 'ADX+DI': 25.27158154, 'ADX-DI': 20.48667952, 'ADX+DI[1]': 27.92566556, 'ADX-DI[1]': 14.19797254, 'AO': 114.26505882, 'AO[1]': 118.24585294, 'Mom': -72.33, 'Mom[1]': 28.37, 'MACD.macd': 31.12953057, 'MACD.signal': 27.97914839, 'Rec.Stoch.RSI': 0, 'Stoch.RSI.K': 38.74649592, 'Rec.WR': 0, 'W.R': -58.48706151, 'Rec.BBPower': 0, 'BBPower': -20.57747939, 'Rec.UO': 0, 'UO': 47.95794838, 'close': 17103.34, 'EMA5': 17142.2328455, 'SMA5': 17152.532, 'EMA10': 17138.1040694, 'SMA10': 17158.701, 'EMA20': 17110.96833468, 'SMA20': 17096.297, 'EMA30': 17097.41772984, 'SMA30': 17045.36033333, 'EMA50': 17091.82731247, 'SMA50': 17080.842, 'EMA100': 17085.73943901, 'SMA100': 17123.7011, 'EMA200': 17045.31878646, 'SMA200': 17065.14255, 'Rec.Ichimoku': 0, 'Ichimoku.BLine': 17072.69, 'Rec.VWMA': 1, 'VWMA': 17091.35386908, 'Rec.HullMA9': -1, 'HullMA9': 17150.65207407, 'Pivot.M.Classic.S3': 15571.87, 'Pivot.M.Classic.S2': 16317.29, 'Pivot.M.Classic.S1': 16701.17, 'Pivot.M.Classic.Middle': 17062.71, 'Pivot.M.Classic.R1': 17446.59, 'Pivot.M.Classic.R2': 17808.13, 'Pivot.M.Classic.R3': 18553.55, 'Pivot.M.Fibonacci.S3': 16317.29, 'Pivot.M.Fibonacci.S2': 16602.04044, 'Pivot.M.Fibonacci.S1': 16777.95956, 'Pivot.M.Fibonacci.Middle': 17062.71, 'Pivot.M.Fibonacci.R1': 17347.46044, 'Pivot.M.Fibonacci.R2': 17523.37956, 'Pivot.M.Fibonacci.R3': 17808.13, 'Pivot.M.Camarilla.S3': 16880.0595, 'Pivot.M.Camarilla.S2': 16948.38966667, 'Pivot.M.Camarilla.S1': 17016.71983333, 'Pivot.M.Camarilla.Middle': 17062.71, 'Pivot.M.Camarilla.R1': 17153.38016667, 'Pivot.M.Camarilla.R2': 17221.71033333, 'Pivot.M.Camarilla.R3': 17290.0405, 'Pivot.M.Woodie.S3': 15966.92, 'Pivot.M.Woodie.S2': 16322.875, 'Pivot.M.Woodie.S1': 16712.34, 'Pivot.M.Woodie.Middle': 17068.295, 'Pivot.M.Woodie.R1': 17457.76, 'Pivot.M.Woodie.R2': 17813.715, 'Pivot.M.Woodie.R3': 18203.18, 'Pivot.M.Demark.S1': 16509.23, 'Pivot.M.Demark.Middle': 16966.74, 'Pivot.M.Demark.R1': 17254.65, 'open': 17151.56, 'P.SAR': 17241.89, 'BB.lower': 16938.43248872, 'BB.upper': 17254.16151128, 'AO[2]': 115.21276471, 'volume': 7491.87152, 'change': -0.28114061, 'low': 17083.08, 'high': 17155.15}

go版本:

仓库地址:go-tvscanner
参考该仓库,知道怎么构造出post的数据包:

1
{"symbols":{"tickers":["BINANCE:BTCUSDT"],"query":{"types":[]}},"columns":["Recommend.Other|120","Recommend.All|120","Recommend.MA|120","RSI|120","RSI[1]|120","Stoch.K|120","Stoch.D|120","Stoch.K[1]|120","Stoch.D[1]|120","CCI20|120","CCI20[1]|120","ADX|120","ADX+DI|120","ADX-DI|120","ADX+DI[1]|120","ADX-DI[1]|120","AO|120","AO[1]|120","AO[2]|120","Mom|120","Mom[1]|120","MACD.macd|120","MACD.signal|120","Rec.Stoch.RSI|120","Stoch.RSI.K|120","Rec.WR|120","W.R|120","Rec.BBPower|120","BBPower|120","Rec.UO|120","UO|120","EMA10|120","close|120","SMA10|120","EMA20|120","SMA20|120","EMA30|120","SMA30|120","EMA50|120","SMA50|120","EMA100|120","SMA100|120","EMA200|120","SMA200|120","Rec.Ichimoku|120","Ichimoku.BLine|120","Rec.VWMA|120","VWMA|120","Rec.HullMA9|120","HullMA9|120","Pivot.M.Classic.S3|120","Pivot.M.Classic.S2|120","Pivot.M.Classic.S1|120","Pivot.M.Classic.Middle|120","Pivot.M.Classic.R1|120","Pivot.M.Classic.R2|120","Pivot.M.Classic.R3|120","Pivot.M.Fibonacci.S3|120","Pivot.M.Fibonacci.S2|120","Pivot.M.Fibonacci.S1|120","Pivot.M.Fibonacci.Middle|120","Pivot.M.Fibonacci.R1|120","Pivot.M.Fibonacci.R2|120","Pivot.M.Fibonacci.R3|120","Pivot.M.Camarilla.S3|120","Pivot.M.Camarilla.S2|120","Pivot.M.Camarilla.S1|120","Pivot.M.Camarilla.Middle|120","Pivot.M.Camarilla.R1|120","Pivot.M.Camarilla.R2|120","Pivot.M.Camarilla.R3|120","Pivot.M.Woodie.S3|120","Pivot.M.Woodie.S2|120","Pivot.M.Woodie.S1|120","Pivot.M.Woodie.Middle|120","Pivot.M.Woodie.R1|120","Pivot.M.Woodie.R2|120","Pivot.M.Woodie.R3|120","Pivot.M.Demark.S1|120","Pivot.M.Demark.Middle|120","Pivot.M.Demark.R1|120"]}

API返回的结果

1
{TotalCount:1 Data:[{S:BINANCE:BTCUSDT D:[0 0.46666667 0.93333333 63.51210379 59.16581691 69.6146242 68.77283822 66.12746449 69.58510338 74.54963546 57.42929389 26.81879053 26.58069963 17.69170375 24.38588284 19.30006705 120.68555882 118.20594118 -16.13 2.18 36.17025233 31.34725473 0 35.82221959 0 -24.16629056 0 77.60112301 0 55.57177607 17193.7 17172.53237578 17171.406 17159.0189826 17163.489 17127.90662836 17120.4805 17110.9071456 17065.16733333 17100.63520803 17082.0938 17090.49811186 17123.4215 17048.52958648 17064.7978 0 17072.69 1 17123.32935619 1 17171.53274074 17160.14 17235.4847 16981.06765146 17259.89334854 116.08352941 4857.7718 0.19545272 17155.5 17219.79]}]} 

结合python版本的代码,帮助我们格式化返回的结果。最终可以获取到我想要的数据,布林带的上下界

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package main

import (
"fmt"
"github.com/jerrychan807/go-indicator/lib"
)

func main() {
fmt.Println("Starting")

jsonRes := lib.GetTradingViewResponse("crypto", "BINANCE", "BTCUSDT", "1h")
analysisData := lib.ParseJsonData(jsonRes)
fmt.Println("analysisData: ", analysisData.BBupper)
}

输出结果:

1
2
3
4
5
Starting
[*] response received 200
[*] Api Json Data After handled: {TotalCount:1 Data:[{S:BINANCE:BTCUSDT D:[0.09090909 0.51212121 0.93333333 75.13228221 79.06565064 75.35647864 71.29840367 72.41126789 69.70505278 247.61844762 223.43410325 31.2990747 41.11855836 11.56486817 46.14259608 12.97791221 180.26205882 144.58582353 242.02 217.99 67.76216208 41.61843449 0 68.96940857 0 -23.55070738 0 407.69688095 0 60.72962433 17401.12 17300.75491719 17261.166 17237.86511799 17211.103 17174.10055491 17151.328 17143.76058678 17088.59366667 17121.24005569 17091.2652 17101.19327718 17127.5939 17054.34432142 17066.7484 0 17210.305 1 17169.71417103 1 17341.78392593 17427.82 17088.5372 16934.27480361 17368.38119639 118.20594118 8550.17222 -0.15320333 17357.74 17477.06]}]}
BBupper: 17368.38119639
BBlower: 16934.27480361