Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2021 11:20
What would you like to do?
buy_side_df = trades_df[trades_df['side']=='buy']
sell_side_df = trades_df[trades_df['side']=='sell']
buy_side_df['price'] = buy_side_df['price'].astype('float')
buy_side_df['amount'] = buy_side_df['amount'].astype('float')
sell_side_df['price'] = sell_side_df['price'].astype('float')
sell_side_df['amount'] = sell_side_df['amount'].astype('float')
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.pyplot import MultipleLocator
import matplotlib.ticker as ticker
fig, ax = plt.subplots()
ax.set_title('btc-usd order book, 2021-11-05 22:50:00 to 2021-11-05 23:00:00')
# buys_side
sns.ecdfplot(x="price", weights="amount", stat="count", complementary=True, data=buy_side_df, ax=ax, color='g')
sns.ecdfplot(x="price", weights="amount", stat="count", complementary=True, data=sell_side_df, ax=ax, color='r')
ax.set_xlabel("Price (USD)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment