Receive real-time data from RTD (RealTimeData) servers in any Python program, without Excel. The same engine that powers calc-rtd for LibreOffice Calc, usable on its own.
pip install calc-rtd
Free, MIT license. Windows for real RTD servers; the simulated source runs anywhere. Python 3.9+.
from calc_rtd import RtdSession
with RtdSession() as rtd:
rtd.subscribe("Vendor.ProgID", ["ACME", "LAST"])
for update in rtd.updates():
print(update.value)Pick the one that fits your program. They can be mixed in the same session.
A loop that gets every change as it arrives.
for update in rtd.updates(timeout=30):
if update.error:
print("problem:", update.error)
else:
print(update.value)Each subscription keeps its most recent value.
acme = rtd.subscribe("calcrtd.sim", ["walk", "ACME", 38.5])
acme.wait(timeout=10) # first value
print(acme.value) # always the latestA function called for every update of one topic.
def on_price(update):
if update.value > 40:
print("ACME above 40:", update.value)
rtd.subscribe("calcrtd.sim", ["walk", "ACME", 38.5],
callback=on_price)
rtd.run_for(60)The ProgID calcrtd.sim is a simulated source built into the library: a clock, counters, random numbers and random walks. Every example uses it by default, so you can run them on any machine, then switch to your vendor's ProgID and topics.
rtd.subscribe("calcrtd.sim", ["clock"])
Paste a formula that works in Excel. It prints every update and exits with code 0 if any arrived:
python -m calc_rtd "=RTD(Vendor.ProgID;;ACME;LAST)" --seconds 30
Complete scripts, run by the project's tests on every commit.
print_updates.py | Print every update of formulas given on the command line. |
log_to_csv.py | Append time, topic and value to a CSV file. |
latest_values.py | Poll the latest values once a second. |
alert_callback.py | React to a value with a callback. |
to_pandas.py | Collect updates into a pandas DataFrame, one row per second. |