Toymakerftw
commited on
Commit
ยท
be3d7a9
1
Parent(s):
3d1de25
Revert "Ui improvements"
Browse filesThis reverts commit 3d1de250d3917c06a64472d81101a7c1ecbb55ae.
- app.py +24 -89
- requirements.txt +1 -2
app.py
CHANGED
@@ -396,104 +396,39 @@ def analyze_asset_sentiment(asset_input):
|
|
396 |
None
|
397 |
)
|
398 |
|
399 |
-
# Update the Gradio interface
|
400 |
-
|
401 |
-
|
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(
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
)
|
429 |
-
with gr.Column(scale=1):
|
430 |
-
analyze_btn = gr.Button("Analyze Now โ", variant="primary", size="lg")
|
431 |
|
432 |
-
with gr.Tabs(
|
433 |
-
with gr.TabItem("
|
434 |
-
gr.Markdown("
|
435 |
-
|
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("
|
442 |
-
|
443 |
-
|
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 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
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()
|
|
|
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()
|
requirements.txt
CHANGED
@@ -7,5 +7,4 @@ GoogleNews==1.6.14
|
|
7 |
yfinance
|
8 |
fuzzywuzzy
|
9 |
matplotlib
|
10 |
-
numpy
|
11 |
-
python-Levenshtein
|
|
|
7 |
yfinance
|
8 |
fuzzywuzzy
|
9 |
matplotlib
|
10 |
+
numpy
|
|