only 2024 data
Browse files
app.py
CHANGED
@@ -28,122 +28,22 @@ from tabs.error import (
|
|
28 |
plot_week_error_data
|
29 |
)
|
30 |
from tabs.about import about_olas_predict
|
31 |
-
import psutil
|
32 |
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
mem_info = process.memory_info()
|
38 |
-
logging.info(f"RAM Usage: RSS={mem_info.rss} bytes, VMS={mem_info.vms} bytes")
|
39 |
-
|
40 |
-
def update_trades_plots():
|
41 |
-
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
42 |
-
|
43 |
-
refresh_data()
|
44 |
-
|
45 |
-
updated_trades_by_week_plot = plot_trades_by_week(
|
46 |
-
trades_df=trades_count_df
|
47 |
-
)
|
48 |
-
|
49 |
-
updated_winning_trades_by_week_plot = plot_winning_trades_by_week(
|
50 |
-
trades_df=trades_winning_rate_df
|
51 |
-
)
|
52 |
-
|
53 |
-
updated_trade_details_plot = plot_trade_details(
|
54 |
-
trade_detail="mech calls",
|
55 |
-
trades_df=trades_df
|
56 |
-
)
|
57 |
-
|
58 |
-
return (
|
59 |
-
updated_trades_by_week_plot,
|
60 |
-
updated_winning_trades_by_week_plot,
|
61 |
-
updated_trade_details_plot
|
62 |
-
)
|
63 |
-
|
64 |
-
|
65 |
-
def update_tool_winnings_plots():
|
66 |
-
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
67 |
-
|
68 |
-
refresh_data()
|
69 |
-
|
70 |
-
updated_winning_plot = plot_tool_winnings_overall(
|
71 |
-
wins_df=winning_rate_overall_df,
|
72 |
-
winning_selector="win_perc"
|
73 |
-
)
|
74 |
-
|
75 |
-
updated_tool_winnings_by_tool_plot = plot_tool_winnings_by_tool(
|
76 |
-
wins_df=winning_rate_df,
|
77 |
-
tool=INC_TOOLS[0]
|
78 |
-
)
|
79 |
-
|
80 |
-
return (
|
81 |
-
updated_winning_plot,
|
82 |
-
updated_tool_winnings_by_tool_plot
|
83 |
-
)
|
84 |
-
|
85 |
-
def update_error_plots():
|
86 |
-
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
87 |
-
|
88 |
-
refresh_data()
|
89 |
-
|
90 |
-
updated_error_overall_plot = plot_error_data(
|
91 |
-
error_all_df=error_overall_df
|
92 |
-
)
|
93 |
-
|
94 |
-
updated_tool_error_plot = plot_tool_error_data(
|
95 |
-
error_df=error_df,
|
96 |
-
tool=INC_TOOLS[0]
|
97 |
-
)
|
98 |
-
|
99 |
-
updated_week_error_plot = plot_week_error_data(
|
100 |
-
error_df=error_df,
|
101 |
-
week=choices[-1]
|
102 |
-
)
|
103 |
-
|
104 |
-
return (
|
105 |
-
updated_error_overall_plot,
|
106 |
-
updated_tool_error_plot,
|
107 |
-
updated_week_error_plot
|
108 |
-
)
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
global tools_df, trades_df, error_df, error_overall_df, winning_rate_df, winning_rate_overall_df, trades_count_df, trades_winning_rate_df
|
113 |
-
|
114 |
-
logging.info("Refreshing data...")
|
115 |
-
|
116 |
-
tools_df = pd.read_parquet("./data/tools.parquet")
|
117 |
-
trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
|
118 |
-
trades_df = prepare_trades(trades_df)
|
119 |
-
error_df = get_error_data(tools_df=tools_df, inc_tools=INC_TOOLS)
|
120 |
-
error_overall_df = get_error_data_overall(error_df=error_df)
|
121 |
-
winning_rate_df = get_tool_winning_rate(tools_df=tools_df, inc_tools=INC_TOOLS)
|
122 |
-
winning_rate_overall_df = get_overall_winning_rate(wins_df=winning_rate_df)
|
123 |
-
trades_count_df = get_overall_trades(trades_df=trades_df)
|
124 |
-
trades_winning_rate_df = get_overall_winning_trades(trades_df=trades_df)
|
125 |
-
|
126 |
-
logging.info("Data refreshed.")
|
127 |
-
except Exception as e:
|
128 |
-
logging.error("Failed to refresh data: %s", e)
|
129 |
-
|
130 |
-
|
131 |
-
def pull_refresh_data():
|
132 |
-
# Run the pull_data.py script and wait for it to finish
|
133 |
-
try:
|
134 |
-
result = subprocess.run(["python", "./scripts/pull_data.py"], check=True)
|
135 |
-
logging.info("Script executed successfully: %s", result)
|
136 |
-
refresh_data()
|
137 |
-
except subprocess.CalledProcessError as e:
|
138 |
-
logging.error("Failed to run script: %s", e)
|
139 |
-
return # Stop execution if the script fails
|
140 |
-
|
141 |
-
refresh_data()
|
142 |
|
143 |
-
|
144 |
-
tools_df = pd.read_parquet("./data/tools.parquet")
|
145 |
-
trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
|
146 |
-
trades_df = prepare_trades(trades_df)
|
147 |
|
148 |
|
149 |
demo = gr.Blocks()
|
@@ -240,19 +140,6 @@ with demo:
|
|
240 |
with gr.Row():
|
241 |
trade_details_plot
|
242 |
|
243 |
-
with gr.Row():
|
244 |
-
with gr.Column():
|
245 |
-
refresh_button = gr.Button("Refresh Data")
|
246 |
-
|
247 |
-
refresh_button.click(
|
248 |
-
update_trades_plots,
|
249 |
-
outputs=[
|
250 |
-
trades_by_week_plot,
|
251 |
-
winning_trades_by_week_plot,
|
252 |
-
trade_details_plot,
|
253 |
-
]
|
254 |
-
)
|
255 |
-
|
256 |
with gr.TabItem("��� Tool Winning Dashboard"):
|
257 |
with gr.Row():
|
258 |
gr.Markdown("# Plot showing overall winning rate")
|
@@ -319,17 +206,6 @@ with demo:
|
|
319 |
sel_tool
|
320 |
with gr.Row():
|
321 |
tool_winnings_by_tool_plot
|
322 |
-
with gr.Row():
|
323 |
-
refresh_button = gr.Button("Refresh Data")
|
324 |
-
|
325 |
-
refresh_button.click(
|
326 |
-
update_tool_winnings_plots,
|
327 |
-
outputs=[
|
328 |
-
winning_plot,
|
329 |
-
tool_winnings_by_tool_plot
|
330 |
-
]
|
331 |
-
)
|
332 |
-
|
333 |
|
334 |
with gr.TabItem("🏥 Tool Error Dashboard"):
|
335 |
with gr.Row():
|
@@ -406,26 +282,9 @@ with demo:
|
|
406 |
sel_week
|
407 |
with gr.Row():
|
408 |
week_error_plot
|
409 |
-
|
410 |
-
with gr.Row():
|
411 |
-
refresh_button = gr.Button("Refresh Data")
|
412 |
-
|
413 |
-
refresh_button.click(
|
414 |
-
update_error_plots,
|
415 |
-
outputs=[
|
416 |
-
error_overall_plot,
|
417 |
-
tool_error_plot,
|
418 |
-
week_error_plot
|
419 |
-
]
|
420 |
-
)
|
421 |
|
422 |
with gr.TabItem("ℹ️ About"):
|
423 |
with gr.Accordion("About Olas Predict"):
|
424 |
gr.Markdown(about_olas_predict)
|
425 |
|
426 |
-
# Create the scheduler
|
427 |
-
scheduler = BackgroundScheduler(timezone=utc)
|
428 |
-
scheduler.add_job(pull_refresh_data, CronTrigger(hour=0, minute=0)) # Runs daily at 12 AM UTC
|
429 |
-
scheduler.start()
|
430 |
-
|
431 |
demo.queue(default_concurrency_limit=40).launch()
|
|
|
28 |
plot_week_error_data
|
29 |
)
|
30 |
from tabs.about import about_olas_predict
|
|
|
31 |
|
32 |
+
|
33 |
+
def prepare_data():
|
34 |
+
tools_df = pd.read_parquet("./data/tools.parquet")
|
35 |
+
trades_df = pd.read_parquet("./data/all_trades_profitability.parquet")
|
36 |
|
37 |
+
tools_df['request_time'] = pd.to_datetime(tools_df['request_time'])
|
38 |
+
tools_df = tools_df[tools_df['request_time'].dt.year == 2024]
|
39 |
|
40 |
+
trades_df['creation_timestamp'] = pd.to_datetime(trades_df['creation_timestamp'])
|
41 |
+
trades_df = trades_df[trades_df['creation_timestamp'].dt.year == 2024]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
trades_df = prepare_trades(trades_df)
|
44 |
+
return tools_df, trades_df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
tools_df, trades_df = prepare_data()
|
|
|
|
|
|
|
47 |
|
48 |
|
49 |
demo = gr.Blocks()
|
|
|
140 |
with gr.Row():
|
141 |
trade_details_plot
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
with gr.TabItem("��� Tool Winning Dashboard"):
|
144 |
with gr.Row():
|
145 |
gr.Markdown("# Plot showing overall winning rate")
|
|
|
206 |
sel_tool
|
207 |
with gr.Row():
|
208 |
tool_winnings_by_tool_plot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
with gr.TabItem("🏥 Tool Error Dashboard"):
|
211 |
with gr.Row():
|
|
|
282 |
sel_week
|
283 |
with gr.Row():
|
284 |
week_error_plot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
with gr.TabItem("ℹ️ About"):
|
287 |
with gr.Accordion("About Olas Predict"):
|
288 |
gr.Markdown(about_olas_predict)
|
289 |
|
|
|
|
|
|
|
|
|
|
|
290 |
demo.queue(default_concurrency_limit=40).launch()
|