Add tradingview command to ta controller (#1320)

* add tradingview command to ta controller

* typo

* fix tests

* hugo docs

* Update _index.md
This commit is contained in:
didierlopes.eth
2022-02-06 17:51:42 +00:00
committed by GitHub
parent b939fbd9b8
commit b425f14cdf
6 changed files with 56 additions and 27 deletions

View File

@@ -6,6 +6,7 @@ import argparse
from typing import List
from datetime import datetime
import webbrowser
import pandas as pd
from prompt_toolkit.completion import NestedCompleter
from gamestonk_terminal.rich_config import console
@@ -70,6 +71,7 @@ class TechnicalAnalysisController(StockBaseController):
"adosc",
"obv",
"fib",
"tv",
]
PATH = "/stocks/ta/"
@@ -111,6 +113,7 @@ class TechnicalAnalysisController(StockBaseController):
help_text = f"""
[param]Stock: [/param]{stock_str}[cmds]
tv open interactive chart on [src][TradingView][/src]
view view historical data and trendlines [src][Finviz][/src]
summary technical summary report [src][FinBrain][/src]
recom recommendation based on Technical Indicators [src][Tradingview][/src]
@@ -153,6 +156,19 @@ class TechnicalAnalysisController(StockBaseController):
# SPECIFIC
def call_tv(self, other_args):
"""Process tv command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="tv",
description="""View TradingView for technical analysis. [Source: TradingView]""",
)
ns_parser = parse_known_args_and_warn(parser, other_args)
if ns_parser:
webbrowser.open(f"https://www.tradingview.com/chart/?symbol={self.ticker}")
console.print("")
def call_view(self, other_args: List[str]):
"""Process view command"""
parser = argparse.ArgumentParser(

View File

@@ -8,17 +8,14 @@ interactions:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/39.0.2171.95 Safari/537.36
method: GET
uri: https://query2.finance.yahoo.com/v8/finance/chart/TSLA?period1=MOCK_PERIOD_1&period2=MOCK_PERIOD_2&interval=1d&includePrePost=False&events=div%2Csplits
uri: https://query2.finance.yahoo.com/v8/finance/chart/TSLA?events=div%2Csplits&includePrePost=False&interval=1d&period1=MOCK_PERIOD_1&period2=MOCK_PERIOD_2
response:
body:
string: '{"chart":{"result":[{"meta":{"currency":"USD","symbol":"TSLA","exchangeName":"NMS","instrumentType":"EQUITY","firstTradeDate":1277818200,"regularMarketTime":1641330002,"gmtoffset":-18000,"timezone":"EST","exchangeTimezoneName":"America/New_York","regularMarketPrice":1149.59,"chartPreviousClose":926.92,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"EST","start":1641373200,"end":1641393000,"gmtoffset":-18000},"regular":{"timezone":"EST","start":1641393000,"end":1641416400,"gmtoffset":-18000},"post":{"timezone":"EST","start":1641416400,"end":1641430800,"gmtoffset":-18000}},"dataGranularity":"1d","range":"","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1639665000,1639751400],"indicators":{"quote":[{"volume":[27590500,33479100],"open":[994.5,914.77001953125],"close":[926.9199829101562,932.5700073242188],"high":[994.97998046875,960.6599731445312],"low":[921.8499755859375,909.0399780273438]}],"adjclose":[{"adjclose":[926.9199829101562,932.5700073242188]}]}}],"error":null}}'
string: '{"chart":{"result":[{"meta":{"currency":"USD","symbol":"TSLA","exchangeName":"NMS","instrumentType":"EQUITY","firstTradeDate":1277818200,"regularMarketTime":1644008403,"gmtoffset":-18000,"timezone":"EST","exchangeTimezoneName":"America/New_York","regularMarketPrice":923.32,"chartPreviousClose":926.92,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"EST","start":1643965200,"end":1643985000,"gmtoffset":-18000},"regular":{"timezone":"EST","start":1643985000,"end":1644008400,"gmtoffset":-18000},"post":{"timezone":"EST","start":1644008400,"end":1644022800,"gmtoffset":-18000}},"dataGranularity":"1d","range":"","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1639751400],"indicators":{"quote":[{"volume":[33479100],"open":[914.77001953125],"high":[960.6599731445312],"close":[932.5700073242188],"low":[909.0399780273438]}],"adjclose":[{"adjclose":[932.5700073242188]}]}}],"error":null}}'
headers:
Age:
- '2'
- '0'
Connection:
- keep-alive
Expect-CT:
@@ -36,11 +33,11 @@ interactions:
cache-control:
- public, max-age=10, stale-while-revalidate=20
content-length:
- '1035'
- '938'
content-type:
- application/json;charset=utf-8
date:
- Wed, 05 Jan 2022 11:45:24 GMT
- Sun, 06 Feb 2022 13:08:41 GMT
server:
- ATS
vary:
@@ -48,13 +45,13 @@ interactions:
x-envoy-decorator-operation:
- finance-chart-api--mtls-production-ir2.finance-k8s.svc.yahoo.local:4080/*
x-envoy-upstream-service-time:
- '3'
- '4'
x-request-id:
- ccc14cc5-af7c-40ac-ac28-44d081fd5beb
- a8fe001d-dad7-42f8-a3f8-0ca33a24fe5b
x-yahoo-request-id:
- 0gsv07dgtb16k
- 57tiq71gvvi2p
y-rid:
- 0gsv07dgtb16k
- 57tiq71gvvi2p
status:
code: 200
message: OK

View File

@@ -1,6 +1,7 @@
Stock: Intraday MOCK_INTERVAL MOCK_TICKER
tv open interactive chart on [TradingView]
view view historical data and trendlines [Finviz]
summary technical summary report [FinBrain]
recom recommendation based on Technical Indicators [Tradingview]

View File

@@ -1,6 +1,7 @@
Stock: Intraday MOCK_INTERVAL MOCK_TICKER (from 2021-12-01)
tv open interactive chart on [TradingView]
view view historical data and trendlines [Finviz]
summary technical summary report [FinBrain]
recom recommendation based on Technical Indicators [Tradingview]

View File

@@ -0,0 +1,12 @@
```
usage: tv [-h]
```
View TradingView for technical analysis. [Source: TradingView]
```
optional arguments:
-h, --help show this help message (default: False)
```
<img width="1792" alt="Screenshot 2022-02-06 at 17 14 16" src="https://user-images.githubusercontent.com/25267873/152692456-2bce6945-85db-411e-8371-6af0e6c03906.png">

View File

@@ -459,6 +459,8 @@ main:
sub:
- name: view
ref: "/common/technical_analysis/view"
- name: tv
ref: "/common/technical_analysis/tv"
- name: summary
ref: "/common/technical_analysis/summary"
- name: recom
@@ -1239,18 +1241,18 @@ main:
- name: jupyter
ref: "/jupyter"
sub:
- name: "dashboards"
ref: "/jupyter/dashboards"
sub:
- name: "stocks"
ref: "/jupyter/dashboards/stocks"
- name: "correlation"
ref: "/jupyter/dashboards/correlations"
- name: "vsurf"
ref: "/jupyter/dashboards/vsurf"
- name: "chains"
ref: "/jupyter/dashboards/chains"
- name: "shortdata"
ref: "jupyter/dashboards/shortdata"
- name: "reports"
ref: "/jupyter/reports"
- name: "dashboards"
ref: "/jupyter/dashboards"
sub:
- name: "stocks"
ref: "/jupyter/dashboards/stocks"
- name: "correlation"
ref: "/jupyter/dashboards/correlations"
- name: "vsurf"
ref: "/jupyter/dashboards/vsurf"
- name: "chains"
ref: "/jupyter/dashboards/chains"
- name: "shortdata"
ref: "jupyter/dashboards/shortdata"
- name: "reports"
ref: "/jupyter/reports"