jasonlib-dev 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jasonlib/__init__.py +53 -0
- jasonlib/_calculator.py +248 -0
- jasonlib/_math.py +52 -0
- jasonlib/_models.py +62 -0
- jasonlib/_numba_kernels.py +195 -0
- jasonlib/_pivot_analysis.py +308 -0
- jasonlib/_pivot_models.py +45 -0
- jasonlib/_trading_calendar.py +93 -0
- jasonlib/_trend_analysis.py +634 -0
- jasonlib/_trend_models.py +165 -0
- jasonlib_dev-0.1.0.dist-info/METADATA +10 -0
- jasonlib_dev-0.1.0.dist-info/RECORD +13 -0
- jasonlib_dev-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Trend analysis data models, enums, and constants."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from pydantic import BaseModel, ConfigDict
|
|
11
|
+
|
|
12
|
+
from jasonlib._models import JInterval
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TrendFunction(str, Enum):
|
|
16
|
+
"""Available trend score functions.
|
|
17
|
+
|
|
18
|
+
Each member's value is the human-readable score name used as
|
|
19
|
+
DataFrame column headers and display labels.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
LOG_RETURNS = "Log Returns"
|
|
23
|
+
Z_SCORE_ABOVE_THRESHOLD = "Z-Score > Threshold"
|
|
24
|
+
Z_SCORE_LOW_VOL = "Z-Score Low Vol"
|
|
25
|
+
AVG_Z_DIFF = "Avg Z-Diff"
|
|
26
|
+
Z_DIFF_ABOVE_THRESHOLD = "Z-Diff > Threshold"
|
|
27
|
+
PIVOTS_DIFFERENCE = "Pivots Difference"
|
|
28
|
+
TIME_SINCE_PIVOTS = "Time Since Pivots"
|
|
29
|
+
OBV_MOMENTUM = "OBV Momentum"
|
|
30
|
+
TREND_EFFICIENCY = "Trend Efficiency"
|
|
31
|
+
VOL_RETURN_CORRELATION = "Vol-Return Correlation"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class InsufficientDataError(Exception):
|
|
35
|
+
"""Raised when there is not enough data to compute trend analysis."""
|
|
36
|
+
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class BaseModelWithPandasFields(BaseModel):
|
|
41
|
+
"""Base model that allows pandas types as fields."""
|
|
42
|
+
|
|
43
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CoinDataset(BaseModelWithPandasFields):
|
|
47
|
+
"""Input container for a single coin's data.
|
|
48
|
+
|
|
49
|
+
Attributes:
|
|
50
|
+
coin: Coin identifier (e.g. "BTCUSDT").
|
|
51
|
+
klines_df: OHLC DataFrame with columns: open, high, low, close, volume.
|
|
52
|
+
DatetimeIndex, UTC-aware.
|
|
53
|
+
jason_df: JASON features DataFrame with columns: high_z, low_z, high_vol,
|
|
54
|
+
low_vol, high_days, low_days, high_pivot, low_pivot.
|
|
55
|
+
DatetimeIndex, UTC-aware.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
coin: str
|
|
59
|
+
klines_df: pd.DataFrame
|
|
60
|
+
jason_df: pd.DataFrame
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class PlotWindow(BaseModel):
|
|
64
|
+
"""Chart plot window time range."""
|
|
65
|
+
|
|
66
|
+
label: str
|
|
67
|
+
start_timestamp: datetime
|
|
68
|
+
end_timestamp: datetime
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class SummaryMetric(BaseModel):
|
|
72
|
+
"""A labelled metric value for market trend summary."""
|
|
73
|
+
|
|
74
|
+
label: str
|
|
75
|
+
value: float
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class MarketTrendSummary(BaseModel):
|
|
79
|
+
"""Market-wide trend summary with current value and historical deltas."""
|
|
80
|
+
|
|
81
|
+
market_trend: SummaryMetric
|
|
82
|
+
delta_24h: SummaryMetric
|
|
83
|
+
delta_3d: SummaryMetric
|
|
84
|
+
delta_7d: SummaryMetric
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class CoinSeries(BaseModelWithPandasFields):
|
|
88
|
+
"""Normalized price series for a single coin in a chart.
|
|
89
|
+
|
|
90
|
+
Attributes:
|
|
91
|
+
coin: Coin identifier.
|
|
92
|
+
average_score: The coin's average trend score.
|
|
93
|
+
series: Datetime-indexed pandas Series of normalized prices (base 100).
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
coin: str
|
|
97
|
+
average_score: float
|
|
98
|
+
series: pd.Series
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class ChartData(BaseModelWithPandasFields):
|
|
102
|
+
"""Chart payload with title and coin series."""
|
|
103
|
+
|
|
104
|
+
title: str
|
|
105
|
+
subtitle: str
|
|
106
|
+
series: list[CoinSeries]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class TrendCharts(BaseModelWithPandasFields):
|
|
110
|
+
"""Leader and lagger chart data."""
|
|
111
|
+
|
|
112
|
+
spot_price_leaders: ChartData
|
|
113
|
+
spot_price_laggers: ChartData
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class TrendAnalysisResult(BaseModelWithPandasFields):
|
|
117
|
+
"""Complete result of a trend analysis computation.
|
|
118
|
+
|
|
119
|
+
Attributes:
|
|
120
|
+
start_date: Analysis window start (YYYY-MM-DD).
|
|
121
|
+
end_date: Analysis window end (YYYY-MM-DD).
|
|
122
|
+
interval: Candle interval used.
|
|
123
|
+
generated_at: Timestamp when the analysis was generated.
|
|
124
|
+
as_of: Timestamp of the most recent data point.
|
|
125
|
+
top_n: Number of top/bottom coins in charts.
|
|
126
|
+
plot_window: Chart time range.
|
|
127
|
+
summary: Market-wide trend summary.
|
|
128
|
+
charts: Leader and lagger charts.
|
|
129
|
+
ranking: DataFrame with columns for price changes, rank deltas,
|
|
130
|
+
Average Score, and individual trend function scores.
|
|
131
|
+
Index is coin identifiers.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
start_date: str
|
|
135
|
+
end_date: str
|
|
136
|
+
interval: JInterval
|
|
137
|
+
generated_at: datetime
|
|
138
|
+
as_of: datetime
|
|
139
|
+
top_n: int
|
|
140
|
+
plot_window: PlotWindow
|
|
141
|
+
summary: MarketTrendSummary
|
|
142
|
+
charts: TrendCharts
|
|
143
|
+
ranking: pd.DataFrame
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
TREND_COLUMN_LABELS: dict[str, str] = {
|
|
147
|
+
"coin": "Coin",
|
|
148
|
+
"last_spot": "Last Spot",
|
|
149
|
+
"change_24h": "24h Chg%",
|
|
150
|
+
"previous_change_24h": "Prev. 24h Chg%",
|
|
151
|
+
"change_7d": "7d Chg%",
|
|
152
|
+
"rank_delta_24h": "Rank Δ 24h",
|
|
153
|
+
"rank_delta_7d": "Rank Δ 7d",
|
|
154
|
+
"average_score": "Average Score",
|
|
155
|
+
"Log Returns": "Log Returns",
|
|
156
|
+
"Z-Score > Threshold": "Direct. Extension",
|
|
157
|
+
"Z-Score Low Vol": "Vol Cone Exp.",
|
|
158
|
+
"Avg Z-Diff": "Var. Diff.",
|
|
159
|
+
"Z-Diff > Threshold": "Adj. Var. Diff.",
|
|
160
|
+
"Pivots Difference": "Pivots Difference",
|
|
161
|
+
"Time Since Pivots": "Time in Trend",
|
|
162
|
+
"OBV Momentum": "OBV Momentum",
|
|
163
|
+
"Trend Efficiency": "Trend Efficiency",
|
|
164
|
+
"Vol-Return Correlation": "Vol-Return Correlation",
|
|
165
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jasonlib-dev
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Core JASON pivot-based feature computation library
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Requires-Dist: numba<0.63.0,>=0.62.1
|
|
7
|
+
Requires-Dist: numpy<2.4.0,>=2.3.0
|
|
8
|
+
Requires-Dist: pandas<4.0.0,>=3.0.1
|
|
9
|
+
Requires-Dist: pydantic<3.0.0,>=2.11.0
|
|
10
|
+
Requires-Dist: tqdm<5.0.0,>=4.67.1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
jasonlib/__init__.py,sha256=Jke729kx0ryB6fv4nbAmtqCEiVp_tPGKgtmhQFHmjIk,1434
|
|
2
|
+
jasonlib/_calculator.py,sha256=g7XhsH_swuOEguk3TncQorwb7mpTA2hHuivFAVODDjk,9010
|
|
3
|
+
jasonlib/_math.py,sha256=fi54oDdcOCp6Pr6AfXJhL64P6DuFypkNNrzR0vxmbEU,1709
|
|
4
|
+
jasonlib/_models.py,sha256=AUIh1GWr2YwbsSvsufJAD17XXidyZmCdUnKpilbUVWQ,1600
|
|
5
|
+
jasonlib/_numba_kernels.py,sha256=5qnc2N8xkqw-9vg3okyUhNB6YbBZNXf4P2UUrZN9SN4,7756
|
|
6
|
+
jasonlib/_pivot_analysis.py,sha256=cc8h61aPnQbBXwlnysmITnJ69SjdxRVW6hRQIDz2yuY,11875
|
|
7
|
+
jasonlib/_pivot_models.py,sha256=9PjurXotmNUyJROrq8PGWsaPZJgKrin90OfeGBCwsYA,1136
|
|
8
|
+
jasonlib/_trading_calendar.py,sha256=KgfvTg6VAQdy5tLJjnioBLy6bZJ4wF9TyJIylUSoYMA,2950
|
|
9
|
+
jasonlib/_trend_analysis.py,sha256=GV4iOLrR71gI2LoZt8CvX_b947cmW9YClvxWlYm3Z30,23469
|
|
10
|
+
jasonlib/_trend_models.py,sha256=Msgmj3rsvTMXvpebt2yHv3r5lBV7SOx6ngn4_mJs_uQ,4806
|
|
11
|
+
jasonlib_dev-0.1.0.dist-info/METADATA,sha256=CcO9000i6sQ5LJ8Dh0EODg5_u3xUCpl4FFQpan0YdRk,322
|
|
12
|
+
jasonlib_dev-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
13
|
+
jasonlib_dev-0.1.0.dist-info/RECORD,,
|