Skip to main content

PORTIQA Python

portiqa is the dependency-free Python client for the PORTIQA Portfolio Analysis API. It sends typed portfolio inputs to POST https://portiqa.ai/evaluate and returns typed response models. All scoring and analysis stays on the PORTIQA service; this package contains no scoring logic.

Requirements

Installation

Install the official package from PyPI:

python -m pip install portiqa

For editable local development from a clone:

python -m pip install -e .

Quick start

Store the key outside your source code:

export PORTIQA_API_KEY="ptq_your_api_key"

PowerShell:

$env:PORTIQA_API_KEY = "ptq_your_api_key"

Then evaluate a portfolio:

from portiqa import EvaluationRequest, PortiqaClient, Position

client = PortiqaClient(timeout=20.0)
request = EvaluationRequest(
    risk_level="medium",
    cash_balance=5_000,
    positions=(
        Position(ticker="AAPL", market_value=25_000),
        Position(ticker="MSFT", market_value=22_000),
        Position(ticker="NVDA", market_value=8_000),
    ),
)

response = client.evaluate(request)
print(response.evaluation.score)
print(response.evaluation.status)

You can pass the key directly when an environment variable is not suitable:

client = PortiqaClient(api_key="ptq_your_api_key", timeout=10.0)

An explicit api_key takes precedence over PORTIQA_API_KEY. Never hard-code or commit a real key.

Models

Each Position requires a ticker and at least one of:

  • market_value: the value already known for the position; or
  • amount: the number of units, which PORTIQA combines with its latest available close price when market_value is absent.

risk_level accepts "low", "medium", or "high". Position values and the cash balance must be finite, non-negative numbers. Invalid local inputs raise ValidationError before any request is made.

Stable response fields are typed, while the complete server response remains available through response.raw and response.evaluation.raw. Newly added API fields are therefore accessible without waiting for an SDK release.

Errors and timeouts

All SDK exceptions inherit from PortiqaError:

Exception Meaning
ConfigurationError The API key or timeout is invalid.
ValidationError A request model is invalid.
APITimeoutError The configured timeout elapsed.
APIConnectionError The service could not be reached.
InvalidResponseError A success response was not valid PORTIQA JSON.
BadRequestError HTTP 400.
AuthenticationError HTTP 401.
SubscriptionError HTTP 402.
RequestTooLargeError HTTP 413.
RateLimitError HTTP 429.
ServerError HTTP 5xx.
APIStatusError Any other non-success HTTP status.
from portiqa import APITimeoutError, PortiqaError, RateLimitError

try:
    response = client.evaluate(request)
except RateLimitError as exc:
    print(f"Limit reached (HTTP {exc.status_code})")
except APITimeoutError:
    print("PORTIQA did not respond before the configured timeout")
except PortiqaError as exc:
    print(f"PORTIQA request failed: {exc}")

The timeout defaults to 20 seconds. The client does not retry automatically, leaving retry and backoff policy under the caller's control.

Development

The tests use standard-library mocks and never contact the live API:

python -m unittest discover -s tests -v

See the API reference, OpenAPI specification, and security policy for more information.

PORTIQA output is quantitative information, not investment advice. See the financial disclaimer.

License

Released under the MIT License.

Metadata

Release files for portiqa 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for portiqa 0.1.0
File Size Uploaded
portiqa-0.1.0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for portiqa 0.1.0
File Interpreter ABI Platform
portiqa-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / portiqa-0.1.0.tar.gz

Download URL portiqa-0.1.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
96df5a5b5c4857ca91724522b89b8639a2c7c42142326cb0466e031dc0e817f0
BLAKE2b-256 checksum
How to use checksums
bee7a3c150487a67cf66df844ebaceb8a712594e7ac67b2031f8203c89501bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release files / portiqa-0.1.0-py3-none-any.whl

Download URL portiqa-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75d7bad3284a673af23ef2bf045567417c1b389ac1fb24f4cb0b33ab1551fbef
BLAKE2b-256 checksum
How to use checksums
babe18094c5c66a877b9b827fb906d54686a0af11d962ac3b869c99371127a57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page