Toymakerftw commited on
Commit
3d1de25
ยท
1 Parent(s): c5a48ec

Ui improvements

Browse files
Files changed (2) hide show
  1. app.py +89 -24
  2. requirements.txt +2 -1
app.py CHANGED
@@ -396,39 +396,104 @@ def analyze_asset_sentiment(asset_input):
396
  None
397
  )
398
 
399
- # Update the Gradio interface (change the output component type)
400
- with gr.Blocks(theme=gr.themes.Default()) as iface:
401
- gr.Markdown("# Advanced Trading Analytics Suite")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
 
403
- with gr.Row():
404
- input_asset = gr.Textbox(
405
- label="Asset Name/Ticker",
406
- placeholder="Enter stock name or symbol...",
407
- max_lines=1
408
- )
409
- analyze_btn = gr.Button("Analyze", variant="primary")
 
 
 
410
 
411
- with gr.Tabs():
412
- with gr.TabItem("Sentiment Analysis"):
413
- gr.Markdown("## News Sentiment Analysis")
414
- articles_output = gr.HTML(label="Analyzed News Articles") # Changed to HTML component
 
 
 
 
415
 
416
- with gr.TabItem("Technical Analysis"):
417
- price_chart = gr.Plot(label="Price Analysis")
418
- ta_json = gr.JSON(label="Technical Indicators")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
- with gr.TabItem("Recommendation"):
421
- recommendation_output = gr.Textbox(
422
- lines=8,
423
- label="Analysis Summary",
424
- interactive=False
425
- )
 
 
 
426
 
427
  analyze_btn.click(
428
  analyze_asset_sentiment,
429
  inputs=[input_asset],
430
- outputs=[articles_output, ta_json, recommendation_output, price_chart]
 
 
 
 
 
431
  )
432
 
 
 
 
 
 
 
 
 
 
433
  logging.info("Launching enhanced Gradio interface")
434
  iface.queue().launch()
 
396
  None
397
  )
398
 
399
+ # Update the Gradio interface with dark theme and improved UI
400
+ custom_theme = gr.themes.Default(
401
+ primary_hue="emerald",
402
+ secondary_hue="emerald",
403
+ neutral_hue="slate",
404
+ font=[gr.themes.GoogleFont("Inter")],
405
+ ).set(
406
+ body_background_fill='*neutral_950',
407
+ button_primary_background_fill='linear-gradient(90deg, #059669 0%, #10b981 100%)',
408
+ button_primary_text_color='white',
409
+ block_background_fill='*neutral_900',
410
+ block_label_text_color='*primary_300',
411
+ block_title_text_color='*primary_300',
412
+ input_background_fill='*neutral_800',
413
+ )
414
+
415
+ with gr.Blocks(theme=custom_theme, css="footer {visibility: hidden}") as iface:
416
+ gr.Markdown("""
417
+ # ๐Ÿ“ˆ Advanced Trading Analytics Suite
418
+ *AI-powered market analysis with real-time sentiment and technical indicators*
419
+ """)
420
 
421
+ with gr.Row(variant="panel"):
422
+ with gr.Column(scale=3):
423
+ input_asset = gr.Textbox(
424
+ label="๐Ÿ” Search Asset",
425
+ placeholder="Enter stock name or symbol (e.g., Apple or AAPL)...",
426
+ max_lines=1,
427
+ container=False
428
+ )
429
+ with gr.Column(scale=1):
430
+ analyze_btn = gr.Button("Analyze Now โ†’", variant="primary", size="lg")
431
 
432
+ with gr.Tabs(selected=0):
433
+ with gr.TabItem("๐Ÿ“ฐ News Sentiment", id=1):
434
+ gr.Markdown("### ๐Ÿ“Š Sentiment Analysis from Latest News")
435
+ with gr.Row():
436
+ sentiment_summary = gr.Label(label="Overall Sentiment",
437
+ value={"Positive": 0, "Neutral": 0, "Negative": 0},
438
+ num_top_classes=3)
439
+ articles_output = gr.HTML(label="Latest News Analysis")
440
 
441
+ with gr.TabItem("๐Ÿ“‰ Technical Analysis", id=2):
442
+ with gr.Row():
443
+ with gr.Column(scale=2):
444
+ gr.Markdown("### Price Chart")
445
+ price_chart = gr.Plot(label="Technical Analysis")
446
+ with gr.Column(scale=1):
447
+ gr.Markdown("### Key Indicators")
448
+ ta_metrics = gr.DataFrame(
449
+ headers=["Indicator", "Value"],
450
+ datatype=["str", "number"],
451
+ interactive=False,
452
+ label="Technical Metrics"
453
+ )
454
+
455
+ with gr.TabItem("๐Ÿ’ก Recommendation", id=3):
456
+ with gr.Row():
457
+ with gr.Column(scale=1):
458
+ gr.Markdown("### Trading Recommendation")
459
+ recommendation_output = gr.Markdown()
460
+ with gr.Column(scale=1):
461
+ gr.Markdown("### Risk Analysis")
462
+ risk_indicators = gr.DataFrame(
463
+ headers=["Risk Factor", "Severity"],
464
+ datatype=["str", "str"],
465
+ interactive=False
466
+ )
467
 
468
+ # Add loading animation
469
+ analyze_btn.click(
470
+ lambda: gr.Loading(loader_args={
471
+ 'text': '๐Ÿ”ฎ Analyzing market data...',
472
+ 'spinner_type': 'dots',
473
+ 'timeout': 10
474
+ }),
475
+ outputs=[]
476
+ )
477
 
478
  analyze_btn.click(
479
  analyze_asset_sentiment,
480
  inputs=[input_asset],
481
+ outputs=[
482
+ articles_output,
483
+ ta_metrics,
484
+ recommendation_output,
485
+ price_chart
486
+ ]
487
  )
488
 
489
+ # Additional callback for sentiment summary
490
+ def update_sentiment_summary(articles):
491
+ sentiments = [a['sentiment']['label'].lower() for a in articles]
492
+ return {
493
+ "Positive": sentiments.count('positive'),
494
+ "Neutral": sentiments.count('neutral'),
495
+ "Negative": sentiments.count('negative')
496
+ }
497
+
498
  logging.info("Launching enhanced Gradio interface")
499
  iface.queue().launch()
requirements.txt CHANGED
@@ -7,4 +7,5 @@ GoogleNews==1.6.14
7
  yfinance
8
  fuzzywuzzy
9
  matplotlib
10
- numpy
 
 
7
  yfinance
8
  fuzzywuzzy
9
  matplotlib
10
+ numpy
11
+ python-Levenshtein