tammoippen / plotille

Plot in the terminal using braille dots.
MIT License
398 stars 17 forks source link

using plotille for stock market charts #60

Open pannet1 opened 5 months ago

pannet1 commented 5 months ago
def tick(min, max, axis=None):
    """
    trying to mimic a stock market ticker
    """
    if axis == "X":
        return datetime.datetime.now().strftime("%H:%M:%S")
    else:
        min = int(min)
        max = 100
        return randint(min, max)

def main():
    X = []
    Y = []
    fig = plt.Figure()
    fig.plot(X, Y)
    fig.set_x_limits(min_=0)
    fig.set_y_limits(min_=0, max_=100)

    while True:
        fig.x_ticks_fkt = partial(tick, axis="X")
        fig.y_ticks_fkt = partial(tick)
        __import__('time').sleep(1)
        print(fig.show())

if __name__ == '__main__':
    main()

outputs plotille

honestly i was surprised by the end result. i just a have an incoming ticker which has a changing price and datetime.seconds. i want just to append it to the x axis and show the new y value (price of the stock). can you please help me.