@2oolkit/kiwoom-cli 0.1.0

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,78 @@
1
+ # Market Data Reference
2
+
3
+ All market-data commands accept `-o, --output <table|json>`. Use `json` for parsing.
4
+
5
+ ## Current price & quotes
6
+
7
+ ```bash
8
+ kiwoom-cli market price 005930 # ka10007 — name, price, change, OHLC, top-of-book
9
+ kiwoom-cli stock info 005930 # ka10001 — fundamentals + price (PER/EPS/ROE/PBR/BPS)
10
+ kiwoom-cli market orderbook 005930 # ka10004 — 10-level bid/ask ladder
11
+ kiwoom-cli market after-hours 005930 # ka10087 — after-hours single price
12
+ ```
13
+
14
+ ### Reading prices
15
+ Quote/chart price fields carry a **direction sign** relative to the previous close:
16
+ `-353750` means the price is **353,750**, trading *below* the prior close. The CLI displays the
17
+ magnitude (`353,750`) and reports `change` / `changeRate` separately. In JSON the raw signed string
18
+ is preserved — strip a leading `+`/`-` to get the value.
19
+
20
+ `pred_pre_sig` / `pre_sig` codes: `1`=상한, `2`=상승, `3`=보합, `4`=하한, `5`=하락.
21
+
22
+ ## Order book (`market orderbook`)
23
+
24
+ 10 levels each side. JSON `-o json` returns the raw ka10004 payload with the irregular field
25
+ naming (level 1 = `sel_fpr_*` / `buy_fpr_*`, levels 2–10 = `sel_Nth_pre_*` / `buy_Nth_pre_*`).
26
+ The table view renders an aligned ladder (asks top, bids bottom) plus total ask/bid quantities.
27
+
28
+ ## Trades & strength
29
+
30
+ ```bash
31
+ kiwoom-cli market trades 005930 # ka10003 — recent tick executions
32
+ kiwoom-cli market strength 005930 # ka10046 — intraday 체결강도 series
33
+ kiwoom-cli market strength 005930 --daily # ka10047 — daily 체결강도 series
34
+ kiwoom-cli market daily 005930 -d 20260622 # ka10086 — daily price history (+investor flows)
35
+ kiwoom-cli market inst-foreign 005930 -s 20260601 -e 20260622 # ka10045
36
+ ```
37
+
38
+ ## Charts
39
+
40
+ | Timeframe | Command | TR | Scope option |
41
+ |---|---|---|---|
42
+ | Tick | `chart tick <code> -s <n>` | ka10079 | ticks 1/3/5/10/30 |
43
+ | Minute | `chart min <code> -i <n>` | ka10080 | minutes 1/3/5/10/15/30/45/60 |
44
+ | Daily | `chart day <code> -d <YYYYMMDD>` | ka10081 | base date |
45
+ | Weekly | `chart week <code>` | ka10082 | base date |
46
+ | Monthly | `chart month <code>` | ka10083 | base date |
47
+ | Yearly | `chart year <code>` | ka10094 | base date |
48
+
49
+ Common: `-n <count>` caps displayed rows (default 50); `--raw` returns unadjusted prices
50
+ (`upd_stkpc_tp=0`). Charts are returned latest-first. Item time fields: `cntr_tm`
51
+ (tick/minute, YYYYMMDDHHMMSS) or `dt` (period, YYYYMMDD).
52
+
53
+ ```bash
54
+ kiwoom-cli chart min 005930 -i 5 -n 30 -o json
55
+ kiwoom-cli chart day 005930 -n 60
56
+ ```
57
+
58
+ ## Rankings
59
+
60
+ ```bash
61
+ kiwoom-cli ranking fluctuation -s 1 # ka10027 — 1=상승률,2=상승폭,3=하락률,4=하락폭,5=보합
62
+ kiwoom-cli ranking volume -s 1 # ka10030 — 1=거래량,2=거래회전율,3=거래대금
63
+ kiwoom-cli ranking amount # ka10032 — top trade value
64
+ kiwoom-cli ranking surge -s 1 # ka10023 — volume surge
65
+ kiwoom-cli ranking prev-volume # ka10031 — prior-day volume
66
+ ```
67
+ Flags: `-m 000=all/001=KOSPI/101=KOSDAQ`, `-x 1=KRX/2=NXT/3=unified`.
68
+
69
+ ## Sectors / industry
70
+
71
+ ```bash
72
+ kiwoom-cli sector codes # ka10101 — list valid industry codes (inds_cd)
73
+ kiwoom-cli sector all # ka20003 — every sector index
74
+ kiwoom-cli sector price -m 0 -c 001 # ka20001 — one index (001=종합 KOSPI)
75
+ kiwoom-cli sector stocks -c 001 # ka20002 — constituents
76
+ kiwoom-cli sector daily -c 001 # ka20009 — daily index history
77
+ ```
78
+ `-m 0=KOSPI/1=KOSDAQ/2=KOSPI200`. Common codes: `001`=종합(KOSPI), `101`=종합(KOSDAQ).
@@ -0,0 +1,99 @@
1
+ # Trading Reference
2
+
3
+ > ⚠️ On the `real` environment these commands place **live orders with real money**.
4
+ > Switch to the simulation server first: `kiwoom-cli config set --env mock`.
5
+ > Every CLI order prompts for confirmation unless you pass `-y/--yes`.
6
+
7
+ ## Place orders
8
+
9
+ ```bash
10
+ # Limit buy 1 share of 005930 at 70,000 KRW
11
+ kiwoom-cli order buy 005930 1 -p 70000
12
+
13
+ # Market sell 1 share (omit -p for a market order)
14
+ kiwoom-cli order sell 005930 1
15
+
16
+ # Explicit order type
17
+ kiwoom-cli order buy 005930 1 -p 70000 -t 0 # 0 = limit
18
+ kiwoom-cli order buy 005930 1 -t 3 # 3 = market
19
+ ```
20
+
21
+ ### Order type codes (`-t` / `trde_tp`)
22
+
23
+ | Code | Meaning | | Code | Meaning |
24
+ |---|---|---|---|---|
25
+ | `0` | 보통 (limit) | | `20` | 보통 FOK |
26
+ | `3` | 시장가 (market) | | `23` | 시장가 FOK |
27
+ | `5` | 조건부지정가 | | `26` | 최유리 FOK |
28
+ | `6` | 최유리지정가 | | `28` | 스톱지정가 (stop-limit) |
29
+ | `7` | 최우선지정가 | | `29` | 중간가 |
30
+ | `10` | 보통 IOC | | `30` | 중간가 IOC |
31
+ | `13` | 시장가 IOC | | `31` | 중간가 FOK |
32
+ | `16` | 최유리 IOC | | `61/62/81` | pre/after/post off-hours |
33
+
34
+ - Market types (`3`, `13`, `23`) must **not** include `-p`; the price is sent empty.
35
+ - Limit-style types require `-p`.
36
+ - If `-t` is omitted: a `-p` implies limit (`0`), no `-p` implies market (`3`).
37
+
38
+ ## Modify & cancel
39
+
40
+ ```bash
41
+ # Modify a resting order to new qty/price
42
+ kiwoom-cli order modify 0000139 005930 1 71000
43
+
44
+ # Cancel all remaining of an order
45
+ kiwoom-cli order cancel 0000139 005930
46
+
47
+ # Cancel a partial quantity
48
+ kiwoom-cli order cancel 0000139 005930 -q 1
49
+ ```
50
+ The `<orderNo>` is the order number returned when the order was placed (or from
51
+ `kiwoom-cli account open-orders`). The exchange (`-x`) must match the original order.
52
+
53
+ ## Exchange routing (`-x` / `dmst_stex_tp`)
54
+
55
+ | Value | Meaning |
56
+ |---|---|
57
+ | `KRX` | Korea Exchange (default) |
58
+ | `NXT` | Nextrade ATS |
59
+ | `SOR` | Smart Order Routing (best execution across KRX + NXT) |
60
+
61
+ ## Credit (margin) orders
62
+
63
+ Add `--credit` to route to the credit order TRs (`/api/dostk/crdordr`):
64
+
65
+ ```bash
66
+ kiwoom-cli order buy 005930 1 -p 70000 --credit
67
+ kiwoom-cli order sell 005930 1 -p 72000 --credit --credit-deal 33 --loan-date 20260102
68
+ ```
69
+ - `--credit-deal` (신용거래구분): `33`=융자, `99`=융자합 (sell only).
70
+ - `--loan-date` (대출일, YYYYMMDD): required when repaying a specific loan tranche.
71
+
72
+ ## Confirmation flow
73
+
74
+ Each order prints a summary, e.g.:
75
+ ```
76
+ BUY 005930 qty 1 @ 70000 type 0(보통(지정가/limit)) [KRX] on REAL ⚠ REAL MONEY
77
+ Proceed? (y/N):
78
+ ```
79
+ Answer `y` to submit, anything else to abort. Pass `-y/--yes` to skip the prompt in scripts.
80
+
81
+ ## MCP order tools
82
+
83
+ `place_order`, `modify_order`, `cancel_order` accept the same parameters plus a **`confirm`**
84
+ boolean. Without `confirm: true` they return a preview and submit nothing — so an AI agent
85
+ cannot place a live order by accident.
86
+
87
+ ```jsonc
88
+ // place_order args
89
+ { "side": "buy", "code": "005930", "qty": "1", "price": "70000", "confirm": false } // preview
90
+ { "side": "buy", "code": "005930", "qty": "1", "price": "70000", "confirm": true } // submits
91
+ ```
92
+
93
+ ## After ordering
94
+
95
+ Confirm fills with the real-time open-orders / executions TRs:
96
+ ```bash
97
+ kiwoom-cli account open-orders
98
+ kiwoom-cli account executions
99
+ ```