Method314 commited on
Commit
54f50bd
·
verified ·
1 Parent(s): df42e91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -3
app.py CHANGED
@@ -1,10 +1,63 @@
1
  import gradio as gr
 
 
 
2
  import yfinance as yf
3
  import numpy as np
4
  import pandas as pd
5
  import plotly.graph_objects as go
6
  from datetime import datetime
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def download_stock_data(ticker, start_date, end_date):
9
  stock = yf.Ticker(ticker)
10
  df = stock.history(start=start_date, end=end_date)
@@ -58,7 +111,7 @@ def plot_interactive_logarithmic_stock_chart(ticker, start_date, end_date):
58
  hovermode='x unified',
59
  plot_bgcolor='#F5F9F8',
60
  paper_bgcolor='#F5F9F8',
61
- font=dict(family="Inter, sans-serif", size=12, color="#313D38")
62
  )
63
 
64
  fig.update_xaxes(
@@ -81,8 +134,8 @@ def plot_interactive_logarithmic_stock_chart(ticker, start_date, end_date):
81
  # Get the current date
82
  current_date = datetime.now().strftime("%Y-%m-%d")
83
 
84
- # Create Gradio interface with seafoam theme
85
- with gr.Blocks(theme=gr.themes.Seafoam(), title="Stock Log Charts") as iface:
86
  gr.Markdown("# Stock Log Charts")
87
  gr.Markdown("Enter a stock ticker and date range to generate a logarithmic chart.")
88
 
 
1
  import gradio as gr
2
+ from gradio.themes import Base
3
+ from gradio.themes.utils import colors, sizes, fonts
4
+ from typing import Iterable
5
  import yfinance as yf
6
  import numpy as np
7
  import pandas as pd
8
  import plotly.graph_objects as go
9
  from datetime import datetime
10
 
11
+ # Custom Seafoam theme definition
12
+ class Seafoam(Base):
13
+ def __init__(
14
+ self,
15
+ *,
16
+ primary_hue: colors.Color | str = colors.emerald,
17
+ secondary_hue: colors.Color | str = colors.blue,
18
+ neutral_hue: colors.Color | str = colors.blue,
19
+ spacing_size: sizes.Size | str = sizes.spacing_md,
20
+ radius_size: sizes.Size | str = sizes.radius_md,
21
+ text_size: sizes.Size | str = sizes.text_lg,
22
+ font: fonts.Font | str | Iterable[fonts.Font | str] = (
23
+ fonts.GoogleFont("Quicksand"),
24
+ "ui-sans-serif",
25
+ "sans-serif",
26
+ ),
27
+ font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
28
+ fonts.GoogleFont("IBM Plex Mono"),
29
+ "ui-monospace",
30
+ "monospace",
31
+ ),
32
+ ):
33
+ super().__init__(
34
+ primary_hue=primary_hue,
35
+ secondary_hue=secondary_hue,
36
+ neutral_hue=neutral_hue,
37
+ spacing_size=spacing_size,
38
+ radius_size=radius_size,
39
+ text_size=text_size,
40
+ font=font,
41
+ font_mono=font_mono,
42
+ )
43
+ super().set(
44
+ body_background_fill="linear-gradient(to bottom right, *primary_50, *primary_100, *primary_200)",
45
+ body_background_fill_dark="linear-gradient(to bottom right, *primary_900, *primary_800, *primary_700)",
46
+ button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
47
+ button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
48
+ button_primary_text_color="white",
49
+ button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
50
+ slider_color="*secondary_300",
51
+ slider_color_dark="*secondary_600",
52
+ block_title_text_weight="600",
53
+ block_border_width="3px",
54
+ block_shadow="*shadow_drop_lg",
55
+ button_shadow="*shadow_drop_lg",
56
+ button_large_padding="32px",
57
+ )
58
+
59
+ seafoam = Seafoam()
60
+
61
  def download_stock_data(ticker, start_date, end_date):
62
  stock = yf.Ticker(ticker)
63
  df = stock.history(start=start_date, end=end_date)
 
111
  hovermode='x unified',
112
  plot_bgcolor='#F5F9F8',
113
  paper_bgcolor='#F5F9F8',
114
+ font=dict(family="Quicksand, sans-serif", size=12, color="#313D38")
115
  )
116
 
117
  fig.update_xaxes(
 
134
  # Get the current date
135
  current_date = datetime.now().strftime("%Y-%m-%d")
136
 
137
+ # Create Gradio interface with custom Seafoam theme
138
+ with gr.Blocks(theme=seafoam, title="Stock Log Charts") as iface:
139
  gr.Markdown("# Stock Log Charts")
140
  gr.Markdown("Enter a stock ticker and date range to generate a logarithmic chart.")
141