Metadata-Version: 2.1
Name: shioaji-cli
Version: 1.7.9
Summary: Shioaji standalone CLI and local HTTP API server
Author-email: yvictor <yvictor3141@gmail.com>
Project-URL: Homepage, https://sinotrade.github.io/
Project-URL: Documentation, https://sinotrade.github.io/
Project-URL: Repository, https://github.com/Sinotrade/Shioaji
Project-URL: Changelog, https://sinotrade.github.io/release/
Description-Content-Type: text/markdown

# shioaji-cli
![shioaji-logo](https://sinotrade.github.io/img/shioaji-mark-on-light-256.png)![sinopac-logo](https://www.sinotrade.com.tw/Images/logo.png)

[![PyPI - Status](https://img.shields.io/pypi/v/shioaji-cli.svg?style=for-the-badge)](https://pypi.org/project/shioaji-cli)
[![doc](https://img.shields.io/badge/docs%20-passing-orange.svg?style=for-the-badge)](https://sinotrade.github.io/)
[![Telegram](https://img.shields.io/badge/chat-%20on%20telegram-blue.svg?style=for-the-badge)](https://t.me/joinchat/973EyAQlrfthZTk1)
[![Discord](https://img.shields.io/badge/chat-%20on%20discord-5865F2.svg?style=for-the-badge)](https://discord.gg/5nzmWCTnG7)

The standalone `shioaji` command-line tool and local HTTP API server of
[Shioaji](https://sinotrade.github.io/), SinoPac Securities' trading API for
Taiwan stocks, futures and options.

It is a single native binary: it does not depend on your Python version
(free-threaded 3.14t included) and carries no Python extension. Its version is
always the same as the [`shioaji`](https://pypi.org/project/shioaji/) package.

## Install

```bash
uv tool install shioaji-cli          # or pin a release line: "shioaji-cli==1.7.*"
shioaji --help
```

One-off use without installing:

```bash
uvx --from shioaji-cli shioaji server start
```

Install either `shioaji-cli` or the `shioaji` Python package as a tool, not
both: both provide the same `shioaji` command. Use `shioaji` instead when you
also need the Python API.

## Quick start

Put your API key in the environment or a `.env` file in the working directory:

```bash
SJ_API_KEY=your-api-key
SJ_SEC_KEY=your-secret-key
```

Start the local server. It runs in **simulation mode by default**:

```bash
shioaji server start              # simulation
shioaji server check              # shows the mode and auth status
shioaji server start --production # real trading; place orders with care
shioaji server stop
```

Other commands start the server in the background on first use:

```bash
shioaji auth accounts
shioaji contracts get 2330
shioaji data ticks --code 2330
shioaji order --help
```

Output is TOON by default; add `-f json` for JSON.

## Local HTTP API

While running, the server exposes the full trading API over HTTP with SSE
streaming at `http://127.0.0.1:8080`, so any language can use it. Interactive
API docs are at `/docs`, the OpenAPI document at `/openapi.json`, and a web
dashboard at `/`.

Common settings (environment variables):

| Variable | Default | Meaning |
|---|---|---|
| `SJ_PRODUCTION` | `false` | Production instead of simulation |
| `SJ_HTTP_ADDR` | `127.0.0.1:8080` | Bind address |
| `SJ_CA_PATH`, `SJ_CA_PASSWD` | | CA certificate for production orders |
| `SJ_RECEIVE_WINDOW` | `30000` | Login receive window in ms; raise it on `Sign data is timeout` |
| `SJ_LOG_DIR` | `~/.shioaji/logs` | Daily server log files, kept 14 days |

## Links

- Documentation: https://sinotrade.github.io/
- Release notes: https://sinotrade.github.io/release/
- Issues: https://github.com/Sinotrade/Shioaji/issues
