RVOL always showing "NAN"
jg892461
Posts: 11
Every time I attempt to use md.L1.rvol, I get NAN for a return on the print statement. I have it enclosed in a str() method to make sure its a string but same result. Anyone else unable to get an rvol value?
Tagged:
Comments
"When" are you attempting to get the RVOL?
Are you trying to get it in is_symbol_qualified? Or on_start? Or within the first minute of the trading day?
RVOL is relative volume. The current volume when compared with a typical (straight line) volume for previous days and is for market hours only.
Multiplier of the average 21 day volume based on time of day with an adjustment for simple cosine wave (higher volumes at beginning and end).
As such there is no value until current minutes passed is at least 1.
If you want an RVOL in the first minute or some kind of pre-market RVOL you will have to come up with your own calculation.
Thank you pt for the response. I am trying to get the rvol in the "on_start" function.
I thought there would still be a RVOL value on the first min of the trading day by giving me the previous day's closing RVOL. Is my thinking correct or should I just include a check that prior to the 1st minute, I grab the closing RVOL from the previous day?
Thank you again for your help.
If that is what you want to do then yes, just check the time or check to see if you got a nan, there is a cheaty shortcut for this...
if md.L1.rvol != md.L1.rvol: # obviously these should equal each other but if it is a NaN then they do not!
myrvol = md.bar.daily(-1).volume / md.stat.avol # So that is yesterdays volume / average volume - good enough.
Oh good little cheat there.
Thank you for your help pt. Much appreciated!
I sit possible to get a previous days L1 data? I dont see any references to past L1 data since its "Forming"
No, L1 is level 1, it is what is happening at this moment in time. What are you wanting to know?
I was just trying to see if I could get Level 1 data from a previous day. The L1 object has a lot more stored in it that just the simple bar data. I couldn't see a way to get historical L1 data to use.
No, no way to do that.
Again, what specifically are you trying to access?
Just saying "Level 1 yesterday" is too vague, for just one symbol that is a gigantic amount of information.
If there is some specific info you require, you could collect it on that day, store it in a file or in a class dictionary, then access it the next day.
But that would have to be very specific small amounts of information, you cannot collect huge amounts of info across all symbols, you will just run out of memory.
Also, to do this, you have to run as a "Single Multi Day Job", so that each day runs in order (not parallelized) so that takes much longer.
You can PM me if you do not want to discuss in a public environment.
pt, thank you again. I think I have missed the way the data is stored for back testing. I guess I thought that L1 data was stored in the system somewhere and I would be able to just access a specific bar (closing bar) of the previous day and get only the RVOL from it. I am not doing anything specific with this information, just trying to get used to the environment and more proficient at programming for alerts/scripts for myself. I knew L1 was only for forming bars but in some of the examples, it was used to gather data. In your example above, you were able to get L1 data from a series of time points starting from the beginning of the trading day until at 9:31, an RVOL amount was returned instead of Nan. I thought I could get that last bar of the close of the prior day and store the RVOL amount. But from what I am seeing, that is not possible? I can only get the data as it is coming into the system in realtime?
I am enjoying cloudquant a lot.