Skip to content

Commit

Permalink
feat: address comments from Charlie
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiajia-Cui committed Sep 5, 2024
1 parent 85643fd commit 4c39230
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
17 changes: 3 additions & 14 deletions vega_query/visualisations/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,14 +898,13 @@ def overlay_cumulative_volume(
trades: List[protos.vega.vega.Trade],
price_decimals: int,
size_decimals: int,
**kwargs,
):
x = [] # List to store timestamps
y = [] # List to store cumulative volume
cumulative_volume = 0 # Initialize cumulative volume

trades = reversed(trades)

for trade in trades:
for trade in reversed(trades):
# Convert timestamp to datetime for x-axis
timestamp = timestamp_to_datetime(trade.timestamp, nano=True)
x.append(timestamp)
Expand All @@ -918,25 +917,15 @@ def overlay_cumulative_volume(
# Calculate traded volume (price * size)
volume = price * size if price != 0 else 0

# Debugging: Print current values
print(f"Trade timestamp: {trade.timestamp}, Price: {price}, Size: {size}, Volume: {volume}")

# Accumulate volume (ensure volume is positive)
cumulative_volume += abs(volume)
y.append(cumulative_volume)
else:
# If price or size is missing, assume no change in cumulative volume
y.append(cumulative_volume)
print(f"Missing price or size for trade at {trade.timestamp}")

# Plot the cumulative volume data using step plot
ax.step(x, y, label="Cumulative Volume", where="post")

# Optionally, set labels and title for clarity
ax.set_xlabel('Timestamp')
ax.set_ylabel('Cumulative Volume')
ax.set_title('Cumulative Volume Over Time')
ax.legend()
ax.step(x, y, label="Cumulative Volume", where="post", **kwargs)

def overlay_maker_fee(
ax: Axes,
Expand Down
4 changes: 2 additions & 2 deletions vega_query/visualisations/plots/amm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def create(
if market_data_history is not None:
overlay_mark_price(axn0l, market_data_history, market.decimal_places)
overlay_trading_mode(axn0r, market_data_history)
overlay_auction_starts(axn0r, market_data_history)
overlay_auction_ends(axn0r, market_data_history)
# overlay_auction_starts(axn0r, market_data_history)
# overlay_auction_ends(axn0r, market_data_history)

axn0l.set_ylabel("USDT")
axn0l.set_title(
Expand Down
2 changes: 1 addition & 1 deletion vega_sim/scenario/amm/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def configure_agents(
key_name=f"AutomatedMarketMaker_{benchmark_config.market_config.instrument.code}_{str(i_agent).zfill(3)}",
market_name=benchmark_config.market_config.instrument.name,
initial_asset_mint=1e6,
commitment_amount=10_000,
commitment_amount=7000,
slippage_tolerance=0.05,
proposed_fee=self.amm_liquidity_fee,
price_process=iter(benchmark_config.price_process),
Expand Down

0 comments on commit 4c39230

Please sign in to comment.