Cryptocurrency Exchange Trades

Recent trade histories on Binance, a popular cryptocurrency exchange, for a specified symbol (trading pair).

import requests
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns
pair = ("ETH", "AUD")
symbol = "".join(pair)
frame = pd.read_json(f"https://api.binance.com/api/v3/trades?symbol={symbol}",
                     convert_dates=["time"])
frame.set_index("time", inplace=True)
frame
id price qty quoteQty isBuyerMaker isBestMatch
time
2020-12-27 17:12:18.660 102313 906.50 0.19130 173.413450 False True
2020-12-27 17:12:18.691 102314 906.50 0.16340 148.122100 False True
2020-12-27 17:12:19.422 102315 906.50 0.11130 100.893450 False True
2020-12-27 17:12:19.456 102316 906.50 0.17685 160.314525 False True
2020-12-27 17:12:19.472 102317 906.50 0.11132 100.911580 False True
... ... ... ... ... ... ...
2020-12-27 19:51:27.446 102808 931.75 1.39014 1295.262945 True True
2020-12-27 19:51:53.966 102809 928.33 0.10780 100.073974 True True
2020-12-27 19:52:27.540 102810 931.45 0.10736 100.000472 False True
2020-12-27 19:57:18.475 102811 933.37 2.10233 1962.251752 False True
2020-12-27 19:59:36.171 102812 933.37 0.05356 49.991297 False True

500 rows × 6 columns



fig, ax = plt.subplots()

sns.scatterplot(x="time", y="price", data=frame, ax=ax)

ax.set_xlabel("Time")
ax.set_ylabel(f"Price ({pair[1]})")

plt.show()
plot trades
fig, ax = plt.subplots()

sns.scatterplot(x="time", y="price", hue="isBuyerMaker", size="qty",
                data=frame, ax=ax)

ax.set_xlabel("Time")
ax.set_ylabel(f"Price ({pair[1]})")

plt.show()
plot trades

Total running time of the script: ( 0 minutes 2.399 seconds)

Gallery generated by Sphinx-Gallery