rosacastillo
commited on
Commit
·
18afe53
1
Parent(s):
6e7e273
fixing ui plot issue and adding new tool
Browse files- app.py +11 -17
- scripts/utils.py +1 -0
- tabs/metrics.py +5 -4
app.py
CHANGED
@@ -50,7 +50,7 @@ from tabs.error import (
|
|
50 |
plot_tool_error_data_by_market,
|
51 |
)
|
52 |
from tabs.about import about_olas_predict, about_this_dashboard
|
53 |
-
|
54 |
from scripts.utils import INC_TOOLS
|
55 |
|
56 |
|
@@ -207,6 +207,14 @@ with demo:
|
|
207 |
trades_df=trades_df
|
208 |
)
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
with gr.Row():
|
211 |
gr.Markdown("# ⚖️ Trading metrics")
|
212 |
with gr.Row():
|
@@ -225,25 +233,11 @@ with demo:
|
|
225 |
with gr.Column(scale=1):
|
226 |
trade_details_text = get_trade_metrics_text()
|
227 |
|
228 |
-
def update_trade_details(trade_detail):
|
229 |
-
return plot_trade_metrics(
|
230 |
-
metric_name=trade_detail,
|
231 |
-
trades_df=trades_df,
|
232 |
-
)
|
233 |
-
|
234 |
trade_details_selector.change(
|
235 |
update_trade_details,
|
236 |
-
inputs=trade_details_selector,
|
237 |
-
outputs=trade_details_plot,
|
238 |
)
|
239 |
-
|
240 |
-
with gr.Row():
|
241 |
-
trade_details_selector
|
242 |
-
with gr.Row():
|
243 |
-
with gr.Column(scale=3):
|
244 |
-
trade_details_plot
|
245 |
-
with gr.Column(scale=1):
|
246 |
-
trade_details_text
|
247 |
with gr.TabItem("🔒 Staking traders"):
|
248 |
with gr.Row():
|
249 |
gr.Markdown("# Trades conducted at the Pearl markets")
|
|
|
50 |
plot_tool_error_data_by_market,
|
51 |
)
|
52 |
from tabs.about import about_olas_predict, about_this_dashboard
|
53 |
+
import matplotlib.pyplot as plt
|
54 |
from scripts.utils import INC_TOOLS
|
55 |
|
56 |
|
|
|
207 |
trades_df=trades_df
|
208 |
)
|
209 |
|
210 |
+
def update_trade_details(trade_detail, trade_details_plot):
|
211 |
+
print(f"user selected option= {trade_detail}")
|
212 |
+
new_plot = plot_trade_metrics(
|
213 |
+
metric_name=trade_detail,
|
214 |
+
trades_df=trades_df,
|
215 |
+
)
|
216 |
+
return new_plot
|
217 |
+
|
218 |
with gr.Row():
|
219 |
gr.Markdown("# ⚖️ Trading metrics")
|
220 |
with gr.Row():
|
|
|
233 |
with gr.Column(scale=1):
|
234 |
trade_details_text = get_trade_metrics_text()
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
trade_details_selector.change(
|
237 |
update_trade_details,
|
238 |
+
inputs=[trade_details_selector, trade_details_plot],
|
239 |
+
outputs=[trade_details_plot],
|
240 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
with gr.TabItem("🔒 Staking traders"):
|
242 |
with gr.Row():
|
243 |
gr.Markdown("# Trades conducted at the Pearl markets")
|
scripts/utils.py
CHANGED
@@ -45,6 +45,7 @@ INC_TOOLS = [
|
|
45 |
"prediction-url-cot-claude",
|
46 |
"prediction-request-rag-claude",
|
47 |
"prediction-request-reasoning-claude",
|
|
|
48 |
]
|
49 |
|
50 |
SUBGRAPH_API_KEY = os.environ.get("SUBGRAPH_API_KEY", None)
|
|
|
45 |
"prediction-url-cot-claude",
|
46 |
"prediction-request-rag-claude",
|
47 |
"prediction-request-reasoning-claude",
|
48 |
+
"superforcaster",
|
49 |
]
|
50 |
|
51 |
SUBGRAPH_API_KEY = os.environ.get("SUBGRAPH_API_KEY", None)
|
tabs/metrics.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
3 |
import plotly.express as px
|
|
|
|
|
4 |
|
5 |
trade_metric_choices = [
|
6 |
"mech calls",
|
@@ -59,13 +61,11 @@ def get_metrics(
|
|
59 |
|
60 |
|
61 |
def get_boxplot_metrics(column_name: str, trades_df: pd.DataFrame) -> pd.DataFrame:
|
62 |
-
|
63 |
-
trades_filtered = trades_df[trades_df["creation_timestamp"] > "2023-09-01"]
|
64 |
-
trades_filtered = trades_filtered[
|
65 |
["creation_timestamp", "month_year_week", "market_creator", column_name]
|
66 |
]
|
67 |
# adding the total
|
68 |
-
trades_filtered_all =
|
69 |
trades_filtered_all["market_creator"] = "all"
|
70 |
|
71 |
# merging both dataframes
|
@@ -75,6 +75,7 @@ def get_boxplot_metrics(column_name: str, trades_df: pd.DataFrame) -> pd.DataFra
|
|
75 |
all_filtered_trades = all_filtered_trades.sort_values(
|
76 |
by="creation_timestamp", ascending=True
|
77 |
)
|
|
|
78 |
return all_filtered_trades
|
79 |
|
80 |
|
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
3 |
import plotly.express as px
|
4 |
+
import gc
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
|
7 |
trade_metric_choices = [
|
8 |
"mech calls",
|
|
|
61 |
|
62 |
|
63 |
def get_boxplot_metrics(column_name: str, trades_df: pd.DataFrame) -> pd.DataFrame:
|
64 |
+
trades_filtered = trades_df[
|
|
|
|
|
65 |
["creation_timestamp", "month_year_week", "market_creator", column_name]
|
66 |
]
|
67 |
# adding the total
|
68 |
+
trades_filtered_all = trades_df.copy(deep=True)
|
69 |
trades_filtered_all["market_creator"] = "all"
|
70 |
|
71 |
# merging both dataframes
|
|
|
75 |
all_filtered_trades = all_filtered_trades.sort_values(
|
76 |
by="creation_timestamp", ascending=True
|
77 |
)
|
78 |
+
gc.collect()
|
79 |
return all_filtered_trades
|
80 |
|
81 |
|