Skip to main content

Snapfront Coherence Python SDK: WCT_phi and coherence-band client with retries, timeouts, and typed errors.

Project description

Snapfront Coherence — Python SDK

Minimal client for the local Coherence API.

Install

pip install -e .

Usage

from snapfront_coherence import Client, RateLimitError

client = Client(api_key="MYSECRETKEY", base_url="http://127.0.0.1:8000")
res = client.wct_phi([0.8, 1.1, -0.5])
print(res["wct_phi"], res["band"])

Mini examples

from snapfront_coherence import Client
c = Client(api_key="MYSECRETKEY", base_url="http://127.0.0.1:8000")
prices = [100, 101, 98, 99, 103, 102]
rets = [prices[i]-prices[i-1] for i in range(1,len(prices))]
resp = c.wct_phi(rets)
print(resp["wct_phi"], resp["band"])
Client.save_receipt(resp, "logs/example_markets_receipt.json")
lines = ["alpha", "alpha beta", "alpha beta gamma", "alpha"]
lengths = list(map(len, lines))
resp = c.score_series(lengths, mode="absolute", window=None)[0]
print(resp["wct_phi"], resp["band"])
temps = [20.0, 20.2, 19.7, 19.8, 20.1, 20.4, 20.0]
resp_list = c.score_series(temps, mode="relative", window=3)
print([r["band"] for r in resp_list])

Receipts

import json
payload = {"deltas":[0.8,1.1,-0.5]}
body_bytes = json.dumps(payload).encode("utf-8")
resp = client.wct_phi(payload["deltas"])
ok = Client.verify_hashes(resp, request_bytes=body_bytes,
                          response_bytes=json.dumps(resp).encode("utf-8"))
print("receipt ok?", ok)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snapfront_coherence-0.2.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snapfront_coherence-0.2.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file snapfront_coherence-0.2.2.tar.gz.

File metadata

  • Download URL: snapfront_coherence-0.2.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for snapfront_coherence-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9a1b5ec86190ae7b535de6102c5e6e68652eaeecd6fb703712899f19dac9cc06
MD5 80b7cc0a85887cf60ea6c8fc522fb4fe
BLAKE2b-256 5ec89143f6c5f833ab6f8167e713499ed47f80fe848b131b486fbc48f98b5abf

See more details on using hashes here.

File details

Details for the file snapfront_coherence-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for snapfront_coherence-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e785fe960bb56fb0fe55e37ccc99445f16e79d63ea8caf8c7846d7c9f640117e
MD5 339c2db6d9e47e419f70161333efa84a
BLAKE2b-256 4b6a11f244a88dd5f17246314c5e80b318781f61e491e9f09b4963b76563c602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page