ibkr-cli 0.1.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.
- ibkr_cli-0.1.0/LICENSE +21 -0
- ibkr_cli-0.1.0/PKG-INFO +273 -0
- ibkr_cli-0.1.0/README.md +242 -0
- ibkr_cli-0.1.0/pyproject.toml +57 -0
- ibkr_cli-0.1.0/setup.cfg +4 -0
- ibkr_cli-0.1.0/setup.py +3 -0
- ibkr_cli-0.1.0/src/ibkr_cli/__init__.py +3 -0
- ibkr_cli-0.1.0/src/ibkr_cli/__main__.py +4 -0
- ibkr_cli-0.1.0/src/ibkr_cli/app.py +1134 -0
- ibkr_cli-0.1.0/src/ibkr_cli/config.py +97 -0
- ibkr_cli-0.1.0/src/ibkr_cli/ib_service.py +1037 -0
- ibkr_cli-0.1.0/src/ibkr_cli/networking.py +28 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/PKG-INFO +273 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/SOURCES.txt +19 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/dependency_links.txt +1 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/entry_points.txt +2 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/requires.txt +11 -0
- ibkr_cli-0.1.0/src/ibkr_cli.egg-info/top_level.txt +1 -0
- ibkr_cli-0.1.0/tests/test_cli.py +261 -0
- ibkr_cli-0.1.0/tests/test_config.py +40 -0
- ibkr_cli-0.1.0/tests/test_renderers.py +106 -0
ibkr_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wangding
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ibkr_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ibkr-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A local-first CLI for Interactive Brokers
|
|
5
|
+
Author: wangding
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/wangding/ibkr-cli
|
|
8
|
+
Project-URL: Repository, https://github.com/wangding/ibkr-cli
|
|
9
|
+
Project-URL: Issues, https://github.com/wangding/ibkr-cli/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: ib_async<3,>=2.1
|
|
23
|
+
Requires-Dist: platformdirs<5,>=4.2
|
|
24
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
25
|
+
Requires-Dist: rich<14,>=13.7
|
|
26
|
+
Requires-Dist: tomli<3,>=2.0; python_version < "3.11"
|
|
27
|
+
Requires-Dist: typer<1,>=0.12
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest<9,>=8; extra == "test"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# ibkr-cli
|
|
33
|
+
|
|
34
|
+
A local-first CLI for Interactive Brokers built on top of `ib_async`, `Typer`, and `Rich`.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- Profile-based local connection management for TWS and IB Gateway
|
|
39
|
+
- Connectivity checks for TCP reachability and IBKR API handshake
|
|
40
|
+
- Account queries for summary and positions
|
|
41
|
+
- Order queries for open, completed, and executions
|
|
42
|
+
- Safe stock order preview via IBKR what-if orders
|
|
43
|
+
- Real stock order submission with explicit `--submit`
|
|
44
|
+
- Open order cancellation by order ID
|
|
45
|
+
- Market data snapshot quotes with live-to-delayed fallback
|
|
46
|
+
- Finite quote watch mode for repeated quote updates
|
|
47
|
+
- Historical bar retrieval
|
|
48
|
+
|
|
49
|
+
## Requirements
|
|
50
|
+
|
|
51
|
+
- Python 3.10+
|
|
52
|
+
- A running TWS or IB Gateway session
|
|
53
|
+
- Market data subscriptions as required by your IBKR account
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Install from PyPI with `pipx` so the `ibkr` command is isolated from your main Python environment:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pipx install ibkr-cli
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you prefer to install into the current Python environment:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m pip install ibkr-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
After installation:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
ibkr --help
|
|
73
|
+
ibkr --version
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
### Initialize local config
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
ibkr profile init
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This creates a config file under the path returned by:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ibkr config-path
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The default generated profiles are:
|
|
91
|
+
|
|
92
|
+
- `paper` -> `127.0.0.1:7497`
|
|
93
|
+
- `live` -> `127.0.0.1:7496`
|
|
94
|
+
- `gateway-paper` -> `127.0.0.1:4002`
|
|
95
|
+
- `gateway-live` -> `127.0.0.1:4001`
|
|
96
|
+
|
|
97
|
+
### Inspect available profiles
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ibkr profile list
|
|
101
|
+
ibkr profile show gateway-paper
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Check connectivity
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
ibkr doctor --profile gateway-paper
|
|
108
|
+
ibkr connect test --profile gateway-paper
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Core commands
|
|
112
|
+
|
|
113
|
+
### Account and positions
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
ibkr account summary --profile gateway-paper
|
|
117
|
+
ibkr positions --profile gateway-paper
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Orders
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
ibkr orders open --profile gateway-paper
|
|
124
|
+
ibkr orders completed --profile gateway-paper
|
|
125
|
+
ibkr orders executions --profile gateway-paper
|
|
126
|
+
ibkr orders cancel 12345 --profile gateway-paper
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Trading
|
|
130
|
+
|
|
131
|
+
Preview first:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
ibkr buy AAPL 10 --preview --profile gateway-paper
|
|
135
|
+
ibkr sell AAPL 10 --preview --profile gateway-paper
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Submit only when you explicitly intend to place an order:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
ibkr buy AAPL 10 --submit --profile gateway-paper
|
|
142
|
+
ibkr sell AAPL 10 --submit --profile gateway-paper
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Market data
|
|
146
|
+
|
|
147
|
+
Snapshot quote:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
ibkr quote AAPL --profile gateway-paper
|
|
151
|
+
ibkr quote AAPL --profile gateway-paper --json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Finite quote watch:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
ibkr quote AAPL --watch --updates 5 --interval 2 --profile gateway-paper
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Historical bars:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
ibkr bars AAPL --profile gateway-paper
|
|
164
|
+
ibkr bars AAPL --profile gateway-paper --duration "1 D" --bar-size "5 mins" --json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## JSON output
|
|
168
|
+
|
|
169
|
+
Most read and trading commands support `--json` for machine-readable output.
|
|
170
|
+
|
|
171
|
+
Examples:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
ibkr quote AAPL --profile gateway-paper --json
|
|
175
|
+
ibkr orders completed --profile gateway-paper --json
|
|
176
|
+
ibkr buy AAPL 10 --preview --profile gateway-paper --json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Error JSON shape
|
|
180
|
+
|
|
181
|
+
When a command fails in `--json` mode, the CLI returns a structured error payload and exits with a non-zero process code.
|
|
182
|
+
|
|
183
|
+
Shape:
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"ok": false,
|
|
188
|
+
"error": {
|
|
189
|
+
"code": "invalid_arguments",
|
|
190
|
+
"message": "Choose exactly one of --preview or --submit.",
|
|
191
|
+
"exit_code": 2,
|
|
192
|
+
"details": {
|
|
193
|
+
"preview": false,
|
|
194
|
+
"submit": false
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Current error code families include:
|
|
201
|
+
|
|
202
|
+
- `invalid_arguments`
|
|
203
|
+
- `config_load_failed`
|
|
204
|
+
- `config_already_exists`
|
|
205
|
+
- `unknown_profile`
|
|
206
|
+
- `connectivity_check_failed`
|
|
207
|
+
- `account_query_failed`
|
|
208
|
+
- `order_query_failed`
|
|
209
|
+
- `order_operation_failed`
|
|
210
|
+
- `market_data_request_failed`
|
|
211
|
+
|
|
212
|
+
## Operational notes
|
|
213
|
+
|
|
214
|
+
### Prefer paper trading first
|
|
215
|
+
|
|
216
|
+
Use `gateway-paper` or `paper` while validating commands that submit or cancel real orders.
|
|
217
|
+
|
|
218
|
+
### Submit is explicit
|
|
219
|
+
|
|
220
|
+
`buy` and `sell` require exactly one of:
|
|
221
|
+
|
|
222
|
+
- `--preview`
|
|
223
|
+
- `--submit`
|
|
224
|
+
|
|
225
|
+
This prevents accidental live order placement from a default command path.
|
|
226
|
+
|
|
227
|
+
### Run same-profile validations serially
|
|
228
|
+
|
|
229
|
+
If multiple CLI processes connect to the same TWS or IB Gateway profile with the same fixed `client_id`, IBKR can reject or interfere with the second connection.
|
|
230
|
+
|
|
231
|
+
For validation and manual testing, prefer running commands sequentially per profile unless you intentionally assign unique client IDs.
|
|
232
|
+
|
|
233
|
+
### Market data fallback
|
|
234
|
+
|
|
235
|
+
`quote` automatically falls back from live market data to delayed market data when live prices are unavailable.
|
|
236
|
+
|
|
237
|
+
### Command name conflicts
|
|
238
|
+
|
|
239
|
+
This package installs the command `ibkr`.
|
|
240
|
+
|
|
241
|
+
If your machine already has another CLI exposing the same command name, uninstall the old tool or adjust your `PATH` so that this package's `ibkr` entrypoint is the one your shell resolves first.
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
Install in editable mode:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
python -m pip install -e .
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Install in editable mode with optional test dependencies:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
python -m pip install -e ".[test]"
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Run directly from source if needed:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
python -m ibkr_cli.app --help
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Run the offline test suite:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
python -m unittest discover -s tests -v
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
The packaged entrypoint for installed users is:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
ibkr --help
|
|
273
|
+
```
|
ibkr_cli-0.1.0/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# ibkr-cli
|
|
2
|
+
|
|
3
|
+
A local-first CLI for Interactive Brokers built on top of `ib_async`, `Typer`, and `Rich`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Profile-based local connection management for TWS and IB Gateway
|
|
8
|
+
- Connectivity checks for TCP reachability and IBKR API handshake
|
|
9
|
+
- Account queries for summary and positions
|
|
10
|
+
- Order queries for open, completed, and executions
|
|
11
|
+
- Safe stock order preview via IBKR what-if orders
|
|
12
|
+
- Real stock order submission with explicit `--submit`
|
|
13
|
+
- Open order cancellation by order ID
|
|
14
|
+
- Market data snapshot quotes with live-to-delayed fallback
|
|
15
|
+
- Finite quote watch mode for repeated quote updates
|
|
16
|
+
- Historical bar retrieval
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- Python 3.10+
|
|
21
|
+
- A running TWS or IB Gateway session
|
|
22
|
+
- Market data subscriptions as required by your IBKR account
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install from PyPI with `pipx` so the `ibkr` command is isolated from your main Python environment:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pipx install ibkr-cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If you prefer to install into the current Python environment:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m pip install ibkr-cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
After installation:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
ibkr --help
|
|
42
|
+
ibkr --version
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick start
|
|
46
|
+
|
|
47
|
+
### Initialize local config
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
ibkr profile init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This creates a config file under the path returned by:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
ibkr config-path
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The default generated profiles are:
|
|
60
|
+
|
|
61
|
+
- `paper` -> `127.0.0.1:7497`
|
|
62
|
+
- `live` -> `127.0.0.1:7496`
|
|
63
|
+
- `gateway-paper` -> `127.0.0.1:4002`
|
|
64
|
+
- `gateway-live` -> `127.0.0.1:4001`
|
|
65
|
+
|
|
66
|
+
### Inspect available profiles
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
ibkr profile list
|
|
70
|
+
ibkr profile show gateway-paper
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Check connectivity
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ibkr doctor --profile gateway-paper
|
|
77
|
+
ibkr connect test --profile gateway-paper
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Core commands
|
|
81
|
+
|
|
82
|
+
### Account and positions
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
ibkr account summary --profile gateway-paper
|
|
86
|
+
ibkr positions --profile gateway-paper
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Orders
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
ibkr orders open --profile gateway-paper
|
|
93
|
+
ibkr orders completed --profile gateway-paper
|
|
94
|
+
ibkr orders executions --profile gateway-paper
|
|
95
|
+
ibkr orders cancel 12345 --profile gateway-paper
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Trading
|
|
99
|
+
|
|
100
|
+
Preview first:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
ibkr buy AAPL 10 --preview --profile gateway-paper
|
|
104
|
+
ibkr sell AAPL 10 --preview --profile gateway-paper
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Submit only when you explicitly intend to place an order:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
ibkr buy AAPL 10 --submit --profile gateway-paper
|
|
111
|
+
ibkr sell AAPL 10 --submit --profile gateway-paper
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Market data
|
|
115
|
+
|
|
116
|
+
Snapshot quote:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
ibkr quote AAPL --profile gateway-paper
|
|
120
|
+
ibkr quote AAPL --profile gateway-paper --json
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Finite quote watch:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
ibkr quote AAPL --watch --updates 5 --interval 2 --profile gateway-paper
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Historical bars:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
ibkr bars AAPL --profile gateway-paper
|
|
133
|
+
ibkr bars AAPL --profile gateway-paper --duration "1 D" --bar-size "5 mins" --json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## JSON output
|
|
137
|
+
|
|
138
|
+
Most read and trading commands support `--json` for machine-readable output.
|
|
139
|
+
|
|
140
|
+
Examples:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
ibkr quote AAPL --profile gateway-paper --json
|
|
144
|
+
ibkr orders completed --profile gateway-paper --json
|
|
145
|
+
ibkr buy AAPL 10 --preview --profile gateway-paper --json
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Error JSON shape
|
|
149
|
+
|
|
150
|
+
When a command fails in `--json` mode, the CLI returns a structured error payload and exits with a non-zero process code.
|
|
151
|
+
|
|
152
|
+
Shape:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"ok": false,
|
|
157
|
+
"error": {
|
|
158
|
+
"code": "invalid_arguments",
|
|
159
|
+
"message": "Choose exactly one of --preview or --submit.",
|
|
160
|
+
"exit_code": 2,
|
|
161
|
+
"details": {
|
|
162
|
+
"preview": false,
|
|
163
|
+
"submit": false
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Current error code families include:
|
|
170
|
+
|
|
171
|
+
- `invalid_arguments`
|
|
172
|
+
- `config_load_failed`
|
|
173
|
+
- `config_already_exists`
|
|
174
|
+
- `unknown_profile`
|
|
175
|
+
- `connectivity_check_failed`
|
|
176
|
+
- `account_query_failed`
|
|
177
|
+
- `order_query_failed`
|
|
178
|
+
- `order_operation_failed`
|
|
179
|
+
- `market_data_request_failed`
|
|
180
|
+
|
|
181
|
+
## Operational notes
|
|
182
|
+
|
|
183
|
+
### Prefer paper trading first
|
|
184
|
+
|
|
185
|
+
Use `gateway-paper` or `paper` while validating commands that submit or cancel real orders.
|
|
186
|
+
|
|
187
|
+
### Submit is explicit
|
|
188
|
+
|
|
189
|
+
`buy` and `sell` require exactly one of:
|
|
190
|
+
|
|
191
|
+
- `--preview`
|
|
192
|
+
- `--submit`
|
|
193
|
+
|
|
194
|
+
This prevents accidental live order placement from a default command path.
|
|
195
|
+
|
|
196
|
+
### Run same-profile validations serially
|
|
197
|
+
|
|
198
|
+
If multiple CLI processes connect to the same TWS or IB Gateway profile with the same fixed `client_id`, IBKR can reject or interfere with the second connection.
|
|
199
|
+
|
|
200
|
+
For validation and manual testing, prefer running commands sequentially per profile unless you intentionally assign unique client IDs.
|
|
201
|
+
|
|
202
|
+
### Market data fallback
|
|
203
|
+
|
|
204
|
+
`quote` automatically falls back from live market data to delayed market data when live prices are unavailable.
|
|
205
|
+
|
|
206
|
+
### Command name conflicts
|
|
207
|
+
|
|
208
|
+
This package installs the command `ibkr`.
|
|
209
|
+
|
|
210
|
+
If your machine already has another CLI exposing the same command name, uninstall the old tool or adjust your `PATH` so that this package's `ibkr` entrypoint is the one your shell resolves first.
|
|
211
|
+
|
|
212
|
+
## Development
|
|
213
|
+
|
|
214
|
+
Install in editable mode:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python -m pip install -e .
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Install in editable mode with optional test dependencies:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python -m pip install -e ".[test]"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Run directly from source if needed:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
python -m ibkr_cli.app --help
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Run the offline test suite:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
python -m unittest discover -s tests -v
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The packaged entrypoint for installed users is:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
ibkr --help
|
|
242
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ibkr-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A local-first CLI for Interactive Brokers"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "wangding"},
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"ib_async>=2.1,<3",
|
|
18
|
+
"platformdirs>=4.2,<5",
|
|
19
|
+
"pydantic>=2.6,<3",
|
|
20
|
+
"rich>=13.7,<14",
|
|
21
|
+
"tomli>=2.0,<3; python_version < '3.11'",
|
|
22
|
+
"typer>=0.12,<1",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 3 - Alpha",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/wangding/ibkr-cli"
|
|
38
|
+
Repository = "https://github.com/wangding/ibkr-cli"
|
|
39
|
+
Issues = "https://github.com/wangding/ibkr-cli/issues"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
test = [
|
|
43
|
+
"pytest>=8,<9",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
ibkr = "ibkr_cli.app:app"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools]
|
|
50
|
+
package-dir = {"" = "src"}
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.packages.find]
|
|
53
|
+
where = ["src"]
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
minversion = "8.0"
|
|
57
|
+
testpaths = ["tests"]
|
ibkr_cli-0.1.0/setup.cfg
ADDED
ibkr_cli-0.1.0/setup.py
ADDED