Allocating Aggregate Premarket Volume Across One-Minute Bars
Summary
The document asks how to estimate minute-by-minute premarket volume when a data source reports prices for each one-minute bar but sets those bars’ volumes to zero, while providing only an aggregate premarket total. It describes a simple allocation heuristic: compare each bar’s high-low range with the average range, then assign volume in proportion to that relative size. The author notes that the relationship between bar range and volume is not necessarily linear.
Two alternatives are raised but not worked out: using reinforcement learning to allocate fixed volume increments, or fitting a machine-learning model that respects the total-volume constraint. The document provides no tested algorithm, comparison, or empirical results to establish which approach works best. Any inferred per-bar figures would be estimates, since OHLC data and an aggregate total do not reveal the actual distribution of trades within the premarket session. The proposed ideas would need validation against historical data with known minute-level volumes before being used for analysis or trading.
Key ideas
- An aggregate premarket volume total does not reveal its distribution across individual one-minute bars.
- A proposed baseline allocates more volume to bars with larger high-low ranges.
- The author considers reinforcement learning and constrained machine learning as possible alternatives.
- The document offers no empirical comparison or validated allocation method.
Tags
Full text
# Algortihm for distributing volume for 1min candle
# Algortihm for distributing volume for 1min candle
Context: I have historical 1min prices for stocks, including premarket. However, when importing real-time data, the standard practice in the financial data industry is to give only OHLC (open, high, low, close) prices and 0 volume for 1min intervals. But they do provide the total amount of pre-market volume.
Example: AAPL 1min data from yahoo finance.
```
Open High ... Adj Close Volume
Datetime
[...] [...]
2021-07-20 09:25:00 143.420000 143.460000 ... 143.400000 0
2021-07-20 09:26:00 143.410000 143.430000 ... 143.395000 0
2021-07-20 09:27:00 143.410000 143.650000 ... 143.410000 0
2021-07-20 09:28:00 143.625000 143.625000 ... 143.500000 0
2021-07-20 09:29:00 143.500000 143.560000 ... 143.560000 0
2021-07-20 09:30:00 143.460007 144.029999 ... 143.990005 2946764
2021-07-20 09:31:00 143.990005 144.009995 ... 143.309998 587213
2021-07-20 09:32:00 143.320007 143.580002 ... 143.535004 667389
2021-07-20 09:33:00 143.550003 143.710007 ... 143.570007 509797
2021-07-20 09:34:00 143.554993 143.589996 ... 143.210007 421908
```
The total amount of the volume is given one minute before the market open (09:30)
My question is: what algortihm can I use for "filling" the 1min intervals with the total volume? I know that the volume amount is closely linked with the size of the 1min candle (high-low).
My solutions so far are those:
- I get the average size and volume of 1 min candles (volume average created by using all pre-mkt volume and dividing by the number of candles). For each candle I create a ratio (candle size/candle average). So, if candle is below average, it gets less volume. Problem: This solution is more or less okay, the problem is that is primitive. The relationship with size and volume is not that linear.
- Create reinforcement learning model: I would do that by letting the AI choose between 2 actions: to add 1000 of volume or not in each candle. It would loop until there is no more volume left (from the total amount of volume). I would compare each episode with the absolute amount of difference between the real volume (from historical data) and what the reinforcement learning created. I believe it would get the nuances of volume relationship with candle size in a better way.
- Create a machine learning with constrain: the problem of predictive model is that I don't know to give the constrain of "limited" volume to distribute between 1 min candles. I quite familiar with ML algorthimn but I don't know how to solve this problem.
I believe that problem is too convoluted for a stack exchange post, if you have any advice on where I can also discuss more in deapth things like this, would be super helpful.
Thanks in advance.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.