Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,14 @@ import gradio as gr
|
|
| 2 |
import altair as alt
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
-
def create_portfolio_graph():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Data for the bars
|
| 7 |
positions = ['Long', 'Short']
|
| 8 |
-
percentages = [
|
| 9 |
|
| 10 |
data = pd.DataFrame({'Position': positions, 'Percentage': percentages})
|
| 11 |
|
|
@@ -24,9 +28,13 @@ with gr.Blocks() as demo:
|
|
| 24 |
# This is the Current Recommended Portfolio Allocation
|
| 25 |
"""
|
| 26 |
)
|
|
|
|
|
|
|
|
|
|
| 27 |
plot = gr.Plot(label="Portfolio Composition Chart")
|
| 28 |
-
plot.change(create_portfolio_graph, inputs=[], outputs=[plot])
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|
| 32 |
demo.launch()
|
|
@@ -49,3 +57,4 @@ if __name__ == "__main__":
|
|
| 49 |
|
| 50 |
|
| 51 |
|
|
|
|
|
|
| 2 |
import altair as alt
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
+
def create_portfolio_graph(amount):
|
| 6 |
+
# Calculate positions based on the provided amount
|
| 7 |
+
long_position = 0.9 * amount
|
| 8 |
+
short_position = 0.1 * amount
|
| 9 |
+
|
| 10 |
# Data for the bars
|
| 11 |
positions = ['Long', 'Short']
|
| 12 |
+
percentages = [long_position, short_position]
|
| 13 |
|
| 14 |
data = pd.DataFrame({'Position': positions, 'Percentage': percentages})
|
| 15 |
|
|
|
|
| 28 |
# This is the Current Recommended Portfolio Allocation
|
| 29 |
"""
|
| 30 |
)
|
| 31 |
+
total_funds_input = gr.Textbox("Type your total funds", default="100000", numeric=True)
|
| 32 |
+
submit_button = gr.Button("Submit")
|
| 33 |
+
|
| 34 |
plot = gr.Plot(label="Portfolio Composition Chart")
|
| 35 |
+
plot.change(create_portfolio_graph, inputs=[total_funds_input, submit_button], outputs=[plot])
|
| 36 |
+
|
| 37 |
+
demo.load(create_portfolio_graph, inputs=[total_funds_input, submit_button], outputs=[title, plot])
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
demo.launch()
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
+
|