filtrix-cli 0.5.0__tar.gz → 0.6.0__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.
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/CHANGELOG.md +9 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/PKG-INFO +1 -1
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/pyproject.toml +1 -1
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/AGENTS.md +9 -7
- filtrix_cli-0.6.0/src/filtrix_cli/__init__.py +1 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/client.py +5 -3
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/market.py +70 -68
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/research.py +1 -1
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_market.py +185 -163
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_smoke.py +1 -1
- filtrix_cli-0.5.0/src/filtrix_cli/__init__.py +0 -1
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/.gitignore +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/LICENSE +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/README.md +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/__main__.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/auth.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/__init__.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/_helpers.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/account.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/authcmd.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/backtest.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/configcmd.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/filters.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/keys.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/live.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/llms.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/screen.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/commands/ticker.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/config.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/filters.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/output.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/render.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/src/filtrix_cli/state.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/__init__.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_auth.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_client.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_client_register.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_auth.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_backtest_screen.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_config.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_keys.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_live.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_llms.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_profile.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_read.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_register.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_cmd_research.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_config.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_filters.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_helpers.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_output.py +0 -0
- {filtrix_cli-0.5.0 → filtrix_cli-0.6.0}/tests/test_render.py +0 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 (2026-11-30)
|
|
4
|
+
|
|
5
|
+
- `filtrix gaps`: the statistics come from FILTRIX's own 1-minute bars since Nov 2016 for tickers in that
|
|
6
|
+
universe (`meta.source` `"filtrix_minute_bars"`), Trade-Ideas alert days otherwise. New `--events` also
|
|
7
|
+
lists every counted gap day (long output).
|
|
8
|
+
- `filtrix runs save --row-filter` help: it picks which rows are stored with the run; the run's statistics
|
|
9
|
+
always use all rows.
|
|
10
|
+
- Agent guide: events without minute bars are not simulated; `missing_minute_data` counts them.
|
|
11
|
+
|
|
3
12
|
## 0.5.0 (2026-11-11)
|
|
4
13
|
|
|
5
14
|
- A paper write the account worker has not answered within the server's 10 s wait comes back
|
|
@@ -14,7 +14,7 @@ Structured command-line access to the FILTRIX historical backtest engine.
|
|
|
14
14
|
- 3 not found
|
|
15
15
|
- 4 authentication required/failed
|
|
16
16
|
- 5 rate limited (retryable)
|
|
17
|
-
- 6 network/timeout, incl. `--wait` giving up on a job that is still running (retryable), or a paper command
|
|
17
|
+
- 6 network/timeout, incl. `--wait` giving up on a job that is still running (retryable), or a paper command
|
|
18
18
|
still pending (see Live Scanner and Paper Trading)
|
|
19
19
|
|
|
20
20
|
## Auth
|
|
@@ -75,13 +75,13 @@ Available once FILTRIX enables the live API (until then: exit 3, "not available
|
|
|
75
75
|
| reset --capital X --limits-json JSON --yes | close-all --yes
|
|
76
76
|
- filtrix paper strategy save --spec-json JSON [--id N] [--monitor-id N] | strategy archive ID --yes
|
|
77
77
|
- filtrix paper start STRATEGY_ID | pause RUN_ID | resume RUN_ID | close RUN_ID --yes
|
|
78
|
-
- filtrix paper command EVENT_ID outcome of a write that exited 6 "pending": its result, or still pending
|
|
78
|
+
- filtrix paper command EVENT_ID outcome of a write that exited 6 "pending": its result, or still pending
|
|
79
79
|
Paper money is simulated. Every paper write sends an Idempotency-Key (--idempotency-key, else a new one);
|
|
80
80
|
versions (--version, --account-version, --draft-version) are fetched from `filtrix paper account` when omitted.
|
|
81
|
-
A 409 version_conflict carries current_version. Run ids are UUIDs.
|
|
82
|
-
A write waits for the account worker (up to ~10 s on the server, then ~12 s of status reads). Still no
|
|
83
|
-
answer: stdout {"status":"pending","event_id","idempotency_key"}, exit 6; it may still apply, so read it with
|
|
84
|
-
`filtrix paper command EVENT_ID` and resend only with the same --idempotency-key. A refusal read there exits as
|
|
81
|
+
A 409 version_conflict carries current_version. Run ids are UUIDs.
|
|
82
|
+
A write waits for the account worker (up to ~10 s on the server, then ~12 s of status reads). Still no
|
|
83
|
+
answer: stdout {"status":"pending","event_id","idempotency_key"}, exit 6; it may still apply, so read it with
|
|
84
|
+
`filtrix paper command EVENT_ID` and resend only with the same --idempotency-key. A refusal read there exits as
|
|
85
85
|
a direct one would (e.g. 409 version_conflict, exit 2). A 500 internal_error is
|
|
86
86
|
retried once with the same key and body.
|
|
87
87
|
|
|
@@ -90,7 +90,9 @@ retried once with the same key and body.
|
|
|
90
90
|
(prints the finished job; a failed job exits 1, `--timeout` seconds without an end exits 6), or poll with
|
|
91
91
|
`filtrix jobs get JOB_ID`. At most 2 jobs run at a time per account (429 otherwise).
|
|
92
92
|
A simulation's result: summary (n_trades, win_rate 0..1, profit_factor, avg_pnl / total_pnl in USD per share,
|
|
93
|
-
avg_holding_min), up to 200 trades with pnl_pct, run_id.
|
|
93
|
+
avg_holding_min), up to 200 trades with pnl_pct, run_id. Events without minute bars are not simulated;
|
|
94
|
+
missing_minute_data counts them (pending: loaded every night; unavailable: none exist).
|
|
95
|
+
Definitions: `filtrix meta --json` -> "simulation".
|
|
94
96
|
--sl / --tp are fractions (0.02 = 2%).
|
|
95
97
|
|
|
96
98
|
## Filter DSL
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.0"
|
|
@@ -165,9 +165,11 @@ class FiltrixClient:
|
|
|
165
165
|
return self._request("GET", f"/api/v1/ticker/{symbol.upper()}/overview")
|
|
166
166
|
|
|
167
167
|
def ticker_gap_stats(self, symbol: str, gap_threshold: float = 10.0,
|
|
168
|
-
direction: str = "up", stat: str = "avg") -> Any:
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
direction: str = "up", stat: str = "avg", include_events: bool = False) -> Any:
|
|
169
|
+
params = {"gap_threshold": gap_threshold, "direction": direction, "stat": stat}
|
|
170
|
+
if include_events:
|
|
171
|
+
params["include_events"] = "true"
|
|
172
|
+
return self._request("GET", f"/api/v1/ticker/{symbol.upper()}/gap-stats", params=params)
|
|
171
173
|
|
|
172
174
|
def ticker_daily(self, symbol: str, limit: int = 250) -> Any:
|
|
173
175
|
return self._request("GET", f"/api/v1/ticker/{symbol.upper()}/daily", params={"limit": limit})
|
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
"""Read-only market and ticker commands over the Public API v1."""
|
|
2
|
-
from enum import Enum
|
|
3
|
-
from typing import Optional
|
|
4
|
-
|
|
5
|
-
import typer
|
|
6
|
-
|
|
7
|
-
from filtrix_cli.commands._helpers import build_client, command, output_result
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Direction(str, Enum):
|
|
11
|
-
up = "up"
|
|
12
|
-
down = "down"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class Stat(str, Enum):
|
|
16
|
-
avg = "avg"
|
|
17
|
-
median = "median"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@command
|
|
21
|
-
def meta() -> None:
|
|
22
|
-
"""Outcome definitions and units, limits, quotas and data coverage (free)."""
|
|
23
|
-
client, _ = build_client()
|
|
24
|
-
output_result(client.meta(), kind="meta")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@command
|
|
28
|
-
def coverage(symbol: Optional[str] = typer.Argument(None, help="Ticker; omit for the whole dataset.")) -> None:
|
|
29
|
-
"""First/last historical event date and event counts."""
|
|
30
|
-
client, _ = build_client()
|
|
31
|
-
output_result(client.coverage(symbol), kind="coverage")
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@command
|
|
35
|
-
def overview(symbol: str = typer.Argument(..., help="Ticker symbol, e.g. AAPL.")) -> None:
|
|
36
|
-
"""Ticker snapshot: last close, recent moves, 52-week range, TTM fundamentals."""
|
|
37
|
-
client, _ = build_client()
|
|
38
|
-
output_result(client.ticker_overview(symbol), kind="overview")
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@command
|
|
42
|
-
def gaps(
|
|
43
|
-
symbol: str = typer.Argument(..., help="Ticker symbol, e.g. TSLA."),
|
|
44
|
-
threshold: float = typer.Option(10.0, "--threshold", min=0, help="Minimum gap in percent (10 = 10%)."),
|
|
45
|
-
direction: Direction = typer.Option(Direction.up, "--direction", help="Gap direction."),
|
|
46
|
-
stat: Stat = typer.Option(Stat.avg, "--stat", help="Aggregate across gap events."),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
""
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
"""Read-only market and ticker commands over the Public API v1."""
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from filtrix_cli.commands._helpers import build_client, command, output_result
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Direction(str, Enum):
|
|
11
|
+
up = "up"
|
|
12
|
+
down = "down"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Stat(str, Enum):
|
|
16
|
+
avg = "avg"
|
|
17
|
+
median = "median"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@command
|
|
21
|
+
def meta() -> None:
|
|
22
|
+
"""Outcome definitions and units, limits, quotas and data coverage (free)."""
|
|
23
|
+
client, _ = build_client()
|
|
24
|
+
output_result(client.meta(), kind="meta")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@command
|
|
28
|
+
def coverage(symbol: Optional[str] = typer.Argument(None, help="Ticker; omit for the whole dataset.")) -> None:
|
|
29
|
+
"""First/last historical event date and event counts."""
|
|
30
|
+
client, _ = build_client()
|
|
31
|
+
output_result(client.coverage(symbol), kind="coverage")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@command
|
|
35
|
+
def overview(symbol: str = typer.Argument(..., help="Ticker symbol, e.g. AAPL.")) -> None:
|
|
36
|
+
"""Ticker snapshot: last close, recent moves, 52-week range, TTM fundamentals."""
|
|
37
|
+
client, _ = build_client()
|
|
38
|
+
output_result(client.ticker_overview(symbol), kind="overview")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@command
|
|
42
|
+
def gaps(
|
|
43
|
+
symbol: str = typer.Argument(..., help="Ticker symbol, e.g. TSLA."),
|
|
44
|
+
threshold: float = typer.Option(10.0, "--threshold", min=0, help="Minimum gap in percent (10 = 10%)."),
|
|
45
|
+
direction: Direction = typer.Option(Direction.up, "--direction", help="Gap direction."),
|
|
46
|
+
stat: Stat = typer.Option(Stat.avg, "--stat", help="Aggregate across gap events."),
|
|
47
|
+
events: bool = typer.Option(False, "--events",
|
|
48
|
+
help="Also list every counted gap day (stats from our minute bars; long output)."),
|
|
49
|
+
) -> None:
|
|
50
|
+
"""How this ticker's own past gaps resolved (gap day and the next day)."""
|
|
51
|
+
client, _ = build_client()
|
|
52
|
+
output_result(client.ticker_gap_stats(symbol, gap_threshold=threshold, direction=direction.value,
|
|
53
|
+
stat=stat.value, include_events=events), kind="gaps")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@command
|
|
57
|
+
def daily(
|
|
58
|
+
symbol: str = typer.Argument(..., help="Ticker symbol, e.g. AAPL."),
|
|
59
|
+
limit: int = typer.Option(250, "--limit", min=1, max=500, help="Number of recent daily bars."),
|
|
60
|
+
) -> None:
|
|
61
|
+
"""Daily OHLCV bars, oldest first."""
|
|
62
|
+
client, _ = build_client()
|
|
63
|
+
output_result(client.ticker_daily(symbol, limit=limit), kind="daily")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@command
|
|
67
|
+
def premarket() -> None:
|
|
68
|
+
"""Today's premarket gappers with historical stats of similar gaps (free)."""
|
|
69
|
+
client, _ = build_client()
|
|
70
|
+
output_result(client.premarket_gappers(), kind="premarket")
|
|
@@ -124,7 +124,7 @@ def runs_save(
|
|
|
124
124
|
flat_threshold: float = typer.Option(0.002, "--flat-threshold"),
|
|
125
125
|
pos_min: Optional[float] = typer.Option(None, "--pos-min"),
|
|
126
126
|
pos_max: Optional[float] = typer.Option(None, "--pos-max"),
|
|
127
|
-
row_filter: RowFilter = typer.Option(RowFilter.all, "--row-filter", help="Which outcome rows to
|
|
127
|
+
row_filter: RowFilter = typer.Option(RowFilter.all, "--row-filter", help="Which outcome rows to store with the run; the run's statistics always use all rows."),
|
|
128
128
|
wait: bool = typer.Option(False, "--wait", help="Poll until the save finishes."),
|
|
129
129
|
timeout: float = typer.Option(600, "--timeout", min=0, help="Seconds --wait polls before giving up."),
|
|
130
130
|
) -> None:
|
|
@@ -1,163 +1,185 @@
|
|
|
1
|
-
import json
|
|
2
|
-
|
|
3
|
-
import respx
|
|
4
|
-
from httpx import Response
|
|
5
|
-
from typer.testing import CliRunner
|
|
6
|
-
|
|
7
|
-
from filtrix_cli.__main__ import app
|
|
8
|
-
from filtrix_cli.state import reset_state
|
|
9
|
-
|
|
10
|
-
runner = CliRunner()
|
|
11
|
-
BASE = "https://api.test"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def setup_function():
|
|
15
|
-
reset_state()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def _env(monkeypatch):
|
|
19
|
-
monkeypatch.setenv("FILTRIX_API_KEY", "flt_x")
|
|
20
|
-
monkeypatch.setenv("FILTRIX_BASE_URL", BASE)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@respx.mock
|
|
24
|
-
def test_meta(monkeypatch):
|
|
25
|
-
_env(monkeypatch)
|
|
26
|
-
respx.get(f"{BASE}/api/v1/meta").mock(return_value=Response(200, json={"api_version": "1"}))
|
|
27
|
-
|
|
28
|
-
result = runner.invoke(app, ["meta"])
|
|
29
|
-
|
|
30
|
-
assert result.exit_code == 0
|
|
31
|
-
assert json.loads(result.stdout)["api_version"] == "1"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@respx.mock
|
|
35
|
-
def test_coverage_with_symbol(monkeypatch):
|
|
36
|
-
_env(monkeypatch)
|
|
37
|
-
route = respx.get(f"{BASE}/api/v1/coverage").mock(return_value=Response(200, json={"events_for_symbol": 4}))
|
|
38
|
-
|
|
39
|
-
result = runner.invoke(app, ["coverage", "tsla"])
|
|
40
|
-
|
|
41
|
-
assert result.exit_code == 0
|
|
42
|
-
assert route.calls.last.request.url.params["symbol"] == "TSLA"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@respx.mock
|
|
46
|
-
def test_coverage_without_symbol_sends_no_param(monkeypatch):
|
|
47
|
-
_env(monkeypatch)
|
|
48
|
-
route = respx.get(f"{BASE}/api/v1/coverage").mock(return_value=Response(200, json={"total_events": 9}))
|
|
49
|
-
|
|
50
|
-
result = runner.invoke(app, ["coverage"])
|
|
51
|
-
|
|
52
|
-
assert result.exit_code == 0
|
|
53
|
-
assert "symbol" not in route.calls.last.request.url.params
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@respx.mock
|
|
57
|
-
def test_overview(monkeypatch):
|
|
58
|
-
_env(monkeypatch)
|
|
59
|
-
respx.get(f"{BASE}/api/v1/ticker/AAPL/overview").mock(return_value=Response(200, json={"last_close": 200.0}))
|
|
60
|
-
|
|
61
|
-
result = runner.invoke(app, ["overview", "aapl"])
|
|
62
|
-
|
|
63
|
-
assert result.exit_code == 0
|
|
64
|
-
assert json.loads(result.stdout)["last_close"] == 200.0
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
@respx.mock
|
|
68
|
-
def test_gaps_options(monkeypatch):
|
|
69
|
-
_env(monkeypatch)
|
|
70
|
-
route = respx.get(f"{BASE}/api/v1/ticker/TSLA/gap-stats").mock(return_value=Response(200, json={"overview": {}}))
|
|
71
|
-
|
|
72
|
-
result = runner.invoke(app, ["gaps", "TSLA", "--threshold", "15", "--direction", "down", "--stat", "median"])
|
|
73
|
-
|
|
74
|
-
assert result.exit_code == 0
|
|
75
|
-
params = route.calls.last.request.url.params
|
|
76
|
-
assert (params["gap_threshold"], params["direction"], params["stat"]) == ("15.0", "down", "median")
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
assert
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@respx.mock
|
|
110
|
-
def
|
|
111
|
-
monkeypatch
|
|
112
|
-
route = respx.get(f"{BASE}/api/v1/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
assert
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
result
|
|
155
|
-
|
|
156
|
-
assert
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import respx
|
|
4
|
+
from httpx import Response
|
|
5
|
+
from typer.testing import CliRunner
|
|
6
|
+
|
|
7
|
+
from filtrix_cli.__main__ import app
|
|
8
|
+
from filtrix_cli.state import reset_state
|
|
9
|
+
|
|
10
|
+
runner = CliRunner()
|
|
11
|
+
BASE = "https://api.test"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def setup_function():
|
|
15
|
+
reset_state()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _env(monkeypatch):
|
|
19
|
+
monkeypatch.setenv("FILTRIX_API_KEY", "flt_x")
|
|
20
|
+
monkeypatch.setenv("FILTRIX_BASE_URL", BASE)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@respx.mock
|
|
24
|
+
def test_meta(monkeypatch):
|
|
25
|
+
_env(monkeypatch)
|
|
26
|
+
respx.get(f"{BASE}/api/v1/meta").mock(return_value=Response(200, json={"api_version": "1"}))
|
|
27
|
+
|
|
28
|
+
result = runner.invoke(app, ["meta"])
|
|
29
|
+
|
|
30
|
+
assert result.exit_code == 0
|
|
31
|
+
assert json.loads(result.stdout)["api_version"] == "1"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@respx.mock
|
|
35
|
+
def test_coverage_with_symbol(monkeypatch):
|
|
36
|
+
_env(monkeypatch)
|
|
37
|
+
route = respx.get(f"{BASE}/api/v1/coverage").mock(return_value=Response(200, json={"events_for_symbol": 4}))
|
|
38
|
+
|
|
39
|
+
result = runner.invoke(app, ["coverage", "tsla"])
|
|
40
|
+
|
|
41
|
+
assert result.exit_code == 0
|
|
42
|
+
assert route.calls.last.request.url.params["symbol"] == "TSLA"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@respx.mock
|
|
46
|
+
def test_coverage_without_symbol_sends_no_param(monkeypatch):
|
|
47
|
+
_env(monkeypatch)
|
|
48
|
+
route = respx.get(f"{BASE}/api/v1/coverage").mock(return_value=Response(200, json={"total_events": 9}))
|
|
49
|
+
|
|
50
|
+
result = runner.invoke(app, ["coverage"])
|
|
51
|
+
|
|
52
|
+
assert result.exit_code == 0
|
|
53
|
+
assert "symbol" not in route.calls.last.request.url.params
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@respx.mock
|
|
57
|
+
def test_overview(monkeypatch):
|
|
58
|
+
_env(monkeypatch)
|
|
59
|
+
respx.get(f"{BASE}/api/v1/ticker/AAPL/overview").mock(return_value=Response(200, json={"last_close": 200.0}))
|
|
60
|
+
|
|
61
|
+
result = runner.invoke(app, ["overview", "aapl"])
|
|
62
|
+
|
|
63
|
+
assert result.exit_code == 0
|
|
64
|
+
assert json.loads(result.stdout)["last_close"] == 200.0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@respx.mock
|
|
68
|
+
def test_gaps_options(monkeypatch):
|
|
69
|
+
_env(monkeypatch)
|
|
70
|
+
route = respx.get(f"{BASE}/api/v1/ticker/TSLA/gap-stats").mock(return_value=Response(200, json={"overview": {}}))
|
|
71
|
+
|
|
72
|
+
result = runner.invoke(app, ["gaps", "TSLA", "--threshold", "15", "--direction", "down", "--stat", "median"])
|
|
73
|
+
|
|
74
|
+
assert result.exit_code == 0
|
|
75
|
+
params = route.calls.last.request.url.params
|
|
76
|
+
assert (params["gap_threshold"], params["direction"], params["stat"]) == ("15.0", "down", "median")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@respx.mock
|
|
80
|
+
def test_gaps_leaves_events_out_by_default(monkeypatch):
|
|
81
|
+
_env(monkeypatch)
|
|
82
|
+
route = respx.get(f"{BASE}/api/v1/ticker/TSLA/gap-stats").mock(return_value=Response(200, json={"overview": {}}))
|
|
83
|
+
|
|
84
|
+
result = runner.invoke(app, ["gaps", "TSLA"])
|
|
85
|
+
|
|
86
|
+
assert result.exit_code == 0
|
|
87
|
+
assert "include_events" not in route.calls.last.request.url.params
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@respx.mock
|
|
91
|
+
def test_gaps_events_flag(monkeypatch):
|
|
92
|
+
_env(monkeypatch)
|
|
93
|
+
route = respx.get(f"{BASE}/api/v1/ticker/TSLA/gap-stats").mock(return_value=Response(200, json={"overview": {}}))
|
|
94
|
+
|
|
95
|
+
result = runner.invoke(app, ["gaps", "TSLA", "--events"])
|
|
96
|
+
|
|
97
|
+
assert result.exit_code == 0
|
|
98
|
+
assert route.calls.last.request.url.params["include_events"] == "true"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_gaps_rejects_bad_direction(monkeypatch):
|
|
102
|
+
_env(monkeypatch)
|
|
103
|
+
|
|
104
|
+
result = runner.invoke(app, ["gaps", "TSLA", "--direction", "sideways"])
|
|
105
|
+
|
|
106
|
+
assert result.exit_code == 2
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@respx.mock
|
|
110
|
+
def test_daily_limit(monkeypatch):
|
|
111
|
+
_env(monkeypatch)
|
|
112
|
+
route = respx.get(f"{BASE}/api/v1/ticker/AAPL/daily").mock(return_value=Response(200, json={"data": []}))
|
|
113
|
+
|
|
114
|
+
result = runner.invoke(app, ["daily", "AAPL", "--limit", "30"])
|
|
115
|
+
|
|
116
|
+
assert result.exit_code == 0
|
|
117
|
+
assert route.calls.last.request.url.params["limit"] == "30"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@respx.mock
|
|
121
|
+
def test_premarket(monkeypatch):
|
|
122
|
+
_env(monkeypatch)
|
|
123
|
+
respx.get(f"{BASE}/api/v1/premarket/gappers").mock(return_value=Response(200, json={"rows": [{"ticker": "X"}]}))
|
|
124
|
+
|
|
125
|
+
result = runner.invoke(app, ["premarket"])
|
|
126
|
+
|
|
127
|
+
assert result.exit_code == 0
|
|
128
|
+
assert json.loads(result.stdout)["rows"][0]["ticker"] == "X"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@respx.mock
|
|
132
|
+
def test_filters_search_is_server_side(monkeypatch):
|
|
133
|
+
monkeypatch.setenv("FILTRIX_BASE_URL", BASE)
|
|
134
|
+
route = respx.get(f"{BASE}/api/v1/filters").mock(return_value=Response(200, json={"total": 1, "columns": [
|
|
135
|
+
{"column": "rv_computed", "value_type": "number", "operators": []}]}))
|
|
136
|
+
|
|
137
|
+
result = runner.invoke(app, ["filters", "--search", "relative volume", "--type", "number"])
|
|
138
|
+
|
|
139
|
+
assert result.exit_code == 0
|
|
140
|
+
params = route.calls.last.request.url.params
|
|
141
|
+
assert params["q"] == "relative volume"
|
|
142
|
+
assert params["type"] == "number"
|
|
143
|
+
assert [c["column"] for c in json.loads(result.stdout)["columns"]] == ["rv_computed"]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@respx.mock
|
|
147
|
+
def test_backtest_new_flags(monkeypatch):
|
|
148
|
+
_env(monkeypatch)
|
|
149
|
+
route = respx.post(f"{BASE}/api/v1/backtest").mock(return_value=Response(200, json={"n": 1, "summary": {}}))
|
|
150
|
+
|
|
151
|
+
result = runner.invoke(app, ["backtest", "-f", "gap_gup>=10", "--threshold", "0.6",
|
|
152
|
+
"--pos-min", "0.3", "--pos-max", "0.9", "--sample", "5"])
|
|
153
|
+
|
|
154
|
+
assert result.exit_code == 0
|
|
155
|
+
sent = json.loads(route.calls.last.request.content)
|
|
156
|
+
assert (sent["threshold"], sent["pos_min"], sent["pos_max"], sent["sample_limit"]) == (0.6, 0.3, 0.9, 5)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@respx.mock
|
|
160
|
+
def test_backtest_defaults_send_no_band(monkeypatch):
|
|
161
|
+
_env(monkeypatch)
|
|
162
|
+
route = respx.post(f"{BASE}/api/v1/backtest").mock(return_value=Response(200, json={"n": 1, "summary": {}}))
|
|
163
|
+
|
|
164
|
+
runner.invoke(app, ["backtest", "-f", "gap_gup>=10"])
|
|
165
|
+
|
|
166
|
+
sent = json.loads(route.calls.last.request.content)
|
|
167
|
+
assert "pos_min" not in sent and "pos_max" not in sent
|
|
168
|
+
assert sent["sample_limit"] == 0
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@respx.mock
|
|
172
|
+
def test_screen_field_flag(monkeypatch):
|
|
173
|
+
_env(monkeypatch)
|
|
174
|
+
route = respx.post(f"{BASE}/api/v1/screen").mock(return_value=Response(200, json={"total": 0, "results": []}))
|
|
175
|
+
|
|
176
|
+
result = runner.invoke(app, ["screen", "-f", "gap_gup>=10", "--field", "rv_computed", "--field", "sector_name"])
|
|
177
|
+
|
|
178
|
+
assert result.exit_code == 0
|
|
179
|
+
assert json.loads(route.calls.last.request.content)["fields"] == ["rv_computed", "sector_name"]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_backtest_threshold_help_states_unit():
|
|
183
|
+
result = runner.invoke(app, ["backtest", "--help"], env={"COLUMNS": "200"})
|
|
184
|
+
|
|
185
|
+
assert "outcome's unit" in result.stdout
|
|
@@ -9,7 +9,7 @@ runner = CliRunner()
|
|
|
9
9
|
def test_version_prints_semver():
|
|
10
10
|
result = runner.invoke(app, ["version"])
|
|
11
11
|
assert result.exit_code == 0
|
|
12
|
-
assert "filtrix-cli 0.
|
|
12
|
+
assert "filtrix-cli 0.6.0" in result.stdout
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def test_no_args_shows_help():
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.0"
|
|
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
|
|
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
|
|
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
|