본문으로 건너뛰기
HTTP API거래

주문 넣기

요청 만들기

값을 바꾸면 명령이 함께 바뀝니다. 토큰은 여기에 입력하지 않습니다. 명령은 SPECTRE_LOCAL_API_TOKEN 환경 변수에서 토큰을 읽습니다. 자신의 터미널에서 실행하세요.

명령
curl -X POST 'http://127.0.0.1:48180/v1/orders' \
  -H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "connection_id": 12,
  "instrument": "binance:futures:BTCUSDT",
  "side": "buy",
  "type": "limit",
  "price": "67000.1",
  "size": "0.012",
  "reduce_only": false,
  "post_only": false,
  "time_in_force": "gtc",
  "client_key": "bot-42"
}'
POST
/orders

지정가 또는 시장가 주문을 넣습니다. 같은 client_key로 반복하면 이전 응답을 반환하고 두 번째 주문은 넣지 않습니다. 터미널은 최근 키 1000개를 기억합니다.

인증

bearerToken trading:write
header인증Bearer <token>

Local API 토큰입니다: spt_와 16진수 문자 64개. Settings App → 일반 → Local API에서 복사합니다. Authorization 헤더로만 받습니다. 작업에 나열된 이름은 그 작업에 필요한 권한입니다. 터미널의 토큰에는 모든 권한이 있습니다.

권한: trading:write

요청 본문

application/json
  1. body
connection_id*integer
형식int64
instrument*string

종목 주소, exchange:market:symbol.

side*string
값 범위"buy""sell"
type*string

지정가 주문에는 price가 필요합니다. 시장가 주문은 가격을 받지 않습니다.

값 범위"limit""market"
price?string

10진수 문자열입니다.

size?string

기준 코인 단위의 수량입니다. size와 notional 중 정확히 하나만 지정합니다.

notional?string

호가 통화 금액입니다. size와 notional 중 정확히 하나만 지정합니다.

reduce_only?boolean
기본값false
post_only?boolean
기본값false
time_in_force?string

지정하지 않으면 거래소의 기본값이 적용됩니다.

값 범위"gtc""ioc""fok""post_only"
client_key?string

클라이언트의 멱등성 키입니다.

응답 본문

터미널이 명령을 접수했습니다. 주문은 account.orders에 key로 나타납니다.

application/json
  1. response

모든 거래, 트리거, 레버리지 명령의 응답입니다.

accepted*boolean

거래소가 아니라 터미널이 접수했습니다.

operation_id*string

터미널의 거래 작업 로그에 기록되는 작업의 id입니다. 넣은 주문의 키는 t-에 이 id를 붙인 것입니다.

key*|

넣은 주문의 키 t-… 또는 넣은 트리거의 키입니다: sl_…, tp_… 또는 stop_…. 취소, 수정, 레버리지의 경우 null입니다.

connection_id*integer
형식int64
instrument*string
요청 예제
curl -X POST 'http://127.0.0.1:48180/v1/orders' \  -H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \  -H 'Content-Type: application/json' \  -d '{  "connection_id": 12,  "instrument": "binance:futures:BTCUSDT",  "side": "buy",  "type": "limit",  "price": "67000.1",  "size": "0.012",  "reduce_only": false,  "post_only": false,  "time_in_force": "gtc",  "client_key": "bot-42"}'
응답 예제
{  "accepted": true,  "operation_id": "173029440000000001",  "key": "t-173029440000000001",  "connection_id": 12,  "instrument": "binance:futures:BTCUSDT"}