mantis-ib 0.2.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.
@@ -0,0 +1,15 @@
1
+ # IDE files
2
+ .vscode/
3
+
4
+ # Python-generated files
5
+ __pycache__/
6
+ *.py[oc]
7
+ build/
8
+ dist/
9
+ wheels/
10
+ *.egg-info
11
+ .pytest_cache/
12
+ .python-version
13
+
14
+ # Virtual environments
15
+ .venv
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.5
2
+ Name: mantis-ib
3
+ Version: 0.2.0
4
+ Summary: Interactive Brokers source provider for MANTIS
5
+ Author-email: Louis Zhuang <yzhuang@outlook.com>
6
+ Requires-Python: >=3.14
7
+ Requires-Dist: adbc-driver-postgresql>=1.12.0
8
+ Requires-Dist: asof-store[sql-postgres,sql-sqlite]
9
+ Requires-Dist: mantis-imf
10
+ Requires-Dist: polars[adbc,pyarrow]>=2.0.0
11
+ Requires-Dist: pydantic>=2.0
12
+ Requires-Dist: service-registrar>=0.2.1
13
+ Requires-Dist: zapros>=0.20.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # MANTIS Interactive Brokers provider
17
+
18
+ This package provides the IB instrument source for MANTIS IMF through a
19
+ `service-registrar` entry point and the provider-specific command line.
20
+
21
+ Install `mantis-ib` alongside `mantis-imf` to enable the default IB resolver
22
+ source and the `ib` CLI.
23
+
24
+ ## Commands
25
+
26
+ ```powershell
27
+ ib index
28
+ ib scrape-instruments
29
+ ib scrape-reconcile
30
+ ib scrape-funds
31
+ ib scrape-exchanges
32
+ ```
33
+
34
+ The `ib index` command requires PostgreSQL and adds trigram indexes to the
35
+ instrument and template tables. The instrument scraping commands accept
36
+ repeated `--product-type` and `--product-country` filters. Use `--dry-run` to
37
+ print the remote product summary without opening a store. Pass `--sql-uri URI`
38
+ to override the configured SQL URI for a command. Run `ib <command> --help` to
39
+ see command-specific options.
40
+
41
+ Configure the default SQL URI in the repository's `service-registrar.toml`:
42
+
43
+ ```toml
44
+ ["asof-store.sql"]
45
+ sql_uri = "sqlite:///ib-instruments.db"
46
+ ```
@@ -0,0 +1,31 @@
1
+ # MANTIS Interactive Brokers provider
2
+
3
+ This package provides the IB instrument source for MANTIS IMF through a
4
+ `service-registrar` entry point and the provider-specific command line.
5
+
6
+ Install `mantis-ib` alongside `mantis-imf` to enable the default IB resolver
7
+ source and the `ib` CLI.
8
+
9
+ ## Commands
10
+
11
+ ```powershell
12
+ ib index
13
+ ib scrape-instruments
14
+ ib scrape-reconcile
15
+ ib scrape-funds
16
+ ib scrape-exchanges
17
+ ```
18
+
19
+ The `ib index` command requires PostgreSQL and adds trigram indexes to the
20
+ instrument and template tables. The instrument scraping commands accept
21
+ repeated `--product-type` and `--product-country` filters. Use `--dry-run` to
22
+ print the remote product summary without opening a store. Pass `--sql-uri URI`
23
+ to override the configured SQL URI for a command. Run `ib <command> --help` to
24
+ see command-specific options.
25
+
26
+ Configure the default SQL URI in the repository's `service-registrar.toml`:
27
+
28
+ ```toml
29
+ ["asof-store.sql"]
30
+ sql_uri = "sqlite:///ib-instruments.db"
31
+ ```
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "mantis-ib"
3
+ dynamic = ["version"]
4
+ description = "Interactive Brokers source provider for MANTIS"
5
+ readme = "README.md"
6
+ authors = [{ name = "Louis Zhuang", email = "yzhuang@outlook.com" }]
7
+ requires-python = ">=3.14"
8
+ dependencies = [
9
+ "adbc-driver-postgresql>=1.12.0",
10
+ "asof-store[sql-postgres,sql-sqlite]",
11
+ "mantis-imf",
12
+ "polars[adbc,pyarrow]>=2.0.0",
13
+ "pydantic>=2.0",
14
+ "service-registrar>=0.2.1",
15
+ "zapros>=0.20.0",
16
+ ]
17
+
18
+ [project.scripts]
19
+ ib = "mantis_ib.cli:main"
20
+
21
+ [project.entry-points."service_registrar.providers"]
22
+ ib = "mantis_ib.plugin:IB_INSTRUMENT_SOURCE"
23
+
24
+ [build-system]
25
+ requires = ["hatchling", "uv-dynamic-versioning"]
26
+ build-backend = "hatchling.build"
27
+
28
+ [tool.hatch.version]
29
+ source = "uv-dynamic-versioning"
30
+
31
+ [tool.uv.sources]
32
+ mantis-imf = { workspace = true }
@@ -0,0 +1 @@
1
+ """Interactive Brokers provider for MANTIS IMF."""
@@ -0,0 +1,55 @@
1
+ """Interactive Brokers command line entry point."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+ from collections.abc import Sequence
8
+
9
+ from .scraper import main as scraper_main
10
+ from .search import create_search_indexes
11
+
12
+ _SCRAPER_COMMANDS = (
13
+ "scrape-instruments",
14
+ "scrape-reconcile",
15
+ "scrape-funds",
16
+ "scrape-exchanges",
17
+ )
18
+
19
+
20
+ def _build_parser() -> argparse.ArgumentParser:
21
+ parser = argparse.ArgumentParser(
22
+ prog="ib",
23
+ description="Search, index, and scrape Interactive Brokers instruments.",
24
+ )
25
+ parser.add_argument("command", nargs="?", choices=("index", *_SCRAPER_COMMANDS))
26
+ parser.add_argument("arguments", nargs=argparse.REMAINDER)
27
+ return parser
28
+
29
+
30
+ def _run_index(argv: Sequence[str]) -> int:
31
+ parser = argparse.ArgumentParser(prog="ib index")
32
+ parser.add_argument("--sql-uri")
33
+ parser.add_argument("--table-name", default="ib_instruments")
34
+ parser.add_argument(
35
+ "--missing-primary-key-table-name",
36
+ default="ib_instrument_templates",
37
+ )
38
+ args = parser.parse_args(argv)
39
+ return create_search_indexes(
40
+ sql_uri=args.sql_uri,
41
+ table_name=args.table_name,
42
+ missing_primary_key_table_name=args.missing_primary_key_table_name,
43
+ )
44
+
45
+
46
+ def main(argv: Sequence[str] | None = None) -> int:
47
+ command_line = list(sys.argv[1:] if argv is None else argv)
48
+ parser = _build_parser()
49
+ args = parser.parse_args(command_line)
50
+ if args.command is None:
51
+ parser.print_help()
52
+ return 0
53
+ if args.command == "index":
54
+ return _run_index(args.arguments)
55
+ return scraper_main([args.command, *args.arguments])