preloader
blog-post

ORDER FIX API ~ Send Market Order

author image

This is a function to send a message to place an order.

Usually, when a message describing the execution report arrives, the ExecutionReport callback will be triggered.

To simplify the process, we send market orders only and each order’s TimeInForce is set to FILL_OR_KILL.

The message type (MsgType, Tag ID: 35) is “D”. Actually, this tag field is encapsulated, only useful when you check the log file.

Usually, we will get these tag fields from the message:

  • Client Order ID (ClOrdID, Tag ID: 11)

This ID should be generated on our side(the client side). It will be returned when the execution report arrives.

order.set(new ClOrdID(clOrderId));
  • Order Type (OrdType, Tag ID: 40)

To simplify the process, we set OrdType to MARKET.

order.set(new OrdType(OrdType.MARKET));
  • Instrument Name (Symbol, Tag ID: 55)
order.set(new Symbol(symbolName));
  • Order Side (Side, Tag ID: 54)

To simplify the process, this variable describes that the order side is either Buy or Sell.

if ("BUY".equals(orderType)) {
  order.set(new Side(Side.BUY));
} else {
  order.set(new Side(Side.SELL));
}
  • Order Quantity (OrderQty, Tag ID: 38)

This variable describes the quantity of the specific order(order volume).

double orderQty = lots * 100000;
order.set(new OrderQty(orderQty));
  • Time In Force (TimeInForce, Tag ID: 59)

To simplify the process, we only send market orders. So, TimeInForce usually is set to FILL_OR_KILL.

order.set(new TimeInForce(TimeInForce.FILL_OR_KILL));
  • Transaction Time (TransactTime, Tag ID: 60)
order.set(new TransactTime());
  • Account ID (Account, Tag ID: 1)
mdr.setString(Account.FIELD, accountId);

Relevant Articles

Fintechee Online FIX API Parser

The received messages will output to the “orderlog” folder.

If you want to parse them, please use Fintechee Online FIX Parser.

Fintechee FIX API Trading Platform Individual Version

If you want to trade via FIX API, please use Fintechee FIX API Trading Platform Individual Version(Paid Version).

If you have a Github / Youtube account, you can get a free license for the paid version(No Charge)!

If you have no Github / Youtube account, you can still use Fintechee FIX API Trading Platform Bridge Version(Free Forever)!

If you are working for financial institutions, you can choose Fintechee FIX API Trading Platform Institution Version(White Label License).

Github Repository

Please access our Github repository to get the latest source codes.

The Entire Source Codes to sendMarketOrder

public void sendMarketOrder(String clOrderId, String symbolName, double lots, String orderType, double price) {
  try {
    NewOrderSingle order = new NewOrderSingle();

    order.set(new ClOrdID(clOrderId));
    order.set(new OrdType(OrdType.MARKET));
    order.set(new Symbol(symbolName));

    if ("BUY".equals(orderType)) {
      order.set(new Side(Side.BUY));
    } else {
      order.set(new Side(Side.SELL));
    }

    double orderQty = lots * 100000;
    order.set(new OrderQty(orderQty));

    order.set(new TimeInForce(TimeInForce.FILL_OR_KILL));

    order.set(new TransactTime());

    order.setString(Account.FIELD, accountId);

    send(order);
  } catch (Exception e) {
    e.printStackTrace();
    logger.error(e.getMessage());
  }
}

Recent Articles

blog-post

FIX API Starter Application Class

This is the FIX API Starter Application Class. It includes: A method to be called to start FIX API Data session A …

Get Free Demo FIX API Account

We provide free demo FIX API accounts.

Book One
*