highfestiva / finplot

Performant and effortless finance plotting for Python
MIT License
907 stars 186 forks source link

[BUG] In some low-priced coin stocks, the crosshair moves differently. #403

Closed big100 closed 1 year ago

big100 commented 1 year ago

Code to reproduce

import sys 
from PySide2.QtWidgets import *
from PySide2.QtCore import *
import finplot as fplt
import pyupbit

from PySide2.QtTest import QTest
class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        widget= QGraphicsView()
        layout = QGridLayout(widget)
        self.setCentralWidget(widget)
        self.resize(800, 300)
        ax = fplt.create_plot(init_zoom_periods=100)
        widget.axs = [ax]
        layout.addWidget(ax.vb.win)

        df = pyupbit.get_ohlcv("KRW-BTT", interval="minutes1") # there is a problem
        # df = pyupbit.get_ohlcv("KRW-SHIB", interval="minutes1") # coin stocks with a low price
        # df = pyupbit.get_ohlcv("KRW-XEC", interval="minutes1") # coin stocks with a low price

        print(df)

        fplt.autoviewrestore()
        plot = fplt.candlestick_ochl(df[['open', 'close', 'high', 'low']], ax=ax)

        fplt.show(qt_exec=False)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MyWindow()
    window.show()
    app.exec_(app.exec_())

Describe the bug

On the chart, the mouse does not move to the correct value on the Y axis.

This problem occurs with coins of a certain price.

Problems occur on some charts with lower prices.

Even if the price chart has the same decimal point, there will be a difference according to the price.

It should move in increments of 0.0001. But it moves in increments of 0.001.

Expected behavior

It is the order book of the coin. It should move in increments of 0.0001.

image

Screenshots

image

Reproducible in:

finplot version: 1.9.0 pyqtgraph version: 0.13.1 PySide2 version: 5.15.2.1

highfestiva commented 1 year ago

Good catch, fix in b6ec5fd.

big100 commented 1 year ago

Good catch, fix in b6ec5fd.

Thanks for solving it.