-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (36 loc) · 1.5 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask
from flask_restful import Api, Resource
from tradingview_ta import TA_Handler, Interval, Exchange
app = Flask(__name__)
api = Api(app)
class TradingView(Resource):
def get(self,symbol,screener,exchange,timeinterval):
if (timeinterval == '1m'):
time_frame = Interval.INTERVAL_1_MINUTE
elif (timeinterval == '5m'):
time_frame = Interval.INTERVAL_5_MINUTES
elif (timeinterval == '15m'):
time_frame = Interval.INTERVAL_15_MINUTES
elif (timeinterval == '30m'):
time_frame = Interval.INTERVAL_30_MINUTES
elif (timeinterval == '1h'):
time_frame = Interval.INTERVAL_1_HOUR
elif (timeinterval == '2h'):
time_frame = Interval.INTERVAL_2_HOUR
elif (timeinterval == '4h'):
time_frame = Interval.INTERVAL_4_HOURS
elif (timeinterval == '1d'):
time_frame = Interval.INTERVAL_1_DAY
elif (timeinterval == '1w'):
time_frame = Interval.INTERVAL_1_WEEK
elif (timeinterval == '1month'):
time_frame = Interval.INTERVAL_1_MONTH
data = TA_Handler(
symbol=symbol,
screener=screener,
exchange=exchange,
interval=time_frame)
return data.get_analysis().summary
api.add_resource(TradingView, "/<string:symbol>/<string:screener>/<string:exchange>/<string:timeinterval>")
if __name__ == "__main__":
app.run(debug=False)