com.lmax.api.order
Class ClosingOrderSpecification

java.lang.Object
  extended by com.lmax.api.order.ClosingOrderSpecification
All Implemented Interfaces:
com.lmax.api.internal.Request

public class ClosingOrderSpecification
extends java.lang.Object
implements com.lmax.api.internal.Request

Closing Order Specification. Allows you to place an order which closes out a given quantity, either against an instrument position, or against a specific order.


Constructor Summary
ClosingOrderSpecification(java.lang.String instructionId, long instrumentId, FixedPointNumber quantity)
          Construct a ClosingOrderSpecification.
ClosingOrderSpecification(java.lang.String instructionId, long instrumentId, java.lang.String originalInstructionId, FixedPointNumber quantity)
          Construct a ClosingOrderSpecification.
 
Method Summary
 java.lang.String getUri()
          The close position uri.
 void setInstructionId(java.lang.String instructionId)
          Set the user correlation ID for this closing order.
 void setInstrumentId(long instrumentId)
          Set the instrument for the position to place the closing order against.
 void setOriginalInstructionId(java.lang.String originalInstructionId)
          Setting an originalInstructionId on the specification means this closing order will close some or all of an existing open order with the given originalInstructionId.
 void setQuantity(FixedPointNumber quantity)
          Set the quantity of the close specification to the specified value.
 java.lang.String toString()
          A readable String representation of the ClosingOrderSpecification.
 void writeTo(com.lmax.api.internal.xml.StructuredWriter writer)
          Internal: Output this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClosingOrderSpecification

public ClosingOrderSpecification(java.lang.String instructionId,
                                 long instrumentId,
                                 FixedPointNumber quantity)
Construct a ClosingOrderSpecification. This allows you to close a quantity of your position on a given instrument by placing a market order in the opposite direction of your existing position.

Parameters:
instructionId - The user-defined correlation id
instrumentId - The id of the instrument for the order book to close position on
quantity - The quantity to close. A signed value, where the sign indicates the side of the market that order is placed. Positive implies a buy order, where as negative is a sell

ClosingOrderSpecification

public ClosingOrderSpecification(java.lang.String instructionId,
                                 long instrumentId,
                                 java.lang.String originalInstructionId,
                                 FixedPointNumber quantity)
Construct a ClosingOrderSpecification. This constructor allows you to specify the instruction ID (originalInstructionId) of a specific order to close out against, and places a market order in the opposite direction of your existing order.

Parameters:
instructionId - The user-defined correlation id
instrumentId - The id of the instrument for the order book to close position on
originalInstructionId - the instruction ID of the original order to close
quantity - The quantity to close. A signed value, where the sign indicates the side of the market that order is placed. Positive implies a buy order, where as negative is a sell
Method Detail

setInstrumentId

public void setInstrumentId(long instrumentId)
Set the instrument for the position to place the closing order against.

Parameters:
instrumentId - The instrument id for the order.

setQuantity

public void setQuantity(FixedPointNumber quantity)
Set the quantity of the close specification to the specified value. This allows you to place multiple closing orders with the same parameters.

Parameters:
quantity - New quantity for the close position specification.

setInstructionId

public void setInstructionId(java.lang.String instructionId)
Set the user correlation ID for this closing order. This must be unique for each new closing order that is placed.

Parameters:
instructionId - the user-specified correlation ID

setOriginalInstructionId

public void setOriginalInstructionId(java.lang.String originalInstructionId)
Setting an originalInstructionId on the specification means this closing order will close some or all of an existing open order with the given originalInstructionId. Instrument ID is mandatory if originalInstructionId is present.

Parameters:
originalInstructionId - the instruction ID of the original order to close

getUri

public java.lang.String getUri()
The close position uri.

Specified by:
getUri in interface com.lmax.api.internal.Request
Returns:
The close position uri.

writeTo

public void writeTo(com.lmax.api.internal.xml.StructuredWriter writer)
Internal: Output this request.

Specified by:
writeTo in interface com.lmax.api.internal.Request
Parameters:
writer - The destination for the content of this request

toString

public java.lang.String toString()
A readable String representation of the ClosingOrderSpecification.

Overrides:
toString in class java.lang.Object
Returns:
ClosingOrderSpecification as a String