gauravlochab commited on
Commit
fdcd7fd
·
1 Parent(s): 5591735

feat: enhance hover data to include formatted timestamps and active agent counts for the last 24 hours

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -932,8 +932,16 @@ def create_combined_roi_time_series_graph(df):
932
  hover_data_roi = []
933
  for idx, row in avg_roi_data_with_ma.iterrows():
934
  timestamp = row['timestamp']
 
 
 
 
 
 
 
 
935
  hover_data_roi.append(
936
- f"Time: {timestamp}<br>Avg ROI (3d window): {row['moving_avg']:.2f}%"
937
  )
938
 
939
  fig.add_trace(
@@ -1581,8 +1589,16 @@ def create_combined_time_series_graph(df):
1581
  hover_data_apr = []
1582
  for idx, row in avg_apr_data_with_ma.iterrows():
1583
  timestamp = row['timestamp']
 
 
 
 
 
 
 
 
1584
  hover_data_apr.append(
1585
- f"Time: {timestamp}<br>Avg APR (3d window): {row['moving_avg']:.2f}"
1586
  )
1587
 
1588
  fig.add_trace(
@@ -1614,13 +1630,21 @@ def create_combined_time_series_graph(df):
1614
  hover_data_adj = []
1615
  for idx, row in filled_avg_apr_data.iterrows():
1616
  timestamp = row['timestamp']
 
 
 
 
 
 
 
 
1617
  if pd.notna(row['adjusted_moving_avg']):
1618
  hover_data_adj.append(
1619
- f"Time: {timestamp}<br>Avg ETH Adjusted APR (3d window): {row['adjusted_moving_avg']:.2f}"
1620
  )
1621
  else:
1622
  hover_data_adj.append(
1623
- f"Time: {timestamp}<br>Avg ETH Adjusted APR (3d window): N/A"
1624
  )
1625
 
1626
  fig.add_trace(
 
932
  hover_data_roi = []
933
  for idx, row in avg_roi_data_with_ma.iterrows():
934
  timestamp = row['timestamp']
935
+ # Format timestamp to show only up to seconds (not milliseconds)
936
+ formatted_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
937
+
938
+ # Calculate number of active agents in the last 24 hours
939
+ time_24h_ago = timestamp - pd.Timedelta(hours=24)
940
+ active_agents = len(df[(df['timestamp'] >= time_24h_ago) &
941
+ (df['timestamp'] <= timestamp)]['agent_id'].unique())
942
+
943
  hover_data_roi.append(
944
+ f"Time: {formatted_timestamp}<br>Avg ROI (3d window): {row['moving_avg']:.2f}%<br>Active agents (24h): {active_agents}"
945
  )
946
 
947
  fig.add_trace(
 
1589
  hover_data_apr = []
1590
  for idx, row in avg_apr_data_with_ma.iterrows():
1591
  timestamp = row['timestamp']
1592
+ # Format timestamp to show only up to seconds (not milliseconds)
1593
+ formatted_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
1594
+
1595
+ # Calculate number of active agents in the last 24 hours
1596
+ time_24h_ago = timestamp - pd.Timedelta(hours=24)
1597
+ active_agents = len(apr_data[(apr_data['timestamp'] >= time_24h_ago) &
1598
+ (apr_data['timestamp'] <= timestamp)]['agent_id'].unique())
1599
+
1600
  hover_data_apr.append(
1601
+ f"Time: {formatted_timestamp}<br>Avg APR (3d window): {row['moving_avg']:.2f}<br>Active agents (24h): {active_agents}"
1602
  )
1603
 
1604
  fig.add_trace(
 
1630
  hover_data_adj = []
1631
  for idx, row in filled_avg_apr_data.iterrows():
1632
  timestamp = row['timestamp']
1633
+ # Format timestamp to show only up to seconds (not milliseconds)
1634
+ formatted_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
1635
+
1636
+ # Calculate number of active agents in the last 24 hours
1637
+ time_24h_ago = timestamp - pd.Timedelta(hours=24)
1638
+ active_agents = len(apr_data[(apr_data['timestamp'] >= time_24h_ago) &
1639
+ (apr_data['timestamp'] <= timestamp)]['agent_id'].unique())
1640
+
1641
  if pd.notna(row['adjusted_moving_avg']):
1642
  hover_data_adj.append(
1643
+ f"Time: {formatted_timestamp}<br>Avg ETH Adjusted APR (3d window): {row['adjusted_moving_avg']:.2f}<br>Active agents (24h): {active_agents}"
1644
  )
1645
  else:
1646
  hover_data_adj.append(
1647
+ f"Time: {formatted_timestamp}<br>Avg ETH Adjusted APR (3d window): N/A<br>Active agents (24h): {active_agents}"
1648
  )
1649
 
1650
  fig.add_trace(