[project]
name = 'zipline-refresh'
description = 'High-performance Pythonic backtesting engine with Apache Parquet storage'
readme = 'README.md'
dynamic = ["version"]

authors = [
    { name = 'Quantopian Inc' },
    { name = 'Stefan Jansen', email = 'pm@ml4trading.io' },
    { name = 'Kavout', email = 'hello@teleclaws.com' },
]
maintainers = [
    { name = 'Kai', email = 'hello@teleclaws.com' },
]

classifiers = [
    'Development Status :: 4 - Beta',
    'Natural Language :: English',
    'Programming Language :: Python',
    'Programming Language :: Python :: 3.10',
    'Programming Language :: Python :: 3.11',
    'Programming Language :: Python :: 3.12',
    'Programming Language :: Python :: 3.13',
    'Operating System :: OS Independent',
    'Intended Audience :: Science/Research',
    'Topic :: Office/Business :: Financial :: Investment',
    'Topic :: Scientific/Engineering :: Information Analysis',
    'Topic :: System :: Distributed Computing',
]

license = "Apache-2.0"
license-files = [
    "LICENSE",
]

requires-python = '>=3.10'
dependencies = [
    "numpy>=1.23.5; python_version<'3.12'",
    "numpy>=1.26.0; python_version>='3.12'",
    "numpy>=2.1; python_version>='3.13'",
    "pandas >=1.3.0,<3.0",
    'alembic >=0.7.7',
    'bottleneck >=1.0.0',
    'click >=4.0.0',
    'empyrical-reloaded >=0.5.7',
    'h5py >=2.7.1',
    'intervaltree >=2.1.0',
    'iso3166 >=2.1.1',
    'iso4217 >=1.6.20180829',
    'lru-dict >=1.1.4',
    'multipledispatch >=0.6.0',
    'networkx >=2.0',
    'numexpr >=2.6.1',
    'patsy >=0.4.0',
    'python-dateutil >=2.4.2',
    'pytz >=2018.5',
    'requests >=2.9.1',
    'scipy >=0.17.1',
    'six >=1.10.0',
    'sqlalchemy >=2',
    'statsmodels >=0.6.1',
    # ta-lib is not available for Numpy 2.0 => optional
    #    'ta-lib >=0.4.09',
    'tables >=3.4.3',
    'toolz >=0.8.2',
    'exchange-calendars >=4.2.4',
    'pyarrow >=14.0',
]

[project.urls]
homepage = 'https://labs.kavout.com'
repository = 'https://github.com/teleclaws/zipline-refresh'
documentation = 'https://github.com/teleclaws/zipline-refresh/tree/main/docs'

[build-system]
requires = [
    'setuptools>=42.0.0',
    "setuptools_scm[toml]>=6.2",
    'wheel>=0.36.0',
    'Cython>=0.29.21,<3.2.0',
    #    'Cython>=3',
    'numpy>=2.0.0 ; python_version>"3.9"',
    'numpy<2.0 ; python_version<="3.9"',
    #    'oldest-supported-numpy; python_version>="3.9"',
]
build-backend = 'setuptools.build_meta'

[project.optional-dependencies]
test = [
    'tox',
    'pytest>=7.2.0',
    'pytest-cov >=3.0.0',
    'pytest-xdist >=2.5.0',
    'pytest-timeout >=1.4.2',
    'parameterized >=0.6.1',
    'testfixtures >=4.1.2',
    'flake8 >=3.9.1',
    'matplotlib >=1.5.3',
    'responses >=0.9.0',
    'pandas-datareader >=0.2.1',
    #    'click <8.1.0',
    'click',
    'coverage',
    'pytest-rerunfailures',
    'Cython>=0.29.21,<3.2.0',
]

dev = [
    'pre-commit >=2.12.1',
    'Cython>=0.29.21',
    'ruff>=0.11.12',
    'mypy>=1.10.0',
]

docs = [
    'Cython',
    'Sphinx >=1.3.2',
    'numpydoc >=0.5.0',
    'sphinx-autobuild >=0.6.0',
    'pydata-sphinx-theme',
    'sphinx_markdown_tables',
    'm2r2',
]

[project.scripts]
zipline = 'zipline.__main__:main'

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.packages.find]
where = ['src']
exclude = ['tests*']

[tool.setuptools_scm]
write_to = "src/zipline/_version.py"
version_scheme = 'guess-next-dev'
local_scheme = 'dirty-tag'

[tool.setuptools.package-data]
"*" = [
    "*.pyi",
    "*.pyx",
    "*.pxi",
    "*.pxd",
]

[tool.pytest.ini_options]
pythonpath = ['.']
testpaths = 'tests'
filterwarnings = [
    'ignore::DeprecationWarning:pandas_datareader.compat',
]
addopts = [
    "--strict-markers",
    "--disable-warnings",
    "-v", # Verbose output
    "--tb=short", # Shorter traceback format
    "--durations=20", # Show 20 slowest tests
    "--maxfail=50", # Stop after 50 failures to prevent endless reruns
    "--ff", # Run failed tests first
]
# Add markers for better test organization
markers = [
    "slow: marks tests as slow (deselect with '-m \"not slow\"')",
    "integration: marks tests as integration tests",
    "unit: marks tests as unit tests",
]

[tool.cibuildwheel]
test-extras = "test"
test-command = "pytest -n auto --reruns 5 --dist=loadgroup --strict-markers --disable-warnings -q {project}/tests"
build-verbosity = 3
environment = "GITHUB_ACTIONS=true"

[tool.cibuildwheel.macos]
archs = [
    "x86_64",
    "arm64",
    "universal2",
]

[tool.cibuildwheel.linux]
archs = ["auto64"]

[tool.cibuildwheel.windows]
test-command = 'pytest -n auto -k "not daily_returns_is_special_case_of_returns" --reruns 5 --dist=loadgroup --strict-markers --disable-warnings {package}/tests'

[tool.black]
line-length = 88
target-version = [
    'py310',
    'py311',
    'py312',
]
exclude = '''
(
    asv_bench/env
  | \.egg
  | \.git
  | \.hg
  | _build
  | build
  | dist
  | setup.py
)
'''

[tool.ruff]
line-length = 88
target-version = "py312"

[tool.ruff.lint]
select = [
    "E",
    "W",
    "F",
    "I",
    "N",
    "D",
    "UP",
    "ANN",
    "S",
    "BLE",
    "B",
    "A",
    "C4",
    "ISC",
    "T20",
    "PYI",
    "PT",
    "Q",
    "SIM",
    "TID",
    "ARG",
    "RUF",
    "NPY201",
]
ignore = [
    "ANN204",
    "D203",
    "D212",
    "D213",
    "D415",
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.ruff.lint.extend-per-file-ignores]
"tests/**/*.py" = [
    # at least this three should be fine in tests:
    "S101", # asserts allowed in tests...
    "ARG", # Unused function args -> fixtures nevertheless are functionally relevant...
    "FBT", # Don't care about booleans as positional arguments in tests, e.g. via @pytest.mark.parametrize()
    # The below are debateable
    "PLR2004", # Magic value used in comparison, ...
    "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]

[tool.tox]
legacy_tox_ini = """
[tox]
envlist =
    py310-pandas{15,20,21,22,23}-numpy1
    py311-pandas{15,20,21,22,23}-numpy1
    py312-pandas{15,20,21,22,23}-numpy1
    py310-pandas{222,23}-numpy2{0,1,2}
    py311-pandas{222,23}-numpy2{0,1,2}
    py312-pandas{222,23}-numpy2{0,1,2}
    py313-pandas{222,23}-numpy2{2}

isolated_build = True
skip_missing_interpreters = True
minversion = 3.23.0

[gh-actions]
python =
    3.10: py310
    3.11: py311
    3.12: py312
    3.13: py313

[pytest_commands]
with_cov =
    pytest -n auto --reruns 2 --dist=loadgroup --strict-markers --disable-warnings  --tb=short --maxfail=30 --cov={toxinidir}/src --cov-report term --cov-report=xml --cov-report=html:htmlcov {toxinidir}/tests
without_cov =
    pytest -n auto --reruns 2 --dist=loadgroup --strict-markers --disable-warnings --tb=short --maxfail=20 {toxinidir}/tests
py313_specific =
    pytest -n auto --reruns 2 --dist=no --strict-markers --disable-warnings -v --tb=short --maxfail=10 --timeout=300 --durations=10 {toxinidir}/tests

# --- Base Test Environment ---
# This is the default configuration for all environments.
[testenv]
usedevelop = True
setenv =
    MPLBACKEND = Agg
passenv = GITHUB_ACTIONS

changedir = tmp
extras = test
deps =
    pandas15: pandas>=1.5.0,<1.6
    pandas20: pandas>=2.0,<2.1
    pandas21: pandas>=2.1,<2.2
    pandas22: pandas>=2.2,<2.3
    pandas222: pandas>=2.2.2,<2.3
    pandas23: pandas>=2.3,<2.4
    numpy1: numpy>=1.23.5,<2.0
    numpy20: numpy>=2.0,<2.1
    numpy21: numpy>=2.1,<2.2
    numpy22: numpy>=2.2,<2.3
# By default, all tests run with coverage.
commands = {[pytest_commands]with_cov}


# Special configuration for ALL Python 3.13 environments.
[testenv:py313-pandas{222,23}-numpy2{2}]
setenv =
    {[testenv]setenv}  # Inherit base setenv
    PYTHONHASHSEED = 0
    PYTHONFAULTHANDLER = 1
    PYTHONUNBUFFERED = 1
    PYTEST_CURRENT_TEST = 1
commands = {[pytest_commands]py313_specific}

# Disable coverage for ALL Python 3.11 environments due to IndexError bugs.
[testenv:py311-pandas{15,20,21,22,222,23}-numpy{1,20,21,22}]
commands = {[pytest_commands]without_cov}

# Disable coverage for pandas 1.5 on any python version.
[testenv:py{310,311,312,313}-pandas15-numpy{1,20,21,22}]
commands = {[pytest_commands]without_cov}

# Disable coverage for pandas 2.0 on any python version.
[testenv:py{310,311,312,313}-pandas{15,20}-numpy{1,20,21,22}]
commands = {[pytest_commands]without_cov}
"""
