This is a generator for random price feeds that can be used to generate a new price at will or at predefined time intervals. The PriceFeed object will also maintain statistics on all the prices that it generated.
A typical use-case is in a development environment where you would like to mimic a pricefeed.
You can install the package via PyPI or from source.
pip install pricefeed
git clone https://github.com/smart-t/pricefeed.git
cd pricefeed
pip install .
import pricefeed as pf
AAPL_ticker = pf.Pricefeed("AAPL", 235.0, 500, 0.001)
for i in range(10):
print(f"{i} : {next(AAPL_ticker)}")
The above script will generate a new price every 500 miliseconds and completes a list with 10 simulated 'AAPL' stock prices starting at $235.0. The 4th argument is used to indicate how volatile the stock movement will be.
The generated prices are designed to stay relatively close to the given start price.
The third and fourth properties (delay and vol) are optional, and if not
provided they default to 0ms
(0sec
) and a volatility of 0.01
. A delay of
0ms
means the object generates a new price on demand.
This is an opensource project where you are invited to contribute and help evolve the pricefeed as we go.