Skip to main content

Utilities for intrinsic time decomposition and fractal event analysis

Project description

IntrinsicTime

Utilities for decomposing intrinsic time events and analyzing fractal scaling behavior in price or signal data.

This package provides:

  • dcos_core: A Directional Change and Overshoot (DcOS) event detector.
  • dcos_fractal: Tools for fractal scaling and multi-threshold analysis.
  • dcos_plot: Plotly visualization for interactive fractal plots.

Installation

From PyPi

pip install IntrinsicTime

From GitHub

pip install git+https://github.com/THouwe/IntrinsicTime.git

Local Install

git clone https://github.com/THouwe/IntrinsicTime.git
cd IntrinsicTime
pip install -e .

Dependencies

See requirements.txt.


Overview

DcOS events are first‑passage moves of size δ in log space

Robust power‑law behaviour can be observed for many phenomena. For instance, Intrinsic Time event density of BTCUSDT price ticks scale linearly with DcOS δ threshold in log space (cit), consistently with first‑passage theory (cit) plus market microstructure. However, this is the case only within a given range of δ thresholds, as the power law may brake at 'extremely low' or 'extremely high' δs.

For small δs, issues relate to microstructure noise (tick size, latency, and irregular sampling inject high‑frequency mean reversion. This raises event frequency toward a ceiling and flattens the log–log curve) and discretization limits (time and sample - e.g., price - granularity cap how many distinct first‑passage events you can observe).

For large δs, issues relate to data scarcity: too few events reduce fit quality and increase variance.

Fractal brakepoint formalization

Compute local slopes (b(\delta)) with a sliding window (w) on ((\log \delta,\log f)). Mark the smallest δ where either (R^2 < R^2_{\min}) or (|\Delta b|) exceeds one standard error from adjacent windows. Your windowed method will return something close to δ ≈ 6e‑4 for this dataset if your visual read is correct.

Example Usage

import numpy as np
import pandas as pd
from IntrinsicTime.dcos_core import DcOS, Price, Sample
from IntrinsicTime.dcos_fractal import DcOS_fractal, DcOS_tests
from IntrinsicTime.dcos_plot import DcOS_plotter

# Example input DataFrame
df = pd.DataFrame(
    {
        "Timestamp": np.arange(1_000),
        "Price": 100 + np.cumsum(np.random.randn(1_000)),
    }
)

# Initialize and run the full fractal analysis
analyzer = DcOS_fractal(debugMode=True)
results, fit_region = analyzer.run(df)

# Display basic statistics
print(results[["threshold", "nDCtot", "nOStot", "nEVtot"]].head())
print("Fit region (δ_min_fit, δ_max_fit):", fit_region)

# Optional: analyze results
summary = DcOS_tests.analyze_dcos_results(
    results,
    event_sequences=results.attrs.get("event_sequences"),
    os_segments=results.attrs.get("os_segments"),
)

# Optional: interactive Plotly visualization
plotter = DcOS_plotter()
fig = plotter.fractal_plot(
    results,
    pt_constant=61.21,
    pt_tolerance=2.5,
    savePlots=False,
    save_png=False,
)
fig.show()

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

intrinsictime-0.1.4.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

intrinsictime-0.1.4-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file intrinsictime-0.1.4.tar.gz.

File metadata

  • Download URL: intrinsictime-0.1.4.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for intrinsictime-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0ec5ec4e939710ede3c15e60d70b6a8cff64eb223ef53de9fb5f55d1315dbc6c
MD5 965eaf0ad2318d2a9543d845af62273a
BLAKE2b-256 9e383768e81ec73c7f469bf110815a7447d8693957b9d0d59a159b987c0ebd73

See more details on using hashes here.

File details

Details for the file intrinsictime-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: intrinsictime-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for intrinsictime-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 74b63df0a61b6fbc9ca3f37960267ad3976138af62d895f8a8297fe26d9aa829
MD5 2932ca0bda6a7e15d78e2a032297776d
BLAKE2b-256 75cbd3ac7741e99cf8076970a85af22cf526dc10485d262f0bcdc180271e0c75

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