From ac4ade33a4482398a430eb687ee9f9c46ece592c Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 5 Sep 2024 15:50:10 +0100 Subject: [PATCH] chore: run linter --- vega_query/service/utils/party.py | 4 ++-- vega_query/visualisations/overlay.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/vega_query/service/utils/party.py b/vega_query/service/utils/party.py index b70be259c..f1bb3d552 100644 --- a/vega_query/service/utils/party.py +++ b/vega_query/service/utils/party.py @@ -96,8 +96,8 @@ def historic_balances( ) if aggregated_balance.market_id is not "": account_key += f" | {aggregated_balance.market_id[:7]}" - data[timestamp_to_datetime(aggregated_balance.timestamp)][account_key] = int( - aggregated_balance.balance + data[timestamp_to_datetime(aggregated_balance.timestamp)][account_key] = ( + int(aggregated_balance.balance) ) df = pd.DataFrame.from_dict(data, orient="index").sort_index().ffill() diff --git a/vega_query/visualisations/overlay.py b/vega_query/visualisations/overlay.py index b7392aa95..9b299454f 100644 --- a/vega_query/visualisations/overlay.py +++ b/vega_query/visualisations/overlay.py @@ -878,6 +878,7 @@ def overlay_price( y.append(price if price != 0 else np.nan) ax.step(x, y, label="price", where="post") + def overlay_volume( ax: Axes, trades: List[protos.vega.vega.Trade], @@ -893,6 +894,7 @@ def overlay_volume( y.append(price * size if price != 0 else np.nan) ax.step(x, y, label="volume", where="post") + def overlay_cumulative_volume( ax: Axes, trades: List[protos.vega.vega.Trade], @@ -908,15 +910,15 @@ def overlay_cumulative_volume( # Convert timestamp to datetime for x-axis timestamp = timestamp_to_datetime(trade.timestamp, nano=True) x.append(timestamp) - + # Ensure price and size are available - if hasattr(trade, 'price') and hasattr(trade, 'size'): + if hasattr(trade, "price") and hasattr(trade, "size"): price = padded_int_to_float(trade.price, price_decimals) size = padded_int_to_float(trade.size, size_decimals) - + # Calculate traded volume (price * size) volume = price * size if price != 0 else 0 - + # Accumulate volume (ensure volume is positive) cumulative_volume += abs(volume) y.append(cumulative_volume) @@ -927,6 +929,7 @@ def overlay_cumulative_volume( # Plot the cumulative volume data using step plot ax.step(x, y, label="Cumulative Volume", where="post", **kwargs) + def overlay_maker_fee( ax: Axes, trades: List[protos.vega.vega.Trade],