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.6.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.6-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: snapfront_coherence-0.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 67e7c32a18df79c3fd63596381c20d54ace9c21dc867424d4685f9ba332f84e1
MD5 74011d0ab6a46c3bd19140dbd04011c1
BLAKE2b-256 702b5588757a9f2c8a3a753182864aafa90bbe7f28aee33072dfef62623a2d4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for snapfront_coherence-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 82765c6fd07e16b37b35d2827a35693cc89356d2dc1fad9c75f6b523688465c7
MD5 ba3c0e60a30544aeea9034629fff8784
BLAKE2b-256 9108ea24c9dc80da9d51820e7b769be87e88c349558e55f27e7859e8ae3b2f93

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