FINTERACTIONS.COM RESTAPI
  • OVERVIEW
  • VERIFICATION
  • SECURITIES
  • TRANSACTIONS
  • ORDERS
  • SIMPLIFIED ORDERS
  • BOOK SNAPSHOT
Powered by GitBook
On this page

ORDERS

This section provides the REST API endpoints for managing orders in the Fundamental Interactions market center technology API. The API allows subscribers to perform various operations related to orders, including retrieving all orders, retrieving a specific order, and adding a new order.

Endpoints

1. Get User Orders

  • HTTP Request Type: GET

  • Route: /firestapi/orders

  • URL / Body Parameters:

    • Required:

      • userid - The user ID for whom the orders are being retrieved.

    • Optional:

      • security - The security symbol to filter orders.

      • fromtime - Unix time in milliseconds since the epoch (January 1, 1970).

  • Info: This endpoint returns all orders of a certain user. It will return a maximum of 1000 records.

  • HTTPS Body Example:

json

{
  "userid": "runzhuo.li@fundamentalinteractions.com",
  "security": "TESTN",
  "fromtime": 1671195975792
}

WS Example:

json

{
  "type": "querymultiorders",
  "userid": "runzhuo.li@fundamentalinteractions.com",
  "security": "TESTN",
  "fromtime": 1671195975792
}

2. Get Order by Reference Number

  • HTTP Request Type: GET

  • Route: /firestapi/orders/:refno

  • URL / Body Parameters: :refno - The reference number of the order.

  • Info: This endpoint returns the details of one order.

  • HTTPS Body Example: N/A

  • WS Example:

json

{
  "type": "queryorder",
  "refno": "123456"
}

3. Add New Order

  • HTTP Request Type: POST

  • Route: /firestapi/orders/addorder

  • URL / Body Parameters:

    • Required:

      • security: "TESTJ"

      • side: "B" (Buy) or "S" (Sell)

      • qty: The quantity to buy or sell.

      • price: The unit price

      • ordertype: "LMT" (Limit), "POST" (Post Only), "ICEBERG", "STOP", "MKT" (Market)

      • If ordertype:"ICEBERG", displayqty is required.

      • If ordertype:"STOP", stopprice is required.

      • tif: "GTC" (Good Till Cancelled), "IOC" (Immediate Or Cancel), "GTT" (Good Till Time), "FOK" (Fill Or Kill), "DAY" (Day)

      • tif: "GTT" If set to GTT we also need input exptime

  • Info: Adds a new order.

  • HTTPS Body Example:

json

{
  "security": "TESTJ",
  "side": "B",
  "qty": 100,
  "price": 50,
  "ordertype": "LMT",
  "tif": "GTC"
}

WS Example:

json

{
  "type": "addorder",
  "security": "TESTJ",
  "side": "B",
  "qty": 100,
  "price": 50,
  "ordertype": "LMT",
  "tif": "GTC",
}

Example Implementation in Express.js

Here's an example of how you might implement these endpoints in an Express.js application:

javascript

const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');

const app = express();

app.use(bodyParser.json());
app.use(cookieParser());
app.use(session({
  secret: 'your_secret_key',
  resave: false,
  saveUninitialized: true,
  cookie: { secure: true } // Use secure cookies in production
}));

// Dummy order data for demonstration purposes
const orders = [
  { refno: '1', userid: 'runzhuo.li@fundamentalinteractions.com', security: 'TESTN', side: 'B', qty: 100, price: 50, ordertype: 'LMT', tif: 'GTC', timestamp: 1671195975792 },
  // Add more orders as needed
];

// Get User Orders
app.get('/firestapi/orders', (req, res) => {
  const { userid, security, fromtime } = req.query;

  let userOrders = orders.filter(order => order.userid === userid);

  if (security) {
    userOrders = userOrders.filter(order => order.security === security);
  }

  if (fromtime) {
    const fromTimeNum = parseInt(fromtime, 10);
    userOrders = userOrders.filter(order => order.timestamp >= fromTimeNum);
  }

  userOrders = userOrders.slice(0, 1000); // Return a maximum of 1000 records

  res.status(200).json(userOrders);
});

// Get Order by Reference Number
app.get('/firestapi/orders/:refno', (req, res) => {
  const { refno } = req.params;
  const order = orders.find(o => o.refno === refno);
  if (order) {
    res.status(200).json(order);
  } else {
    res.status(404).send('Order not found');
  }
});

// Add New Order
app.post('/firestapi/orders/addorder', (req, res) => {
  const { security, side, qty, price, ordertype, tif, ioi, negotiate } = req.body;

  // Perform necessary validations here
  const newOrder = {
    refno: (orders.length + 1).toString(),
    token: req.session.sessionToken,
    security,
    side,
    qty,
    price,
    ordertype,
    tif,
    timestamp: Date.now()
  };

  orders.push(newOrder);
  res.status(201).json(newOrder);
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

This example sets up the specified routes using Express.js and handles retrieving user orders, retrieving an order by reference number, and adding new orders. It includes necessary validations and error handling for the endpoints.

PreviousTRANSACTIONSNextSIMPLIFIED ORDERS

Last updated 9 months ago