More detail on publishing streams using Python. See publish for alternatives.
Publishing using Python
pip install microprediction
If you are happy scheduling things yourself by whatever means, just use MicroWriter.set() to publish.
from microprediction import MicroWriter mw = MicroWriter(write_key='YOUR WRITE KEY HERE') mw.set(name='my_stream.json',value=3.14157)
Alternatively, use MicroPoll as illustrated by traffic_speed.py.
from microprediction.polling import MicroPoll from microprediction.live.nyc_traffic import verrazano_speed poller = MicroPoll(write_key='YOUR KEY HERE', name='verrazano_speed.json', func=verrazano_speed, interval=15) poller.run()
Here interval is in minutes. The argument
func should be a function returning
a float, and you can supply
func_args if needed.
It often pays to publish changes to live quantities, rather than absolute values, as this obviates the need for algorithms to precisely anticipate publishing times. The class MicroChangePoll can help and is illustrated by traffic_speed_changes.py. Note the suspension and resumption logic.
See faang.py for an illustration
of using slightly more advanced functionality provided in
the use of a
change_func to create streams that are functionals of changes
After you publish
- Be patient, keep publishing, and promote your stream.
- Retrieve predictions.
- View zscores to assess market efficiency.
Reminder: write keys
You can use a colab notebook to burn a new WRITE_KEY.
Edit this page.