Created
April 26, 2024 17:53
-
-
Save LinuxIsCool/e62359b4cb7d89353de0b49cc23abe9d to your computer and use it in GitHub Desktop.
Simple data generator with streamz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from streamz import Stream | |
def market_step(market_inputs): | |
return {'market_movement': market_inputs['market_movement']} | |
def write(x): | |
print(x) | |
def f(n=5): | |
source = Stream(asynchronous=True) # Configure the stream for asynchronous operation | |
source.map(market_step).rate_limit(0.500).sink(write) | |
for x in range(n): | |
source.emit({'market_movement':x}) # Emit values into the stream | |
f(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment