Place an order (previously quoted)

Goal

Place a previously quoted order and query its progress through the order workflow.

This guide uses the previously quoted (PQ) order type: you submit the order with a reference to a tradable rate you requested and received.

Also, this guide uses the Get spot prices workflow for tradable rates, but you can substitute the Get fixed-period market data workflow in Step 2.

Prerequisites

  • Your REST API app.
  • Integral API login with trading permission.
  • Your organization provisioned with at least one provider who streams ESP spot prices.

Steps

Step 1: Login
Step 2: Get rate
Step 3: Place order
Step 4: Query order

Step 1: Login

Use the Login and get token endpoint.

See the related Login tutorial.

Your access token is in SSO_TOKEN of the response header. Your token is valid for limited time.

Pass the SSO_TOKEN cookie value with all of your subsequent API requests.

application/json
{ "user": "apiUserId", "pass": "This is a long password!", "org": "apiOrganizationId" }
Response
application/json
{ "status": "OK", "errorCode": null, "responseTuples": null, "expiryTime": 1665490480729, "serverUTCTime": 1665490420730 }

Step 2: Get spot prices

Use the Get spot rate by symbol endpoint.

See the related Get spot prices tutorial.

Use the rateId attribute of the JSON response in the next step.

No request payload
Response
application/json
{ "symbol": "EUR/USD", "bid": 1.1863, "offer": 1.18638, "bidLimit": 1000000, "offerLimit": 1000000, "time": 1602536120080, "rateId": "2022-11-10-EURUSD-SPOT-435ef73249" }

Step 3: Place order

Use the Place order endpoint.

Send the rateId from the ESP rate in the rateId parameter of the request body.

To get your order status, you must query your order. After the initial success/fail response, status updates are not pushed to you.

Response
application/json

Successful limit order

{ "coId": "8932452311944", "type": "Limit", "timeInForce": "IOC", "side": "Buy", "currency": "EUR", "symbol": "EUR/USD", "size": 1000000, "org": "BrokerOrg1", "price": 1.0971678, "orderId": "4820276016", "userFullName": "User1@pfOrg", "action": "place", "status": "RECEIVED" }

Step 4: Query order

To get your order status, you must query your order. After the initial success/fail response, status updates are not pushed to you.

Use one of the following endpoints:

The diagram shows the values returned in the status field in the response and their context in the order workflow.

Order status transition (PQ order, success)
Place order
Query order
Query order
Query order
Query order
Status = RECEIVED
HTTP code 202
Status = NEW
(Intermediate state)
HTTP code 200
Status = FILLED
HTTP code 200
Status = REJECTED
HTTP code 200
Order status transition (failure)
Place order
Error object
HTTP code 400/5xx
const id = '4820276016';
const resp = await fetch(
  `https://docs.fxinside.net/_mock/openapi/integral-api-reference/rest/v2/orders/${id}`,
  {
    method: 'GET',
    headers: {
      SSO_TOKEN: 'YOUR_API_KEY_HERE'
    }
  }
);

const data = await resp.text();
console.log(data);
Response
application/json

Successful limit order

{ "coId": "8932452311944", "type": "Limit", "timeInForce": "IOC", "side": "Buy", "currency": "EUR", "symbol": "EUR/USD", "size": 1000000, "org": "BrokerOrg1", "price": 1.0971678, "orderId": "4820276016", "userFullName": "User1@pfOrg", "action": "place", "status": "RECEIVED" }