Quanta Docs

Tài liệu Quanta hoàn chỉnh cho Quant Studio

Khối Act & Risk · intermediate · 7 phút

Khối Act

Khối act: enter, close, flatten

#act#execution#v2

Khối `act:`

Thay vì gọi buy() hay sell(), Quanta v2 khuyến nghị cú pháp ra lệnh tự nhiên. Engine biên dịch chúng xuống primitive an toàn cho Backtest/Live. Engine cũng chấp nhận alias synonym bên dưới.

Hành độngCú pháp Quanta StoryAlias chấp nhận
Vào long % NAVenter long with wnav 5pctenter buy with wnav 5pct
Vào long cố địnhenter long with size 1 (1 HĐ/cp)enter buy with size 1
Vào short % NAVenter short with wnav 3pctenter sell with wnav 3pct
Vào short cố địnhenter short with size 5000 (5000 cp)enter sell with size 5000
Đóng longclose long tag "Cắt Lỗ"close buy
Đóng shortclose shortclose sell
Đóng hếtclose all / flatten all
Đính kèm nhãnThêm tag "..." ở cùng dòng hoặc note "..." ở dòng dưới

Nhóm synonym

  • Long: buy()long()enter longenter buyclose shortclose sell
  • Short: sell()short()enter shortenter sellclose longclose buy

Debug Console

Dùng print(...) trong logics: / act: để ghi giá trị ra Console (nút >_ góc dưới chart):

quanta
logics:
  rsi14 = rsi(c, 14)
  print("rsi", rsi14)
  print("last3", rsi14, bars: 3)

Ví dụ (canonical + một alias):

quanta
act:
  when buy_cond and not position.is_long:
    qty = position_size(2pct, atr(h,l,c,14)*2)
    enter long with size qty tag "Breakout"
  
  when position.is_long and c < sma(c, 50):
    close long tag "Trend Broken"
    note "Đóng do giá rớt dưới MA50"

  # alias tương đương enter long / close short:
  when cover_short:
    enter buy with wnav 5pct tag "Alias entry"
Trợ lý Quanta"Học nhanh hơn, hiệu quả hơn cùng AI"

Xin chào! Tôi là trợ lý học ngôn ngữ Quanta. Hỏi tôi về cú pháp, hàm, hoặc cách viết một chiến lược cụ thể (ví dụ: "Làm sao để xác định đỉnh đáy để vẽ trendline?").