Below is the plot. Dark lines cover the x axis, and for some reason it seems like I can't debug this. I am trying to display two columns from a data framework, a 3-dimensional SMA price versus time, as can be seen from the code below.

This is the result of this code.
import datetime
import matplotlib.pyplot as plt
import pandas as pd
from binance.client import Client
BASE = "ETH"
QUOTE = "USDT"
MARKET = BASE + QUOTE
client = Client("vitalik",
                "buterin")
klines = client.get_historical_klines(MARKET, Client.KLINE_INTERVAL_15MINUTE, "31 Dec, 2017", "13 Jan, 2018")
for kline in klines:
    kline[0] = datetime.datetime.fromtimestamp(
        int(kline[0] / 1000)
    ).strftime('%Y-%m-%d %H:%M:%S')
    kline[6] = datetime.datetime.fromtimestamp(
        int(kline[6] / 1000)
    ).strftime('%Y-%m-%d %H:%M:%S')
df = pd.DataFrame(klines,
                  columns=["open_time", "open", "high", "low", "close", "volume", "close_time", "quote_asset_volume",
                           "trades", "base_volume", "quote_volume", "ignore"])
df['sma_3'] = df["close"].rolling(window=3).mean()
print(df.dtypes)
fig, ax = plt.subplots(figsize=(10, 6))
ax.xaxis_date()
plt.xticks(rotation=90)
plt.xlabel("Date")
plt.ylabel("Price")
plt.title(MARKET)
plt.plot_date(x=df["close_time"], y=df["sma_3"], fmt="r-")
plt.show()
Result print(df.dtypes):
open_time              object
open                   object
high                   object
low                    object
close                  object
volume                 object
close_time             object
quote_asset_volume     object
trades                  int64
base_volume            object
quote_volume           object
ignore                 object
sma_5                 float64
sma_3                 float64
dtype: object
Any help would be greatly appreciated. Thank.
source
share