@ibidathoillah/bittime-cli 0.1.7

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.
package/README.md ADDED
@@ -0,0 +1,294 @@
1
+ # bittime-cli
2
+
3
+ Unofficial Rust CLI for the Bittime exchange. Use it to inspect markets, manage account data, place spot orders, stream live WebSocket events, and expose the same command surface to agents through MCP.
4
+
5
+ [![Rust](https://img.shields.io/badge/Rust-2021-000000?logo=rust)](https://www.rust-lang.org/)
6
+ [![CLI](https://img.shields.io/badge/interface-terminal-2f855a)](#quick-start)
7
+ [![WebSocket](https://img.shields.io/badge/websocket-live-2563eb)](#websocket-streaming)
8
+ [![MCP](https://img.shields.io/badge/MCP-ready-7c3aed)](#mcp-server)
9
+
10
+ ## Highlights
11
+
12
+ - Public market data: ping, server time, exchange info, tickers, order book, trades, aggregate trades.
13
+ - Private account data: balances, account info, assets, order history, trade history.
14
+ - Spot trading: market and limit buy/sell, query order, cancel order, open orders.
15
+ - Funding and OTC: crypto deposit/withdraw history, OTC VA code, OTC IDR deposit and withdrawal history.
16
+ - Real-time streams: market depth, private order events, private balance events, raw user channels.
17
+ - Paper trading: local simulated balances and orders stored in `~/.config/bittime/paper_state.json`.
18
+ - Automation-friendly output: human tables by default, JSON envelopes with `-o json`.
19
+ - Credential resolution: CLI flags, environment variables, or `~/.config/bittime/config.toml`.
20
+ - Agent support: MCP server mode for tool discovery and JSON-RPC execution.
21
+
22
+ ## Installation
23
+
24
+ Install from source:
25
+
26
+ ```bash
27
+ git clone https://github.com/ibidathoillah/bittime-cli.git
28
+ cd bittime-cli
29
+ cargo install --path .
30
+ ```
31
+
32
+ Install from crates.io:
33
+
34
+ ```bash
35
+ cargo install bittime-cli
36
+ ```
37
+
38
+ Install from npm:
39
+
40
+ ```bash
41
+ npm install -g bittime-cli
42
+ ```
43
+
44
+ Run with Docker:
45
+
46
+ ```bash
47
+ docker run --rm ibidathoillah/bittime-cli --help
48
+ docker run --rm -e BITTIME_API_KEY -e BITTIME_API_SECRET ibidathoillah/bittime-cli balance
49
+ ```
50
+
51
+ Run from the checkout:
52
+
53
+ ```bash
54
+ cargo build
55
+ ./target/debug/bittime --help
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ Market data does not require credentials:
61
+
62
+ ```bash
63
+ bittime ping
64
+ bittime ticker usdt/idr
65
+ bittime orderbook usdt/idr --count 10
66
+ bittime -o json book-ticker usdt/idr
67
+ ```
68
+
69
+ Configure private API credentials:
70
+
71
+ ```bash
72
+ bittime auth set --api-key YOUR_API_KEY --api-secret YOUR_API_SECRET
73
+ bittime auth test
74
+ ```
75
+
76
+ Or use environment variables:
77
+
78
+ ```bash
79
+ export BITTIME_API_KEY=your_api_key
80
+ export BITTIME_API_SECRET=your_api_secret
81
+ ```
82
+
83
+ Credential priority:
84
+
85
+ 1. `--api-key` and `--api-secret`
86
+ 2. `BITTIME_API_KEY` and `BITTIME_API_SECRET`
87
+ 3. `~/.config/bittime/config.toml`
88
+
89
+ ## Command Reference
90
+
91
+ Global options:
92
+
93
+ ```text
94
+ bittime [OPTIONS] <COMMAND>
95
+
96
+ Options:
97
+ -o, --output <table|json> Output format [default: table]
98
+ --api-key <API_KEY> API key override
99
+ --api-secret <API_SECRET> API secret override
100
+ -v, --verbose Enable verbose logs
101
+ --host <HOST> Override API host
102
+ ```
103
+
104
+ ### Market
105
+
106
+ ```bash
107
+ bittime ping
108
+ bittime server-time
109
+ bittime exchange-info
110
+ bittime ticker usdt/idr
111
+ bittime ticker-all
112
+ bittime price usdt/idr
113
+ bittime book-ticker usdt/idr
114
+ bittime orderbook usdt/idr --count 10
115
+ bittime trades usdt/idr --count 5
116
+ bittime agg-trades usdt/idr --count 5
117
+ bittime historical-trades usdt/idr --count 5
118
+ ```
119
+
120
+ ### Account
121
+
122
+ ```bash
123
+ bittime account-info
124
+ bittime balance
125
+ bittime account-info-v2
126
+ bittime assets usdt
127
+ bittime trades-history usdt/idr
128
+ bittime trades-history-v2 usdt/idr --since 123
129
+ bittime trades-legacy usdt/idr
130
+ ```
131
+
132
+ ### Trading
133
+
134
+ ```bash
135
+ bittime order buy usdt/idr -t LIMIT -p 16000 --volume 1
136
+ bittime order sell usdt/idr -t MARKET --volume 1
137
+ bittime order cancel usdt/idr --order-id 123456
138
+ bittime order query usdt/idr --order-id 123456
139
+ bittime order open-orders usdt/idr
140
+ bittime order all-orders usdt/idr
141
+ bittime order pending-orders usdt/idr
142
+ bittime order book-orders usdt/idr --count 5
143
+ ```
144
+
145
+ Notes:
146
+
147
+ - `pending-orders` is a compatibility alias for Bittime's documented `openOrders` endpoint.
148
+ - `book-orders` returns public order book depth from Bittime's documented `depth` endpoint.
149
+
150
+ ### Funding
151
+
152
+ ```bash
153
+ bittime withdraw --asset USDT --volume 100 --address 0x... --network ERC20
154
+ bittime withdrawal status --asset usdt
155
+ bittime deposit status --asset usdt
156
+ bittime deposit va --bank-id 7
157
+ bittime deposit otc-status --count 10
158
+ bittime withdrawal otc-status --count 10
159
+ ```
160
+
161
+ ### Paper Trading
162
+
163
+ ```bash
164
+ bittime paper init --pair usdt/idr --quote-balance 100000000 --base-balance 1
165
+ bittime paper balance
166
+ bittime paper buy usdt/idr --price 16000 --volume 1
167
+ bittime paper sell usdt/idr --price 17000 --volume 1
168
+ bittime paper fill 1
169
+ bittime paper orders
170
+ bittime paper orders --all
171
+ bittime paper cancel 2
172
+ bittime paper cancel-all --pair usdt/idr
173
+ bittime paper topup IDR 5000000
174
+ bittime paper history
175
+ bittime paper status
176
+ bittime paper reset
177
+ ```
178
+
179
+ Use `--fill` on `paper buy` or `paper sell` to immediately settle an order at the supplied price.
180
+
181
+ ### WebSocket Streaming
182
+
183
+ Market depth:
184
+
185
+ ```bash
186
+ bittime ws depth usdt/idr
187
+ bittime ws depth usdt/idr --limit 1 --seconds 15
188
+ ```
189
+
190
+ Private streams:
191
+
192
+ ```bash
193
+ bittime ws orders
194
+ bittime ws balances
195
+ bittime ws user user_order_update
196
+ bittime ws user user_balance_update
197
+ ```
198
+
199
+ The WebSocket client handles Bittime's market gzip frames, market ping/pong, user-stream ping/pong, listen-key creation, and listen-key keepalive.
200
+
201
+ ### Interactive Shell
202
+
203
+ ```bash
204
+ bittime shell
205
+ ```
206
+
207
+ ### MCP Server
208
+
209
+ ```bash
210
+ bittime mcp
211
+ ```
212
+
213
+ The MCP server exposes CLI commands as machine-readable tools over JSON-RPC stdio.
214
+
215
+ ## E2E Testing
216
+
217
+ The repository includes live API smoke tests:
218
+
219
+ ```bash
220
+ ./scripts/e2e_test.sh --public
221
+ ./scripts/e2e_test.sh --private
222
+ ./scripts/e2e_test.sh --ws
223
+ ```
224
+
225
+ Environment knobs:
226
+
227
+ ```bash
228
+ BITTIME_TEST_PAIR=usdt/idr
229
+ BITTIME_TEST_COIN=usdt
230
+ BITTIME_BIN=./target/debug/bittime
231
+ ```
232
+
233
+ Latest local verification:
234
+
235
+ ```text
236
+ cargo test: 16 passed
237
+ ./scripts/e2e_test.sh --public: 22 passed
238
+ ./scripts/e2e_test.sh --private: 19 passed
239
+ ./scripts/e2e_test.sh --ws: 4 passed
240
+ ```
241
+
242
+ ## API Coverage
243
+
244
+ - REST base: `https://openapi.bittime.com`
245
+ - Market WebSocket: `wss://ws.bittime.com/market/ws`
246
+ - User WebSocket: `wss://wsapi.bittime.com`
247
+ - API docs: https://bittime-docs.github.io/
248
+
249
+ ## Architecture
250
+
251
+ ```mermaid
252
+ graph TD
253
+ A[bittime binary] --> B[Clap command dispatcher]
254
+ B --> C[AppContext]
255
+ C --> D[BittimeClient]
256
+ C --> E[Output dispatcher JSON/Table]
257
+ D --> F[Bittime REST API]
258
+ D --> G[Bittime WebSocket streams]
259
+ B --> H[Interactive shell REPL]
260
+ B --> I[Model Context Protocol server]
261
+ ```
262
+
263
+ ## Security
264
+
265
+ - Credentials are stored with `0600` permissions when using `bittime auth set`.
266
+ - Prefer read-only API keys for account inspection and WebSocket monitoring.
267
+ - Use IP restrictions on exchange API keys when possible.
268
+ - Never commit real API keys, secrets, or listen keys.
269
+
270
+ ## Development
271
+
272
+ ```bash
273
+ cargo fmt
274
+ cargo test
275
+ cargo build
276
+ ```
277
+
278
+ ## Related Projects
279
+
280
+ If you use multiple exchanges, check out these related CLI tools built with the same architecture:
281
+
282
+ - [indodax-cli](https://github.com/ibidathoillah/indodax-cli) - CLI for Indodax
283
+ - [bittime-cli](https://github.com/ibidathoillah/bittime-cli) - CLI for Bittime
284
+ - [binance-cli](https://github.com/ibidathoillah/binance-cli) - CLI for Binance Spot
285
+ - [tokocrypto-cli](https://github.com/ibidathoillah/tokocrypto-cli) - CLI for Tokocrypto
286
+ - [kraken-cli](https://github.com/ibidathoillah/kraken-cli) - CLI for Kraken (Spot, Margin, Futures)
287
+
288
+ ## License
289
+
290
+ MIT
291
+
292
+ ## Disclaimer
293
+
294
+ This project is unofficial and is not affiliated with or endorsed by Bittime. Cryptocurrency trading is risky; review commands carefully before using write-capable API keys.
@@ -0,0 +1,15 @@
1
+ ## 🚀 Welcome to bittime-cli CLI v0.1.7
2
+
3
+ The unofficial, fast, and feature-rich command-line interface for **Bittime**.
4
+
5
+ ### 🆕 What's New in v0.1.7
6
+
7
+ - **🔄 Standardized Workflow**: Aligned with the Indodax-CLI development and release lifecycle.
8
+ - **🛡️ Security**: Improved credential management and SSL/TLS handling.
9
+ - **✨ Core Features**: Market data, private trading, and MCP support for AI agents.
10
+
11
+ ### ✨ Core Features
12
+
13
+ - **🤖 AI Agent Integration (MCP)**: Built-in Model Context Protocol server.
14
+ - **📈 Real-time Data**: WebSocket support for live market updates.
15
+ - **🛠️ Paper Trading**: Local simulated environment for testing strategies.
package/bin/bittime.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const binName = process.platform === 'win32' ? 'bittime.exe' : 'bittime';
8
+ const binPath = path.join(__dirname, binName);
9
+
10
+ if (!fs.existsSync(binPath)) {
11
+ console.error('\x1b[31mError: bittime native binary not found.\x1b[0m');
12
+ console.error(`Expected at: ${binPath}`);
13
+ console.error('\nTry reinstalling with: npm install -g bittime-cli');
14
+ console.error('Or install from Cargo: cargo install bittime-cli');
15
+ process.exit(1);
16
+ }
17
+
18
+ const child = spawn(binPath, process.argv.slice(2), {
19
+ stdio: 'inherit',
20
+ });
21
+
22
+ child.on('exit', (code) => {
23
+ process.exit(code || 0);
24
+ });
25
+
26
+ child.on('error', (err) => {
27
+ console.error(`\x1b[31mError spawning bittime binary:\x1b[0m ${err.message}`);
28
+ process.exit(1);
29
+ });
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@ibidathoillah/bittime-cli",
3
+ "version": "0.1.7",
4
+ "description": "Unofficial command-line interface for the Bittime cryptocurrency exchange",
5
+ "bin": {
6
+ "bittime": "./bin/bittime.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/install.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/ibidathoillah/bittime-cli.git"
14
+ },
15
+ "keywords": [
16
+ "bittime",
17
+ "crypto",
18
+ "cli",
19
+ "trading",
20
+ "websocket",
21
+ "mcp"
22
+ ],
23
+ "author": "Ibida Thoillah",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/ibidathoillah/bittime-cli/issues"
27
+ },
28
+ "homepage": "https://github.com/ibidathoillah/bittime-cli#readme",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
32
+ }
@@ -0,0 +1,87 @@
1
+ const fs = require('fs');
2
+ const https = require('https');
3
+ const os = require('os');
4
+ const path = require('path');
5
+
6
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
7
+ const repo = 'ibidathoillah/bittime-cli';
8
+
9
+ function targetName() {
10
+ const platform = os.platform();
11
+ const arch = os.arch();
12
+
13
+ const platforms = {
14
+ linux: 'linux',
15
+ darwin: 'macos',
16
+ win32: 'windows',
17
+ };
18
+
19
+ const arches = {
20
+ x64: 'x86_64',
21
+ arm64: 'aarch64',
22
+ };
23
+
24
+ if (!platforms[platform] || !arches[arch]) {
25
+ return null;
26
+ }
27
+
28
+ const ext = platform === 'win32' ? '.exe' : '';
29
+ return `bittime-${platforms[platform]}-${arches[arch]}${ext}`;
30
+ }
31
+
32
+ const artifact = targetName();
33
+ const binDir = path.join(__dirname, '..', 'bin');
34
+ const binName = os.platform() === 'win32' ? 'bittime.exe' : 'bittime';
35
+ const binPath = path.join(binDir, binName);
36
+
37
+ if (!artifact) {
38
+ console.warn(`Unsupported platform for prebuilt bittime binary: ${os.platform()} ${os.arch()}`);
39
+ process.exit(0);
40
+ }
41
+
42
+ fs.mkdirSync(binDir, { recursive: true });
43
+
44
+ const url = `https://github.com/${repo}/releases/download/v${pkg.version}/${artifact}`;
45
+
46
+ function download(source, destination, redirects = 0) {
47
+ console.log(`Downloading bittime-cli binary from ${source}...`);
48
+
49
+ const file = fs.createWriteStream(destination);
50
+ https
51
+ .get(source, (response) => {
52
+ if ([301, 302, 303, 307, 308].includes(response.statusCode)) {
53
+ file.close();
54
+ fs.unlink(destination, () => {});
55
+ if (redirects > 5) {
56
+ console.warn('Too many redirects while downloading bittime-cli binary.');
57
+ process.exit(0);
58
+ }
59
+ download(response.headers.location, destination, redirects + 1);
60
+ return;
61
+ }
62
+
63
+ if (response.statusCode !== 200) {
64
+ file.close();
65
+ fs.unlink(destination, () => {});
66
+ console.warn(`Binary download returned HTTP ${response.statusCode}.`);
67
+ console.warn('npm install will complete, but install Cargo manually if needed: cargo install bittime-cli');
68
+ process.exit(0);
69
+ }
70
+
71
+ response.pipe(file);
72
+ file.on('finish', () => {
73
+ file.close();
74
+ fs.chmodSync(destination, 0o755);
75
+ console.log('\x1b[32mbittime-cli binary installed successfully.\x1b[0m');
76
+ });
77
+ })
78
+ .on('error', (err) => {
79
+ file.close();
80
+ fs.unlink(destination, () => {});
81
+ console.warn(`Failed to download bittime-cli binary: ${err.message}`);
82
+ console.warn('npm install will complete, but install Cargo manually if needed: cargo install bittime-cli');
83
+ process.exit(0);
84
+ });
85
+ }
86
+
87
+ download(url, binPath);
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ set -e
3
+ PROJECT_NAME=$(grep "^name =" Cargo.toml | head -n1 | cut -d"\"" -f2)
4
+ if [ -z "$1" ]; then
5
+ VERSION=$(grep "^version =" Cargo.toml | head -n1 | cut -d"\"" -f2)
6
+ else
7
+ VERSION=$1
8
+ sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
9
+ fi
10
+ if [ -f "package.json" ]; then sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" package.json; fi
11
+ if [ -f "RELEASE_NOTES.md" ]; then
12
+ sed -i "s/Welcome to .* CLI v[0-9.]*/Welcome to $PROJECT_NAME CLI v$VERSION/" RELEASE_NOTES.md
13
+ sed -i "s/What's New in v[0-9.]*/What's New in v$VERSION/" RELEASE_NOTES.md
14
+ fi
15
+ echo "✅ $PROJECT_NAME updated to v$VERSION"
16
+ if command -v gh &> /dev/null; then
17
+ echo "Updating GitHub release v$VERSION..."
18
+ gh release edit "v$VERSION" --notes-file RELEASE_NOTES.md || \
19
+ gh release create "v$VERSION" --title "v$VERSION" --notes-file RELEASE_NOTES.md
20
+ fi
21
+