jvinhit//lab

Search posts

Type to search across journal entries.

navigate open esc close

Đầu tư Cổ phiếu · Phần 27 — Market microstructure và execution chuyên nghiệp

Hiểu order book, spread, queue, partial fill, adverse selection, slippage và market impact; xây execution plan và transaction-cost analysis cho trader.

Bạn dự định mua ở 50.000, backtest ghi 50.000, nhưng live fill trung bình 50.250; khi bán gấp lại nhận 49.700. Edge không biến mất trong phân tích kỹ thuật. Nó bị spread, urgency, queue, adverse selection và impact ăn mất.

Phần 26 mô hình execution. Bài này giải thích cơ chế bên dưới và biến “mua quanh đây” thành một execution plan có benchmark, tolerance và post-trade review.

1. Giá không phải một điểm

Tại một thời điểm:

Best bid: 49.900 × 8.000 cp
Best ask: 50.000 × 3.000 cp
Midquote: (49.900 + 50.000) / 2 = 49.950
Quoted spread: 100 = 20 bps so với mid

Market buy 5.000 cổ phiếu không nhất thiết fill 50.000; chỉ 3.000 đang hiển thị ở ask, phần còn lại đi lên mức giá sau. Order book cũng có thể thay đổi trước khi lệnh tới nơi.

Các khái niệm:

  • Bid/ask: giá mua/bán tốt nhất hiển thị.
  • Spread: chi phí tức thời và phần bù cho liquidity provider.
  • Depth: lượng chờ ở nhiều mức giá.
  • Queue priority: thứ tự lệnh tại cùng giá theo quy tắc venue.
  • Tick size: bước giá tối thiểu.
  • Lot size: đơn vị khối lượng theo thị trường.
  • Latency: thời gian quan sát → quyết định → broker → venue → acknowledgment.

Quy tắc cụ thể khác nhau theo sở giao dịch và thời điểm. Đọc tài liệu venue/broker thay vì áp dụng máy móc mô hình Mỹ vào Việt Nam.

2. Limit hay market là trade-off

SEC Trading Basics nhấn mạnh market order không bảo đảm giá, còn limit order không bảo đảm execution.

OrderBạn kiểm soátBạn hy sinhRủi ro chính
MarketUrgency/khả năng khớpGiáSlippage, impact
LimitWorst acceptable priceKhả năng/thời điểm khớpMiss, partial fill, adverse selection
Stop-marketKích hoạt theo ngưỡngGiá sau triggerGap xuyên stop
Stop-limitTrigger + price boundKhả năng thoátKhông khớp khi cần nhất

Không có order “tốt nhất” độc lập với mục tiêu. Exit rủi ro khẩn cấp ưu tiên khác entry không gấp.

3. Maker, taker và adverse selection

Resting limit cung cấp liquidity. Marketable order lấy liquidity. Nhưng limit khớp có thể vì người phía bên kia biết/đoán giá sắp đi ngược bạn.

Bạn đặt buy limit 50.000.
Case tốt: seller thiếu kiên nhẫn; giá hồi lên.
Case xấu: tin xấu/flow bán; bạn được fill ngay trước khi giá xuống 49.500.

Đó là adverse selection. Tỷ lệ fill cao không tự động là execution tốt. SEC từng giải thích non-marketable limit orders cần được đánh giá cả execution uncertainty và khả năng được khớp khi thị trường đi bất lợi (order-execution disclosure).

4. Chi phí implementation shortfall

Chọn decision price lúc chiến lược quyết định giao dịch.

Với buy:

Execution cost = (avg_fill - decision_price) × filled_qty
Opportunity cost = (evaluation_price - decision_price) × unfilled_qty
Fees = broker + venue + tax/levy applicable
Implementation shortfall = execution + opportunity + fees

Nếu hủy phần chưa fill, không được bỏ nó khỏi đánh giá; làm vậy sẽ khiến limit strategy trông quá đẹp vì chỉ đếm lệnh được fill thuận lợi.

Benchmarks khác

  • Arrival price: quote/mid khi order tới.
  • VWAP: giá trung bình theo volume trong interval; benchmark, không phải giá chắc đạt.
  • Close/open: phù hợp mandate benchmark tương ứng nhưng dễ chịu auction risk.
  • Previous close: dễ tính, kém công bằng nếu decision sau biến động overnight.

Chọn benchmark trước, không chọn benchmark làm lệnh trông đẹp.

5. Slippage đúng dấu

Buy slippage  = fill - benchmark
Sell slippage = benchmark - fill
Slippage bps  = slippage / benchmark × 10.000

Ví dụ buy 10.000 cp, benchmark 50.000, fill 50.120:

slippage = 120 VND = 24 bps
cost = 1.200.000 VND, chưa phí

Phải báo distribution: median, P75, P90, worst; mean dễ bị vài outlier chi phối.

6. Market impact và participation

Impact tăng theo size, urgency, volatility và thanh khoản; không nhất thiết tuyến tính.

participation_rate = order_qty / market_volume_during_execution
ADV_fraction = order_notional / average_daily_value_traded

Guardrail ví dụ:

No order > 5% predicted interval volume
No position > 3 ngày thanh khoản theo participation cap
Giảm urgency nếu spread > P90 lịch sử, trừ risk exit

Không coi ADV là lời hứa. Volume có thể biến mất đúng lúc stress.

7. Queue và partial fill

Nếu 20.000 cp đã chờ trước bạn tại bid, 10.000 cp bán vào bid không làm bạn fill. Daily low “chạm limit” không chứng minh execution.

Execution policy phải nói:

Minimum acceptable fill?
Partial position có được quản lý như full position?
Stop/target tính từ actual average fill?
Order hết hạn khi nào?
Có replace không; replace có mất priority?
Unfilled quantity được ghi opportunity cost thế nào?

8. Gap, auction và halt

Overnight news có thể mở cửa ngoài stop. Auction gom order theo cơ chế venue, giá/priority khác continuous session. Trading halt làm stop không thể thực hiện.

Contingency runbook:

IF gap through stop:
  cancel stale child orders
  verify position/order state
  execute risk-exit policy với bound/urgency đã định
  không tăng size để “gỡ”

IF halt:
  freeze new related orders
  estimate portfolio stress if reopen -5/-10/-20%
  communicate/record operational state

IF broker/feed disagreement:
  trust authoritative order acknowledgments
  stop sending duplicate orders
  reconcile position before action

9. Execution plan trước lệnh

EXECUTION TICKET
Trade/play ID:
Symbol/side/total quantity:
Decision timestamp and benchmark:
Urgency: low / normal / risk-exit
Spread/depth/volatility snapshot:
Expected volume profile:
Order type and limit logic:
Child-order schedule:
Participation cap:
Max acceptable slippage:
Partial-fill rule:
Cancel/replace deadline:
Gap/halt/data contingency:
Owner and timestamp:

Ví dụ

Buy 12.000 cp; decision mid 49.950
Median daily volume 600.000; order = 2% ADV
Max participation 5%; execution window 60 phút
Limit không vượt 50.100
Cancel nếu spread >40 bps hoặc regime shock
Minimum useful fill 4.000; actual size drives portfolio heat

10. Transaction-cost analysis (TCA)

Theo từng order

decision/arrival/fill prices
spread at arrival
quantity submitted/filled/cancelled
time to first/last fill
fees
slippage bps
effective spread
post-trade price at 1/5/30 minutes hoặc phù hợp horizon

Phân nhóm

  • Play/setup.
  • Symbol/liquidity bucket.
  • Buy vs sell.
  • Time of day.
  • Volatility/regime.
  • Order type và participation band.
  • Broker/venue nếu dữ liệu cho phép.

SEC Rule 605 reporting dùng các lớp như order type/size, time-to-execution, effective và realized spread để đánh giá execution quality; các sửa đổi gần đây tiếp tục mở rộng chi tiết báo cáo (SEC Rule 605 amendments). Đây là khung Mỹ, nhưng tư duy phân nhóm và benchmark có giá trị chung.

Diagnose

PatternGiả thuyếtTest
Buy slippage xấu khi openAuction/gap/urgencyTách open vs later window
Limit fill tốt nhưng post-fill return âmAdverse selectionMarkout 1/5/30 phút
Impact tăng nhanh >5% participationCapacitySize buckets
Sell risk-exit P90 rất xấuLiquidity shockStress cost và smaller normal size

11. Execution scorecard

Hạng mụcĐiểm
Ticket đầy đủ trước order20
Tuân thủ quantity/participation20
Order type phù hợp urgency15
Không duplicate/stale order15
Fill/slippage/fees ghi đủ15
Post-trade TCA và exception15

Không thưởng trader vì fill dưới VWAP nếu họ cố tình trì hoãn và bỏ lỡ một trade tăng mạnh; opportunity cost phải được tính.

12. Lab 50 lệnh paper/pilot

  1. Lưu quote snapshot và decision price.
  2. Chọn order/urgency trước khi thấy kết quả.
  3. Mô phỏng hoặc pilot size nhỏ.
  4. Tính fill rate, shortfall, P90 slippage, adverse markout.
  5. Phân nhóm theo liquidity, volatility, time.
  6. Viết một thay đổi execution v0.2; test trên 50 lệnh mới.
MASTERY GATE
☐ Giải thích spread, depth, queue và adverse selection
☐ Tách signal alpha khỏi execution alpha/cost
☐ Tính implementation shortfall gồm unfilled quantity
☐ Có partial-fill/gap/halt runbook
☐ Báo distribution thay vì một average
☐ Biết capacity là function của liquidity và urgency

Kết luận

Execution không phải khâu hành chính sau chiến lược. Một signal chỉ trở thành position qua order book, và mọi assumption sai ở đoạn đó đi thẳng vào P&L. Trader trưởng thành biết khi nào ưu tiên giá, khi nào ưu tiên chắc chắn thoát, và đo cả chi phí của phần không khớp.

Phần 28 sẽ nâng từ rủi ro một lệnh lên cả book: exposure, correlation cluster, factor, drawdown budget, liquidity và stress scenarios.