reportify-sdk 0.3.2__tar.gz → 0.3.4__tar.gz
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.
- {reportify_sdk-0.3.2/reportify_sdk.egg-info → reportify_sdk-0.3.4}/PKG-INFO +4 -4
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/README.md +3 -3
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/pyproject.toml +1 -1
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/__init__.py +1 -1
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/client.py +1 -1
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/docs.py +2 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/quant.py +58 -14
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/stock.py +15 -4
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4/reportify_sdk.egg-info}/PKG-INFO +4 -4
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/LICENSE +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/agent.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/channels.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/chat.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/concepts.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/exceptions.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/kb.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/search.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/timeline.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk/user.py +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk.egg-info/SOURCES.txt +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk.egg-info/dependency_links.txt +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk.egg-info/requires.txt +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/reportify_sdk.egg-info/top_level.txt +0 -0
- {reportify_sdk-0.3.2 → reportify_sdk-0.3.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: reportify-sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Python SDK for Reportify API - Financial data and document search
|
|
5
5
|
Author-email: Reportify <support@reportify.cn>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -133,7 +133,7 @@ df = client.quant.compute_indicators(["000001"], "MACD()")
|
|
|
133
133
|
|
|
134
134
|
# Screen stocks by formula
|
|
135
135
|
stocks = client.quant.screen(formula="RSI(14) < 30")
|
|
136
|
-
stocks = client.quant.screen(formula="CROSS(MA(5), MA(20))")
|
|
136
|
+
stocks = client.quant.screen(formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))")
|
|
137
137
|
|
|
138
138
|
# Get OHLCV data
|
|
139
139
|
ohlcv = client.quant.ohlcv("000001", start_date="2024-01-01")
|
|
@@ -144,8 +144,8 @@ result = client.quant.backtest(
|
|
|
144
144
|
start_date="2023-01-01",
|
|
145
145
|
end_date="2024-01-01",
|
|
146
146
|
symbol="000001",
|
|
147
|
-
entry_formula="CROSS(MA(5), MA(20))",
|
|
148
|
-
exit_formula="CROSSDOWN(MA(5), MA(20))"
|
|
147
|
+
entry_formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))",
|
|
148
|
+
exit_formula="CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))"
|
|
149
149
|
)
|
|
150
150
|
print(f"Total Return: {result['total_return_pct']:.2%}")
|
|
151
151
|
```
|
|
@@ -104,7 +104,7 @@ df = client.quant.compute_indicators(["000001"], "MACD()")
|
|
|
104
104
|
|
|
105
105
|
# Screen stocks by formula
|
|
106
106
|
stocks = client.quant.screen(formula="RSI(14) < 30")
|
|
107
|
-
stocks = client.quant.screen(formula="CROSS(MA(5), MA(20))")
|
|
107
|
+
stocks = client.quant.screen(formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))")
|
|
108
108
|
|
|
109
109
|
# Get OHLCV data
|
|
110
110
|
ohlcv = client.quant.ohlcv("000001", start_date="2024-01-01")
|
|
@@ -115,8 +115,8 @@ result = client.quant.backtest(
|
|
|
115
115
|
start_date="2023-01-01",
|
|
116
116
|
end_date="2024-01-01",
|
|
117
117
|
symbol="000001",
|
|
118
|
-
entry_formula="CROSS(MA(5), MA(20))",
|
|
119
|
-
exit_formula="CROSSDOWN(MA(5), MA(20))"
|
|
118
|
+
entry_formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))",
|
|
119
|
+
exit_formula="CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))"
|
|
120
120
|
)
|
|
121
121
|
print(f"Total Return: {result['total_return_pct']:.2%}")
|
|
122
122
|
```
|
|
@@ -39,6 +39,8 @@ class QuantModule:
|
|
|
39
39
|
"""
|
|
40
40
|
Get list of available technical indicators
|
|
41
41
|
|
|
42
|
+
All indicators are functions and require parentheses when used (e.g., MA(CLOSE, 20), RSI(14), MACD()).
|
|
43
|
+
|
|
42
44
|
Returns:
|
|
43
45
|
List of indicator definitions with name, description, and fields
|
|
44
46
|
|
|
@@ -62,6 +64,10 @@ class QuantModule:
|
|
|
62
64
|
"""
|
|
63
65
|
Compute indicator values for given symbols
|
|
64
66
|
|
|
67
|
+
Variables vs Functions:
|
|
68
|
+
- Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME (aliases: C, O, H, L, V, VOL)
|
|
69
|
+
- Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), RSI(14), MACD(), etc.
|
|
70
|
+
|
|
65
71
|
Args:
|
|
66
72
|
symbols: List of stock codes (e.g., ["000001", "600519"])
|
|
67
73
|
formula: Indicator formula (e.g., "RSI(14)", "MACD()", "MACD(12,26,9)")
|
|
@@ -84,6 +90,9 @@ class QuantModule:
|
|
|
84
90
|
>>> # KDJ indicator
|
|
85
91
|
>>> df = client.quant.compute_indicators(["000001"], "KDJ(9,3,3)")
|
|
86
92
|
>>> print(df[["symbol", "date", "k", "d", "j"]])
|
|
93
|
+
|
|
94
|
+
>>> # Standard deviation
|
|
95
|
+
>>> df = client.quant.compute_indicators(["000001"], "STD(CLOSE, 20)")
|
|
87
96
|
"""
|
|
88
97
|
data: dict[str, Any] = {
|
|
89
98
|
"symbols": symbols,
|
|
@@ -106,11 +115,15 @@ class QuantModule:
|
|
|
106
115
|
"""
|
|
107
116
|
Get list of available factors (variables and functions)
|
|
108
117
|
|
|
118
|
+
Variables vs Functions:
|
|
119
|
+
- Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME, PE_TTM, ROE_TTM, etc.
|
|
120
|
+
- Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
121
|
+
|
|
109
122
|
Returns factors organized by level:
|
|
110
|
-
- Level 0 Variables: CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
111
|
-
- Level 0 Functions: MA, EMA, REF, HHV, LLV, STD, etc.
|
|
112
|
-
- Level 1 Functions: CROSS, COUNT, EVERY, etc.
|
|
113
|
-
- Level 2 Functions: MACD, KDJ, RSI, BOLL, etc.
|
|
123
|
+
- Level 0 Variables: CLOSE, OPEN, HIGH, LOW, VOLUME (price data, no parentheses)
|
|
124
|
+
- Level 0 Functions: MA(), EMA(), REF(), HHV(), LLV(), STD(), etc. (require parentheses)
|
|
125
|
+
- Level 1 Functions: CROSS(), COUNT(), EVERY(), etc. (require parentheses)
|
|
126
|
+
- Level 2 Functions: MACD(), KDJ(), RSI(), BOLL(), PE(), ROE(), etc. (require parentheses)
|
|
114
127
|
|
|
115
128
|
Returns:
|
|
116
129
|
List of factor definitions
|
|
@@ -136,6 +149,10 @@ class QuantModule:
|
|
|
136
149
|
|
|
137
150
|
Uses Mai-language syntax compatible with TongDaXin/TongHuaShun.
|
|
138
151
|
|
|
152
|
+
Variables vs Functions:
|
|
153
|
+
- Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
154
|
+
- Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
155
|
+
|
|
139
156
|
Args:
|
|
140
157
|
symbols: List of stock codes
|
|
141
158
|
formula: Factor formula using Mai-language syntax
|
|
@@ -154,10 +171,14 @@ class QuantModule:
|
|
|
154
171
|
>>> df = client.quant.compute_factors(["000001"], "MACD().dif")
|
|
155
172
|
|
|
156
173
|
>>> # Close above 20-day MA (boolean)
|
|
157
|
-
>>> df = client.quant.compute_factors(["000001"], "CLOSE > MA(20)")
|
|
174
|
+
>>> df = client.quant.compute_factors(["000001"], "CLOSE > MA(CLOSE, 20)")
|
|
158
175
|
|
|
159
176
|
>>> # Deviation from MA20 in percent
|
|
160
|
-
>>> df = client.quant.compute_factors(["000001"], "(CLOSE - MA(20)) / MA(20) * 100")
|
|
177
|
+
>>> df = client.quant.compute_factors(["000001"], "(CLOSE - MA(CLOSE, 20)) / MA(CLOSE, 20) * 100")
|
|
178
|
+
|
|
179
|
+
>>> # Fundamental factors (note: functions require parentheses)
|
|
180
|
+
>>> df = client.quant.compute_factors(["000001"], "PE()")
|
|
181
|
+
>>> df = client.quant.compute_factors(["000001"], "ROE()")
|
|
161
182
|
|
|
162
183
|
Supported Operators:
|
|
163
184
|
- Comparison: >, <, >=, <=, ==, !=
|
|
@@ -165,12 +186,16 @@ class QuantModule:
|
|
|
165
186
|
- Logical OR: | (NOT "OR")
|
|
166
187
|
- Arithmetic: +, -, *, /
|
|
167
188
|
|
|
168
|
-
Supported Variables:
|
|
189
|
+
Supported Variables (no parentheses):
|
|
169
190
|
- CLOSE, C: Close price
|
|
170
191
|
- OPEN, O: Open price
|
|
171
192
|
- HIGH, H: High price
|
|
172
193
|
- LOW, L: Low price
|
|
173
194
|
- VOLUME, V, VOL: Volume
|
|
195
|
+
|
|
196
|
+
Supported Functions (require parentheses):
|
|
197
|
+
- Technical: MA(), EMA(), RSI(), MACD(), BOLL(), etc.
|
|
198
|
+
- Fundamental: PE(), PB(), ROE(), ROA(), etc.
|
|
174
199
|
"""
|
|
175
200
|
data: dict[str, Any] = {
|
|
176
201
|
"symbols": symbols,
|
|
@@ -199,6 +224,10 @@ class QuantModule:
|
|
|
199
224
|
Returns stocks where the formula evaluates to True (for boolean formulas)
|
|
200
225
|
or non-null (for numeric formulas).
|
|
201
226
|
|
|
227
|
+
Variables vs Functions:
|
|
228
|
+
- Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
229
|
+
- Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
230
|
+
|
|
202
231
|
Args:
|
|
203
232
|
formula: Screening formula using Mai-language syntax
|
|
204
233
|
market: Stock market ("cn", "hk", "us"), default "cn"
|
|
@@ -213,14 +242,17 @@ class QuantModule:
|
|
|
213
242
|
>>> stocks = client.quant.screen(formula="RSI(14) < 30")
|
|
214
243
|
|
|
215
244
|
>>> # Golden cross
|
|
216
|
-
>>> stocks = client.quant.screen(formula="CROSS(MA(5), MA(10))")
|
|
245
|
+
>>> stocks = client.quant.screen(formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 10))")
|
|
217
246
|
|
|
218
247
|
>>> # Uptrend
|
|
219
|
-
>>> stocks = client.quant.screen(formula="(CLOSE > MA(20)) & (MA(20) > MA(60))")
|
|
248
|
+
>>> stocks = client.quant.screen(formula="(CLOSE > MA(CLOSE, 20)) & (MA(CLOSE, 20) > MA(CLOSE, 60))")
|
|
220
249
|
|
|
221
250
|
>>> # Above upper Bollinger Band
|
|
222
251
|
>>> stocks = client.quant.screen(formula="CLOSE > BOLL(20, 2).upper")
|
|
223
252
|
|
|
253
|
+
>>> # Fundamental screening (note: functions require parentheses)
|
|
254
|
+
>>> stocks = client.quant.screen(formula="(PE() < 20) & (ROE() > 0.15)")
|
|
255
|
+
|
|
224
256
|
>>> # Screen specific stocks
|
|
225
257
|
>>> stocks = client.quant.screen(
|
|
226
258
|
... formula="RSI(14) < 30",
|
|
@@ -338,6 +370,10 @@ class QuantModule:
|
|
|
338
370
|
"""
|
|
339
371
|
Execute strategy backtest
|
|
340
372
|
|
|
373
|
+
Variables vs Functions:
|
|
374
|
+
- Variables (no parentheses): CLOSE, OPEN, HIGH, LOW, VOLUME
|
|
375
|
+
- Functions (TongDaXin style: col first, n second): MA(CLOSE, 20), PE(), ROE(), RSI(14), etc.
|
|
376
|
+
|
|
341
377
|
Args:
|
|
342
378
|
start_date: Backtest start date (YYYY-MM-DD)
|
|
343
379
|
end_date: Backtest end date (YYYY-MM-DD)
|
|
@@ -350,7 +386,7 @@ class QuantModule:
|
|
|
350
386
|
stop_loss: Stop loss setting (default: 0.0, no stop loss)
|
|
351
387
|
sizer_percent: Position percentage (default: 99%)
|
|
352
388
|
auto_close: Auto close positions (default: True)
|
|
353
|
-
labels: Label dict for returning extra indicator values, e.g. {"up": "CROSS(MA(20), MA(60))"}
|
|
389
|
+
labels: Label dict for returning extra indicator values, e.g. {"up": "CROSS(MA(CLOSE, 20), MA(CLOSE, 60))"}
|
|
354
390
|
|
|
355
391
|
Returns:
|
|
356
392
|
Backtest results including:
|
|
@@ -371,7 +407,7 @@ class QuantModule:
|
|
|
371
407
|
... start_date="2023-01-01",
|
|
372
408
|
... end_date="2024-01-01",
|
|
373
409
|
... symbol="000001",
|
|
374
|
-
... entry_formula="CROSS(MA(5), MA(20))", # Buy when MA5 crosses above MA20
|
|
410
|
+
... entry_formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))", # Buy when MA5 crosses above MA20
|
|
375
411
|
... initial_cash=100000
|
|
376
412
|
... )
|
|
377
413
|
>>> print(f"Total Return: {result['total_return_pct']:.2%}")
|
|
@@ -383,8 +419,16 @@ class QuantModule:
|
|
|
383
419
|
... start_date="2023-01-01",
|
|
384
420
|
... end_date="2024-01-01",
|
|
385
421
|
... symbol="000001",
|
|
386
|
-
... entry_formula="CROSS(MA(5), MA(20))", # Buy signal
|
|
387
|
-
... exit_formula="CROSSDOWN(MA(5), MA(20))" # Sell signal
|
|
422
|
+
... entry_formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))", # Buy signal
|
|
423
|
+
... exit_formula="CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))" # Sell signal
|
|
424
|
+
... )
|
|
425
|
+
|
|
426
|
+
>>> # Fundamental screening backtest (note: functions require parentheses)
|
|
427
|
+
>>> result = client.quant.backtest(
|
|
428
|
+
... start_date="2023-01-01",
|
|
429
|
+
... end_date="2024-01-01",
|
|
430
|
+
... symbol="000001",
|
|
431
|
+
... entry_formula="(PE() < 20) & (ROE() > 0.15)",
|
|
388
432
|
... )
|
|
389
433
|
|
|
390
434
|
>>> # With custom labels for analysis
|
|
@@ -394,7 +438,7 @@ class QuantModule:
|
|
|
394
438
|
... symbol="000001",
|
|
395
439
|
... entry_formula="RSI(14) < 30",
|
|
396
440
|
... exit_formula="RSI(14) > 70",
|
|
397
|
-
... labels={"rsi": "RSI(14)", "ma20": "MA(20)"}
|
|
441
|
+
... labels={"rsi": "RSI(14)", "ma20": "MA(CLOSE, 20)"}
|
|
398
442
|
... )
|
|
399
443
|
"""
|
|
400
444
|
data = {
|
|
@@ -591,7 +591,14 @@ class StockModule:
|
|
|
591
591
|
elif isinstance(data, dict):
|
|
592
592
|
# Handle nested data structures
|
|
593
593
|
if "data" in data:
|
|
594
|
-
|
|
594
|
+
inner_data = data["data"]
|
|
595
|
+
if isinstance(inner_data, list):
|
|
596
|
+
df = pd.DataFrame(inner_data)
|
|
597
|
+
elif isinstance(inner_data, dict):
|
|
598
|
+
# If data is a dict with scalar values, wrap it in a list
|
|
599
|
+
df = pd.DataFrame([inner_data])
|
|
600
|
+
else:
|
|
601
|
+
df = pd.DataFrame([data])
|
|
595
602
|
elif "items" in data:
|
|
596
603
|
df = pd.DataFrame(data["items"])
|
|
597
604
|
elif "records" in data:
|
|
@@ -606,8 +613,12 @@ class StockModule:
|
|
|
606
613
|
date_columns = ["date", "period", "fiscal_date", "report_date"]
|
|
607
614
|
for col in date_columns:
|
|
608
615
|
if col in df.columns:
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
616
|
+
try:
|
|
617
|
+
df[col] = pd.to_datetime(df[col])
|
|
618
|
+
df = df.set_index(col)
|
|
619
|
+
break
|
|
620
|
+
except (ValueError, TypeError):
|
|
621
|
+
# Skip columns that can't be converted to datetime
|
|
622
|
+
continue
|
|
612
623
|
|
|
613
624
|
return df
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: reportify-sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: Python SDK for Reportify API - Financial data and document search
|
|
5
5
|
Author-email: Reportify <support@reportify.cn>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -133,7 +133,7 @@ df = client.quant.compute_indicators(["000001"], "MACD()")
|
|
|
133
133
|
|
|
134
134
|
# Screen stocks by formula
|
|
135
135
|
stocks = client.quant.screen(formula="RSI(14) < 30")
|
|
136
|
-
stocks = client.quant.screen(formula="CROSS(MA(5), MA(20))")
|
|
136
|
+
stocks = client.quant.screen(formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))")
|
|
137
137
|
|
|
138
138
|
# Get OHLCV data
|
|
139
139
|
ohlcv = client.quant.ohlcv("000001", start_date="2024-01-01")
|
|
@@ -144,8 +144,8 @@ result = client.quant.backtest(
|
|
|
144
144
|
start_date="2023-01-01",
|
|
145
145
|
end_date="2024-01-01",
|
|
146
146
|
symbol="000001",
|
|
147
|
-
entry_formula="CROSS(MA(5), MA(20))",
|
|
148
|
-
exit_formula="CROSSDOWN(MA(5), MA(20))"
|
|
147
|
+
entry_formula="CROSS(MA(CLOSE, 5), MA(CLOSE, 20))",
|
|
148
|
+
exit_formula="CROSSDOWN(MA(CLOSE, 5), MA(CLOSE, 20))"
|
|
149
149
|
)
|
|
150
150
|
print(f"Total Return: {result['total_return_pct']:.2%}")
|
|
151
151
|
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|