├── .gitattributes ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── app.py ├── requirements.txt ├── static └── screenshot.png └── templates ├── error.html ├── index.html └── success.html /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # celery beat schedule file 95 | celerybeat-schedule 96 | 97 | # SageMath parsed files 98 | *.sage.py 99 | 100 | # Environments 101 | .env 102 | .venv 103 | env/ 104 | venv/ 105 | ENV/ 106 | env.bak/ 107 | venv.bak/ 108 | 109 | # Spyder project settings 110 | .spyderproject 111 | .spyproject 112 | 113 | # Rope project settings 114 | .ropeproject 115 | 116 | # mkdocs documentation 117 | /site 118 | 119 | # mypy 120 | .mypy_cache/ 121 | .dmypy.json 122 | dmypy.json 123 | 124 | # Pyre type checker 125 | .pyre/ 126 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8-slim 2 | 3 | COPY ./requirements.txt /app/requirements.txt 4 | 5 | WORKDIR /app 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | COPY . /app 10 | 11 | CMD ["gunicorn" , "-b", "0.0.0.0:5000", "app:app"] 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Brian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tradingview-ta-demo 2 | A demo site for the [tradingview-ta](https://github.com/brian-the-dev/python-tradingview-ta) library. 3 | 4 | ## Site 5 | https://tradingview.brianthe.dev 6 | 7 | ## Screenshot 8 | ![](https://raw.githubusercontent.com/brian-the-dev/tradingview-ta-demo/main/static/screenshot.png) 9 | 10 | ## Turnstile 11 | We use Cloudflare's Turnstile to prevent abuse. Get the API key from Cloudflare if you need them. 12 | 13 | ## Contributing 14 | You may fork this repository or submit a pull request. Any pull request (documentation, bug fix, features, etc) are welcomed. Please follow the guidelines [here](https://github.com/brian-the-dev/python-tradingview-ta/blob/master/CONTRIBUTING.md). 15 | 16 | ## License 17 | 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: 18 | 19 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 20 | 21 | 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. 22 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | # tradingview-ta-demo 2 | # Author: deathlyface 3 | from flask import Flask, request, render_template, jsonify 4 | from tradingview_ta import TA_Handler, Interval 5 | from datetime import timezone 6 | import tradingview_ta, requests, os 7 | 8 | app = Flask(__name__) 9 | 10 | # Turnstile keys 11 | turnstile_sitekey = os.environ.get("TURNSTILE_SITEKEY") 12 | turnstile_secret = os.environ.get("TURNSTILE_SECRET") 13 | 14 | @app.route("/", methods=["GET", "POST"]) 15 | def root(): 16 | if request.method == "GET": 17 | return render_template("index.html", version=tradingview_ta.__version__, sitekey=turnstile_sitekey) 18 | elif request.method == "POST": 19 | try: 20 | # Turnstile 21 | turnstile_resp = request.form["cf-turnstile-response"] 22 | validate = requests.post("https://challenges.cloudflare.com/turnstile/v0/siteverify", data={"secret": turnstile_secret, "response": turnstile_resp}) 23 | if validate.json()["success"] == False: 24 | return render_template("error.html", version=tradingview_ta.__version__, error="Error: Invalid Turnstile token", sitekey=turnstile_sitekey) 25 | 26 | # TradingView Technical Analysis 27 | handler = TA_Handler() 28 | handler.set_symbol_as(request.form["symbol"]) 29 | handler.set_exchange_as_crypto_or_stock(request.form["exchange"]) 30 | handler.set_screener_as_stock(request.form["screener"]) 31 | handler.set_interval_as(request.form["interval"]) 32 | analysis = handler.get_analysis() 33 | return render_template("success.html", 34 | version=tradingview_ta.__version__, 35 | symbol=analysis.symbol, 36 | exchange=analysis.exchange, 37 | screener=analysis.screener, 38 | interval=analysis.interval, 39 | time=analysis.time.astimezone(timezone.utc), 40 | summary=analysis.summary, 41 | oscillators=analysis.oscillators, 42 | moving_averages=analysis.moving_averages, 43 | indicators=analysis.indicators, 44 | sitekey=turnstile_sitekey) 45 | except Exception as e: 46 | return render_template("error.html", version=tradingview_ta.__version__, error=e, sitekey=turnstile_sitekey) 47 | 48 | if __name__ == '__main__': 49 | app.run(debug=False, host='0.0.0.0') 50 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | datetime 2 | flask 3 | gunicorn 4 | tradingview-ta==3.2.10 5 | -------------------------------------------------------------------------------- /static/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnalyzerREST/tradingview-ta-demo/d5ea4d50966e3b781d9a582bb09a021eb7c0dea7/static/screenshot.png -------------------------------------------------------------------------------- /templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TradingView-TA Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

TradingView-TA Demo

15 |

Try the tradingview-ta library on this Flask site!

16 |

Running tradingview-ta v{{ version }}.

17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 35 |
36 | 37 |
38 |
39 |

Error

40 |

{{ error }}

41 |

Please report this error on GitHub: brian-the-dev/tradingview-ta-demo and attach the screenshot of the form.

42 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TradingView-TA Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

TradingView-TA Demo

15 |

Try the tradingview-ta library on this Flask site!

16 |

Running tradingview-ta v{{ version }}.

17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 35 |
36 | 37 | 38 |
39 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /templates/success.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TradingView-TA Demo 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

TradingView-TA Demo

15 |

Try the tradingview-ta library on this Flask site!

16 |

Running tradingview-ta v{{ version }}.

17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 35 |
36 | 37 |
38 |
39 |

Result

40 |

Compare with data from TradingView: {{ symbol }}

41 |

Details

42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Symbol analysis.symbol{{ symbol }}
Exchange analysis.exchange{{ exchange }}
Screener analysis.screener{{ screener }}
Interval analysis.interval{{ interval }}
Time analysis.time{{ time }}
64 |

Summary analysis.summary

65 | 66 | {% for key, value in summary.items() %} 67 | 68 | 69 | 70 | 71 | {% endfor %} 72 |
{{ key }} {{ value }}
73 |

Oscillators analysis.oscillators

74 | 75 | {% for key, value in oscillators.items() %} 76 | {% if key != "COMPUTE": %} 77 | 78 | 79 | 80 | 81 | {% else %} 82 | 83 | 84 | 85 | 86 | 87 | {% for key, val in value.items() %} 88 | 89 | 90 | 91 | 92 | 93 | {% endfor %} 94 | {% endif %} 95 | {% endfor %} 96 |
{{ key }} {{ value }}
COMPUTE INDICATOR RECOMMENDATION
{{ key if key != "COMPUTE" }} {{ val if key != "COMPUTE" }}
97 |

Moving Averages analysis.moving_averages

98 | 99 | {% for key, value in moving_averages.items() %} 100 | {% if key != "COMPUTE": %} 101 | 102 | 103 | 104 | 105 | {% else %} 106 | 107 | 108 | 109 | 110 | 111 | {% for key, val in value.items() %} 112 | 113 | 114 | 115 | 116 | 117 | {% endfor %} 118 | {% endif %} 119 | {% endfor %} 120 |
{{ key }} {{ value }}
COMPUTE INDICATOR RECOMMENDATION
{{ key if key != "COMPUTE" }} {{ val if key != "COMPUTE" }}
121 |

Indicators analysis.indicators

122 | 123 | {% for key, value in indicators.items() %} 124 | 125 | 126 | 127 | 128 | {% endfor %} 129 |
{{ key }} {{ value }}
130 | 131 | 134 | 135 | 136 | 137 | --------------------------------------------------------------------------------