project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
242 stars 57 forks source link

Volume and delta candles #91

Closed quantfreedom closed 1 year ago

quantfreedom commented 1 year ago

Describe the bug

So i am not sure if this is a bug or a feature request

i am trying to print candles based on volume and delta ... so my x axis will have random times on it like oct 14 2023 20:04:05.659 then the next one could be oct 14 2023 20:04:07.893 .... I am wondering how do i set it up so that the x axis isn't set to some type of time interval and i can make the candles start at any point with a specific width of lets say 40 pixels or something ... right now it is making my candles super super tiny ... so i want the candle size to not be dictated by the x axis

which one of the settings would i have to change ... i am guessing it could be in either

also it seems like the answer might be here but it doesn't seems to be complete https://nightvision.dev/guide/main-comp/layout.html#mapping-functions

also if i change the data to index based each tick gets its own spot but what is interesting is the candle is perfectly spaced out ... the time is perfect on the x axis ... so really wanting to make that happen with volume based candles ... its almost as if i need to be able to turn indexbased on and off at the right time or something

this is what it is doing right now image

https://nightvision.dev/guide/api/chart-config https://nightvision.dev/guide/api/chart-api https://nightvision.dev/guide/api/layout-api

Reproduction

https://github.com/QuantFreedom1022/QuantFreedom/tree/neo/nightvision/tick_data

Steps to reproduce

No response

Javascript Framework

no-framework (vanilla-js)

Logs

No response

Validations

C451 commented 1 year ago

Seems like you need this: https://nightvision.dev/guide/main-comp/layout.html#the-problem

quantfreedom commented 1 year ago

Seems like you need this: https://nightvision.dev/guide/main-comp/layout.html#the-problem

yeah i tried looking into that but there doesn't seem to be much information about it ... it seems like to update the candle to print a new one i need the indexBased to be true ... then when i want to update the candle with ticks i need it to be false ... but i tried all of that and it still didn't work

can you please look at this and let me know where i should be putting the change to using the indexBased true and when it should be false ... i tried to change it at chart.data.indexBased ... and it didn't work ... and i also tried to change it at chart.hub.data.indexBased and no luck ... and i also changed it in the dataload part where i load the init data and it would only print each tick as a new candle

quantfreedom commented 1 year ago

@C451 you can check out the code in codespace ... if you could help me figure out where i would need to put indexbased to true that would be great because i wasn't able to get it to work no matter where i put it to be true or put it to be false because it seems like i need both https://codesandbox.io/s/jovial-tess-pyf4nc?file=/main.js

C451 commented 1 year ago

Look into data-aapl.json in the repo, that will be sufficient.

quantfreedom commented 1 year ago

Look into data-aapl.json in the repo, that will be sufficient.

thanks for the suggestion but this data set doesn't seem to be what i am looking for ... it seems to looks like every other dataset with time and candle info

https://github.com/search?q=repo%3Aproject-nv%2Fnight-vision%20data-aapl.json&type=code

i searched for your suggestion as well and only two files came up and i tested the one that did log scale and it didn't do what i was looking for https://github.com/project-nv/night-vision/blob/ccaa665856db7e5c6b71e205dacfa1ed34b9ace8/tests/scales/logScale.js

and the other file was tests file which i ran and i am not seeing anything in the run that is what i am looking for ... i ran stack.execALL() and none of the tests did what i was looking for ... even the indexbased test just basically redid what the timebased test did ... the indexbased one is testing the same data as time but just adding true to indexbased ... so there doesn't seem to be a text of indexbased it seems ... maybe i am wrong tho

https://github.com/project-nv/night-vision/blob/ccaa665856db7e5c6b71e205dacfa1ed34b9ace8/src/App.svelte

quantfreedom commented 1 year ago

After giving it some thought I realized that neither time based or index based would work ... there needs to be other options

One would be trade-based where say for example the user is streaming binance data and they want to print a candle after every 30 trades or 50 trades or 100 trades

Then there's volume based which the user says I want to print a candle every 5 million volume or 10 million volume or whatever volume they set

And another one would be volume Delta where again if you're streaming the data you can say whenever we reach an imbalance of 500,000 by volume over the cell volume then you print a candle

basically it would have to let the user build using tick data and then whenever they say they have built up enough data the close the candle and the move on to building the next ... exactly how time does it accept it's not based off time

I have already tried setting the index based to true and then closing the candle and then setting it back to false but that doesn't work.

So do you have any ideas on how I could help make this an option for you guys or can you help me make it because without it there's no way to do any volume based candles or tick base candles where you are building the candle off of the total amount of trades or the total amount of volume or the total amount of volume Delta

@mariusvigariu u seem to have a lot of experience with this lib ... u have any idea

mariusvigariu commented 1 year ago

can't say for sure, i haven't touched that part yet .. your reproduction link says 404

quantfreedom commented 1 year ago

@mariusvigariu yeah i moved it to codesandbox ... you can check it out here and see what it is doing if you would like https://codesandbox.io/s/jovial-tess-pyf4nc?file=/main.js ... i feel like this should be pretty easy for someone with experience with this repo and js ... which i am not either of those lol

quantfreedom commented 1 year ago

@C451 ... hey just wanted to check in on this ... really could use the help in being pointed to what i need to change in order to make this work

C451 commented 1 year ago

Hey, this project & tvjs were always for people who like to dig into the code and hack. If you want to make something tailored to your specific use-case, you'll need to work for it.

quantfreedom commented 1 year ago

Hey, this project & tvjs were always for people who like to dig into the code and hack. If you want to make something tailored to your specific use-case, you'll need to work for it.

ok ... but i am just needing to know if this is some type of thing that has to be added at its core or something i would have to completely change ... but its all good ... i figured it out ... and keeping in the spirit of not really wanting to help ... ill just let the next users figure it out if that's the way you want to do things!

also if its going to be that way you should probably have a massive disclaimer at the start of your documentation that your not really here to help and that if you want something done you have to figure it out yourself .... would have been good to know what i was getting into ... but on second thought i guess that goes against the spirit of just figure it out

C451 commented 1 year ago

Well, the disclaimer is on the main page: "Time-series / candlestick charts for PROS." :D I wish you good luck man, I believe in your ability to figure it out.