Skip to content

Instantly share code, notes, and snippets.

@ljw-612
Created November 25, 2021 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljw-612/d6fc12d6580fcf9eebe7ee8b5fc8d194 to your computer and use it in GitHub Desktop.
Save ljw-612/d6fc12d6580fcf9eebe7ee8b5fc8d194 to your computer and use it in GitHub Desktop.
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)")
ax.set_ylabel("Amount")
ax.legend(['Buy','Sell'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment