Skip to content

Instantly share code, notes, and snippets.

@LinuxIsCool
Created April 26, 2024 17:53
Show Gist options
  • Save LinuxIsCool/e62359b4cb7d89353de0b49cc23abe9d to your computer and use it in GitHub Desktop.
Save LinuxIsCool/e62359b4cb7d89353de0b49cc23abe9d to your computer and use it in GitHub Desktop.
Simple data generator with streamz
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