Skip to content

Commit

Permalink
chore: run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
cdummett committed Sep 5, 2024
1 parent 4c39230 commit ac4ade3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions vega_query/service/utils/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 7 additions & 4 deletions vega_query/visualisations/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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)
Expand All @@ -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],
Expand Down

0 comments on commit ac4ade3

Please sign in to comment.