a-ge commited on
Commit
95f9276
·
verified ·
1 Parent(s): 0e2a3ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -15
app.py CHANGED
@@ -9,24 +9,29 @@ qs.extend_pandas()
9
 
10
 
11
  def get_technical_analysis(
12
- symbol: str, exchange: str, screener: str, interval: str
13
  ) -> dict[str:any]:
14
  """Get the technical analysis for the given symbol.
15
 
16
  Args:
17
- symbol(str): Ticker symbol which is to be analyzed (e.g., "AAPL","MSFT","VOD").
18
- exchange(str): Exchange at which the tikcer is traded (e.g., "NASDAQ", "NSE", "LSE").
19
- screener(str): The exchange's country as the screener (e.g., "america", "india", "uk").The possible values are listed in the config.py file
20
- interval(str): The time interval for the analysis (e.g., "1d", "1h", "15m").The possible values are listed in the config.py file
21
 
22
  Returns:
23
  dict: Technical analysis for the symbol/ticker for the given period. Returns a dict containing the analysis.
24
  """
 
25
  try:
26
- screener = list(SCREENER.keys())[screener]
 
 
 
 
27
  handler = TA_Handler(
28
  symbol=symbol,
29
- screener=screener,
30
  exchange=exchange,
31
  interval=interval,
32
  )
@@ -92,24 +97,24 @@ def get_comparison_report(symbol: str, benchmark: str):
92
  with gr.Blocks() as demo:
93
  gr.Markdown("# Stock-lens🔎")
94
  gr.Markdown(
95
- "Get Analyst ratings and technical indicator details📈. Get Comparison of your favourite stocks🏆"
96
  )
97
 
98
  with gr.Tab("Technical Analysis"):
99
 
100
  gr.Markdown("# Analyst Ratings and Technical Indicators")
101
  gr.Markdown(
102
- "Enter a stock symbol,exchange,screener and interval to see the tecnical indicator details."
103
  )
104
  symbol_input = gr.Textbox(
105
- label="Ticker/Symbol (e.g., AAPL,MSFT,GOOGL)",
106
- info ="No need for the exchange suffix as exchange is already another input"
107
  )
108
- exchange_input = gr.Textbox(label="Exchange (e.g., NASDAQ, NSE, LSE)")
109
- screener_input = gr.Dropdown(
110
  choices=SCREENER.values(),
111
- label="Screener (for stocks, enter the exchange's country as the screener)",
112
  type="index",
 
113
  )
114
  interval_input = gr.Dropdown(interval_options, label="Select Interval:")
115
  submit_button = gr.Button("Generate Analysis", variant="primary")
@@ -117,7 +122,7 @@ with gr.Blocks() as demo:
117
 
118
  submit_button.click(
119
  fn=get_technical_analysis,
120
- inputs=[symbol_input, exchange_input, screener_input, interval_input],
121
  outputs=output_json,
122
  )
123
 
 
9
 
10
 
11
  def get_technical_analysis(
12
+ symbol: str, exchange: str, country: str, interval: str
13
  ) -> dict[str:any]:
14
  """Get the technical analysis for the given symbol.
15
 
16
  Args:
17
+ symbol(str):Required: Ticker symbol which is to be analyzed (e.g., "AAPL","MSFT","VOD").
18
+ exchange(str):Required: Exchange at which the tikcer is traded (e.g., "NASDAQ", "NSE", "LSE").
19
+ country(str):Required: The exchange's country (e.g., "america", "india", "uk").The possible values are listed in the config.py file
20
+ interval(str):Required: The time interval for the analysis (e.g., "1d", "1h", "15m").The possible values are listed in the config.py file
21
 
22
  Returns:
23
  dict: Technical analysis for the symbol/ticker for the given period. Returns a dict containing the analysis.
24
  """
25
+
26
  try:
27
+ symbol = symbol.split(".")[0]
28
+ country = list(SCREENER.keys())[country]
29
+ if country == None or country == "None":
30
+ raise ValueError("Country is required!")
31
+
32
  handler = TA_Handler(
33
  symbol=symbol,
34
+ screener=country,
35
  exchange=exchange,
36
  interval=interval,
37
  )
 
97
  with gr.Blocks() as demo:
98
  gr.Markdown("# Stock-lens🔎")
99
  gr.Markdown(
100
+ "Get Analyst ratings and technical indicator details📈. Get Comparison of your favourite stocks 🏆"
101
  )
102
 
103
  with gr.Tab("Technical Analysis"):
104
 
105
  gr.Markdown("# Analyst Ratings and Technical Indicators")
106
  gr.Markdown(
107
+ "Enter a stock symbol,exchange,country and interval to see the tecnical indicator details."
108
  )
109
  symbol_input = gr.Textbox(
110
+ label="Ticker/Symbol* (e.g., AAPL,MSFT,GOOGL)",
 
111
  )
112
+ exchange_input = gr.Textbox(label="Exchange* (e.g., NASDAQ, NSE, LSE)")
113
+ country_input = gr.Dropdown(
114
  choices=SCREENER.values(),
115
+ label="Country* (e.g.,United States,India)",
116
  type="index",
117
+ value=None,
118
  )
119
  interval_input = gr.Dropdown(interval_options, label="Select Interval:")
120
  submit_button = gr.Button("Generate Analysis", variant="primary")
 
122
 
123
  submit_button.click(
124
  fn=get_technical_analysis,
125
+ inputs=[symbol_input, exchange_input, country_input, interval_input],
126
  outputs=output_json,
127
  )
128