ScottPlot / ScottPlot

Interactive plotting library for .NET
https://ScottPlot.net
MIT License
5.31k stars 860 forks source link

Improve finance demo #4483

Closed swharden closed 2 days ago

swharden commented 2 days ago

This issue tracks short term goals to improve financial charting resulting from a discussion today with @quantfreedom and @VladislavPustovarov

Scott

Vlad

YearOnly - Year
YearAndJuly - Year, July
YearAnd2Months - Year, May, Sep
YearAnd3Months - Year, Apr, Jul, Oct
YearAnd4Months - Year, Mar, May, Jul, Sep, Nov
Months - Year, then each month
MonthAndThirdMonday - months are short names, days are the number
MonthAndEveryMonday - months are short names, days are the number
MonthAndEveryOtherDay - months are short names, days are the number
MonthAndEveryDay - months are short names, days are the number
DayAndEvery12Hours - show the day number for midnight, then show 6, 12, 18
DayAndEvery4Hours
DayAndEvery3Hours
EveryHour
EveryHalfHour
Every15Minutes
Every5Minutes
EveryMinute
Seconds45
Seconds30
Seconds15
Seconds10
Seconds5
Seconds1
quantfreedom commented 2 days ago

vlad has two accounts and the one he uses for his personal project is

VladislavPustovarov

so you can change the at to match that

swharden commented 2 days ago

@quantfreedom and @VladislavPustovarov - got it, thanks!

swharden commented 2 days ago

I added cursor tracking with highlighted labels and candle snapping in the horizontal axis

I'll keep working in #4484

snap2

quantfreedom commented 2 days ago

tenor holy jesus ... this thing is looking so damn sexy ... this is beyond nuts that all of this is even happening ... insane

swharden commented 2 days ago

@VladislavPustovarov I have an important message about performance.

Performance is indeed very bad when displaying 50,000 candles. However, I think this should never be done. Showing so many distinct candles on a 800px wide chart means each candle is less than 0.02 pixels wide.

I highly recommend detecting when you are trying to display an extremely large number of candles and re-binning the data so that candles are at least 1 pixel wide or wider. I don't think a user will ever want to see second-width candles on a years-wide plot.

For example, TradingView limits how far you can zoom in or out based on the width of candles. This prevents more than a few thousand candles from ever being seen at one time. Users who want to see more time can increase the candle width.

If you implement this strategy in your application, it will be extremely performant. Also, no modification to ScottPlot is required to achieve this high performance.

Let me know if you have any questions about this topic! I am updating the demo app in #4484 to show render time and frame rate at the top in the title area. It's interesting to see how poor performance gets when candles are significantly smaller than 1 pixel wide.

candlePerf2

swharden commented 2 days ago

Resizing Behavior

I'm writing this down to put words to the behavior that needs to change.

Presently, resizing the window "squeezes" the plot so there is no change in axis limits. For financial charting, this is not the desired behavior. resize1

The chart should respond to resize events by "sliding" data off the screen to the left to achieve a fixed "distance per pixel" ratio through resize events resize2

swharden commented 2 days ago

I figured out a way to implement this behavior using a custom axis rule

This completes my list of tasks so I'm going to merge #4484 which will close this issue, but we can still use this issue for conversation and taking notes even after it's closed.

Let's can pick up our discussion again after you make progress on improving the data tick logic

Feel free to reach out in the meantime if you have any questions 👍

resize3