Skip to main content

Xarizmi

Xarizmi (read Khwarizmi) project is an educational project that contains tools for technical analysis in Python.

Installation

pip install xarizmi

If you encounter error in installation use Anaconda and then install ta-lib using: bash conda install -c conda-forge ta-lib and then install other packages.

Example

Build Candlestick

from xarizmi.candlestick import Candlestick
c = Candlestick(
    **{
        "open": 2,
        "low": 1,
        "high": 4,
        "close": 3,
    }
)

Portfolio Rebalancing

import datetime
from xarizmi.models.portfolio import Portfolio, PortfolioItem
from xarizmi.models.rebalance import (
    PortfolioAllocation, PortfolioAllocationItem, rebalance
)
from xarizmi.models.symbol import Symbol

now = datetime.datetime(2024, 11, 26)
btc = Symbol.build("BTC", "USD", "USD", "BINANCE")
eth = Symbol.build("ETH", "USD", "USD", "BINANCE")
sol = Symbol.build("SOL", "USD", "USD", "BINANCE")

# Current holdings
portfolio = Portfolio(items=[
    PortfolioItem(symbol=btc, market_value=90_000, quantity=0.9,  datetime=now),
    PortfolioItem(symbol=eth, market_value=30_000, quantity=10.0, datetime=now),
    PortfolioItem(symbol=sol, market_value=10_000, quantity=62.5, datetime=now),
])

# Desired allocation
target = PortfolioAllocation(items=[
    PortfolioAllocationItem(symbol=btc, weight=0.50),
    PortfolioAllocationItem(symbol=eth, weight=0.30),
    PortfolioAllocationItem(symbol=sol, weight=0.20),
])

result = rebalance(portfolio, target)

for item in result.to_sell():
    print(f"SELL {item.symbol.to_string()}: ${-item.delta_market_value:,.0f}")
# SELL BTC-USD: $25,000

for item in result.to_buy():
    print(f"BUY  {item.symbol.to_string()}: ${item.delta_market_value:,.0f}")
# BUY  ETH-USD: $9,000
# BUY  SOL-USD: $16,000

See examples/rebalance.py for the full runnable script.

Indicators

OBV Indicator

from xarizmi.candlestick import CandlestickChart
from xarizmi.ta.obv import OBVIndicator

# assuming btc_usdt_monthly_data is defined (similar to tests/conftest.py)
c = CandlestickChart.model_validate({"candles": btc_usdt_monthly_data})

obv_indicator = OBVIndicator(candlestick_chart=c, volume='amount')
obv_indicator.compute()
print(obv_indicator.indicator_data)
obv_indicator.plot()

Metadata

Release files for xarizmi 0.18.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 xarizmi 0.18.0
File Size Uploaded Provenance Actions
xarizmi-0.18.0.tar.gz 48.2 kB Without provenance Details for xarizmi-0.18.0.tar.gz

Built distribution (wheel)

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

Total release size: 115.9 kB

Release files / xarizmi-0.18.0.tar.gz

Download URL xarizmi-0.18.0.tar.gz
Size 48.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2e00ed8100973e7124211c0f30d973ce67ba4fbe4a277e38e9acf96a897fbc4f
BLAKE2b-256 checksum
How to use checksums
af107fa807d2f9f0558edea38e39cbb2c227b2d5438e1ba823b8db449ba7cf33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / xarizmi-0.18.0-py3-none-any.whl

Download URL xarizmi-0.18.0-py3-none-any.whl
Size 67.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
138b71d3341c818365ee3804fdb56e07f2a720521792d9735d9f2478a154b678
BLAKE2b-256 checksum
How to use checksums
9a8765048151aff9d7e4236bc390b68b4e2cc7ee08ae14440b38c30661a6cb4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for xarizmi 0.18.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.18.0 This release

2 release files No provenance

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