rosacastillo
commited on
Commit
·
ce1e45a
1
Parent(s):
8e66cc5
updating the weekly graph of number of trades for stacked version
Browse files- tabs/trades.py +17 -15
tabs/trades.py
CHANGED
@@ -188,38 +188,40 @@ def integrated_plot_trades_per_market_by_week_v2(trades_df: pd.DataFrame) -> gr.
|
|
188 |
# Combine the traces
|
189 |
final_traces = []
|
190 |
market_colors = {"pearl": "darkviolet", "quickstart": "goldenrod", "all": "green"}
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
for market in ["pearl", "quickstart", "all"]:
|
193 |
market_data = trades[trades["market_creator"] == market]
|
|
|
|
|
194 |
agent_data = market_data[market_data["staking_type"] == "agent"]
|
195 |
-
|
196 |
x=agent_data["month_year_week"],
|
197 |
y=agent_data["trades"],
|
198 |
name=f"{market}-agent",
|
199 |
marker_color=market_colors[market],
|
200 |
-
offsetgroup=market,
|
201 |
showlegend=True,
|
202 |
)
|
203 |
-
final_traces.append(trace)
|
204 |
|
205 |
-
|
206 |
-
market_darker_colors = {
|
207 |
-
"pearl": "purple",
|
208 |
-
"quickstart": "darkgoldenrod",
|
209 |
-
"all": "darkgreen",
|
210 |
-
}
|
211 |
-
for market in ["pearl", "quickstart", "all"]:
|
212 |
-
market_data = trades[trades["market_creator"] == market]
|
213 |
non_agent_data = market_data[market_data["staking_type"] == "non_agent"]
|
214 |
-
|
215 |
x=non_agent_data["month_year_week"],
|
216 |
y=non_agent_data["trades"],
|
217 |
name=f"{market}-non_agent",
|
218 |
marker_color=market_darker_colors[market],
|
219 |
-
offsetgroup=market,
|
|
|
220 |
showlegend=True,
|
221 |
)
|
222 |
-
|
|
|
223 |
|
224 |
# Create new figure with the combined traces
|
225 |
fig = go.Figure(data=final_traces)
|
|
|
188 |
# Combine the traces
|
189 |
final_traces = []
|
190 |
market_colors = {"pearl": "darkviolet", "quickstart": "goldenrod", "all": "green"}
|
191 |
+
market_darker_colors = {
|
192 |
+
"pearl": "purple",
|
193 |
+
"quickstart": "darkgoldenrod",
|
194 |
+
"all": "darkgreen",
|
195 |
+
}
|
196 |
+
|
197 |
+
# Process both agent and non-agent traces for each market together
|
198 |
for market in ["pearl", "quickstart", "all"]:
|
199 |
market_data = trades[trades["market_creator"] == market]
|
200 |
+
|
201 |
+
# First add 'agent' trace
|
202 |
agent_data = market_data[market_data["staking_type"] == "agent"]
|
203 |
+
agent_trace = go.Bar(
|
204 |
x=agent_data["month_year_week"],
|
205 |
y=agent_data["trades"],
|
206 |
name=f"{market}-agent",
|
207 |
marker_color=market_colors[market],
|
208 |
+
offsetgroup=market, # Keep the market grouping
|
209 |
showlegend=True,
|
210 |
)
|
|
|
211 |
|
212 |
+
# Then add 'non_agent' trace with base set to agent values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
non_agent_data = market_data[market_data["staking_type"] == "non_agent"]
|
214 |
+
non_agent_trace = go.Bar(
|
215 |
x=non_agent_data["month_year_week"],
|
216 |
y=non_agent_data["trades"],
|
217 |
name=f"{market}-non_agent",
|
218 |
marker_color=market_darker_colors[market],
|
219 |
+
offsetgroup=market, # Keep the market grouping
|
220 |
+
base=agent_data["trades"], # Stack on top of agent trace
|
221 |
showlegend=True,
|
222 |
)
|
223 |
+
|
224 |
+
final_traces.extend([agent_trace, non_agent_trace])
|
225 |
|
226 |
# Create new figure with the combined traces
|
227 |
fig = go.Figure(data=final_traces)
|