AZPytest
A small Python backtesting toolkit: replay tick data from a CSV one row at a time, place simulated long/short trades, and run price analytics.
Setup
Requires Python 3.10+.
Install from PyPI:
pip install azpytest
Or straight from GitHub:
pip install git+https://github.com/vxvira/AZPytest.git
To work on it from a clone, install it editable along with pytest:
pip install -e . pytest
Usage
import AZPytest.handling as dh
cfg = dh.Configuration()
cfg.path = "data.csv"
cfg.tickSz = 0.25 # price increment of one tick
cfg.tickVal = 0.25 # money value of one tick, per contract
cfg.priceAlias = "price" # CSV column names
cfg.tsEventAlias = "ts_event"
cfg.tsRecvAlias = "ts_recv"
cfg.actionAlias = "action"
cfg.buildConfig()
handler = dh.Handling(cfg)
handler.tick() # read the next row
handler.addLong(1) # or addShort(n); adds change the net position
handler.tick()
handler.unrealizedPnl() # pnl of the open trade
handler.closeLong() # or closeShort()
handler.realizedPnl() # pnl of the most recently closed trade
addLong/addShort adjust the net position: the same side grows it, the opposite side shrinks it, reaching zero ends the trade, and crossing zero flips it into a new trade. The first opposite-side add logs a warning.
Every tick is recorded in handler.data (price, tsEvent, tsRecv, action lists) and handler.positionsData ([inTrade, unrealizedPnl, entryIdx] per tick).
Analytics
AZPytest/analytics has two classes that work on pandas Series:
PriceAnalytics(PriceSeries, VolumeSeries=None)
| Method | Returns |
|---|---|
ManipulatePriceSeries(new) |
swaps the price series |
ManipulateVolumeSeries(new) |
swaps the volume series |
returnExponentialMovingAverage(period) |
Series |
returnSimpleMovingAveraage(period) |
Series |
returnVolumeWeightedAveragePrice() |
Series (needs volume) |
returnOnBalanceVolume() |
Series (needs volume) |
returnVolumeProfile(bins=24, binSize=None) |
DataFrame: volume per price level (needs volume) |
returnPointOfControl(bins=24, binSize=None) |
float, the busiest price level (needs volume) |
returnValueArea(bins=24, binSize=None, pct=0.7) |
(low, high) floats (needs volume) |
returnBollingerBands(period=20, numStd=2) |
DataFrame: middle, upper, lower |
returnRelativeStrengthIndex(period=14) |
Series |
returnMACD(fast=12, slow=26, signal=9) |
DataFrame: macd, signal, histogram |
returnRateOfChange(period) |
Series |
Volume-dependent methods raise [fatal] if no VolumeSeries was given.
SetAnalytics(Series)
| Method | Returns |
|---|---|
ManipulateSeries(new) |
swaps the series |
returnRollingMovingAverage(period) |
Series |
returnZScore(period=None) |
Series (whole series if no period) |
returnPearsonCorrelation(other, period=None) |
float, or a Series if a period is given |
returnTanh() |
Series |
returnFisherTransform(period=None) |
Series |
returnSpreadBetweenSeries(other) |
Series, other - Series; the longer one is trimmed with a warning |
import pandas as pd
from AZPytest.analytics.PriceAnalytics import PriceAnalytics
pa = PriceAnalytics(pd.Series(handler.data.price))
pa.returnExponentialMovingAverage(20)
pa.returnRelativeStrengthIndex(14)
Tests
python -m pytest
License
MIT, see LICENSE.
Metadata
Release files for AZPytest 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| azpytest-0.1.0.tar.gz | 14.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| azpytest-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / azpytest-0.1.0.tar.gz
| Download URL | azpytest-0.1.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cc807e600b9aa30623ee45f4d923915a687b0d4fb9a28e34e84b5c01292881c
|
|
BLAKE2b-256 checksum How to use checksums |
aacc9704fe80c45bb6a998765e29b9f4365e5b62260770f6fd71648ed405f2d6
|
| 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 Sep 27, 2026.
Transparency logRelease files / azpytest-0.1.0-py3-none-any.whl
| Download URL | azpytest-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de5d6e0c3f6920ec4100cc7761a63d4808d9ba8b49f80091e9e8cd504436c3cf
|
|
BLAKE2b-256 checksum How to use checksums |
0d0063593e5a9bffd8ac06a9ce45d80954ea3616f2e3de88c34eb55cc05301dc
|
| 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 Sep 27, 2026.
Transparency log