com.dukascopy.api
Interface IOrder


public interface IOrder

Contains order data and allows order manipulation

Author:
Denis Larka

Nested Class Summary
static class IOrder.State
          Indicates state of the order
 
Method Summary
 void close()
          Sends a request to fully close position by market price or cancel entry order This is the only allowed close() method for entry orders
 void close(double amount)
          Sends a request to close the position with specified amount, by market price and default slippage.
 void close(double amount, double price)
          Sends a request to close the position with specified amount, price and default slippage.
 void close(double amount, double price, double slippage)
          Sends a request to close the position with specified amount, price and slippage.
 double getAmount()
          Returns amount of the order.
 double getClosePrice()
          Returns price at which order was closed or 0 if order or order part wasn't closed.
 long getCloseTime()
          Returns time when server closed the order
 String getComment()
          Returns comment that was set when order was submitted
 long getCreationTime()
          Returns creation time.
 long getFillTime()
          Returns time of the fill
 long getGoodTillTime()
          Returns time when order will be cancelled or 0 if order is "good till cancel"
 String getId()
          Returns position or entry ID
 Instrument getInstrument()
          Returns instrument of the order
 String getLabel()
          Returns label
 double getOpenPrice()
          Returns entry level price for conditional orders in IOrder.State.CREATED and IOrder.State.OPENED state or price at which order was filled for orders in IOrder.State.FILLED or IOrder.State.CLOSED states
 IEngine.OrderCommand getOrderCommand()
          Returns IEngine.OrderCommand of this message
 double getRequestedAmount()
          Returns requested amount
 IOrder.State getState()
          Returns current IOrder.State of the order
 double getStopLossPrice()
          Returns price of stop loss condition or 0 if stop loss condition is not set.
 OfferSide getStopLossSide()
          Returns side that is used to check stop loss condition
 double getTakeProfitPrice()
          Returns price of take profit condition or 0 if take profit condition is not set.
 double getTrailingStep()
          Returns current trailing step or 0 if no trailing step is set
 boolean isLong()
          Returns true if order is LONG.
 void setGoodTillTime(long goodTillTime)
          Sets "good till time" for BIDs and OFFERs
 void setOpenPrice(double price)
          Sets open price for order in IOrder.State.CREATED or IOrder.State.OPENED state
 void setRequestedAmount(double amount)
          Sets amount of order in IOrder.State.CREATED or IOrder.State.OPENED state
 void setStopLoss(double price)
          Deprecated. changed to setStopLossPrice
 void setStopLoss(double price, OfferSide side)
          Deprecated. changed to setStopLossPrice
 void setStopLoss(double price, OfferSide side, double trailingStep)
          Deprecated. changed to setStopLossPrice
 void setStopLossPrice(double price)
          Sets stop loss price.
 void setStopLossPrice(double price, OfferSide side)
          Sets stop loss price.
 void setStopLossPrice(double price, OfferSide side, double trailingStep)
          Sets stop loss price.
 void setTakeProfit(double price)
          Deprecated. changed to setTakeProfitPrice
 void setTakeProfitPrice(double price)
          Sets take profit price.
 void waitForUpdate(long timeoutMills)
          Blocks until order changes it's state, values or until timeout is elapsed (unblocks when system receives any message related to this order).
 

Method Detail

getInstrument

Instrument getInstrument()
Returns instrument of the order

Returns:
instrument

getLabel

String getLabel()
Returns label

Returns:
label

getId

String getId()
Returns position or entry ID

Returns:
label

getCreationTime

long getCreationTime()
Returns creation time. This is the time when server accepted the order, not the time when it was submitted

Returns:
creation time

getCloseTime

long getCloseTime()
Returns time when server closed the order

Returns:
time when order was closed

getOrderCommand

IEngine.OrderCommand getOrderCommand()
Returns IEngine.OrderCommand of this message

Returns:
order command of this message

isLong

boolean isLong()
Returns true if order is LONG. Equals to getOrderCommand().isLong()

Returns:
true if order is LONG

getFillTime

long getFillTime()
Returns time of the fill

Returns:
time of the order fill

getAmount

double getAmount()
Returns amount of the order. For orders in IOrder.State.OPENED state returns amount requested. For orders in IOrder.State.FILLED state will return filled amount. Filled amount can be different from requested amount (partial fill).

Returns:
amount of the order

getRequestedAmount

double getRequestedAmount()
Returns requested amount

Returns:
amount requested

getOpenPrice

double getOpenPrice()
Returns entry level price for conditional orders in IOrder.State.CREATED and IOrder.State.OPENED state or price at which order was filled for orders in IOrder.State.FILLED or IOrder.State.CLOSED states

Returns:
entry level for conditional orders or open price for positions

getClosePrice

double getClosePrice()
Returns price at which order was closed or 0 if order or order part wasn't closed. This is the price of latest close operation in case of partial close

Returns:
close price for closed orders, return 0 for any other type of order

getStopLossPrice

double getStopLossPrice()
Returns price of stop loss condition or 0 if stop loss condition is not set. Orders submitted with stop loss condition, will have this price set only after server accepts order

Returns:
stop loss price or 0

getTakeProfitPrice

double getTakeProfitPrice()
Returns price of take profit condition or 0 if take profit condition is not set. Orders submitted with take profit condition, will have this price set only after server accepts order

Returns:
take profit price or 0

setStopLossPrice

void setStopLossPrice(double price)
                      throws JFException
Sets stop loss price. If price is 0, then stop loss condition will be removed. Default stop loss side is BID for long orders and ASK for short. This method will send command to the server, getStopLossPrice() method will still return old value until server will accept this changes

Parameters:
price - price to set
Throws:
JFException - when method fails for some reason

setStopLoss

@Deprecated
void setStopLoss(double price)
                 throws JFException
Deprecated. changed to setStopLossPrice

Use setStopLossPrice(double) instead

Throws:
JFException

setStopLossPrice

void setStopLossPrice(double price,
                      OfferSide side)
                      throws JFException
Sets stop loss price. If price is 0, then stop loss condition will be removed. This method will send command to the server, getStopLossPrice() method will still return old value until server will accept this changes

Parameters:
price - price to set
side - side that will be used to check stop loss condition
Throws:
JFException - when method fails for some reason

setStopLoss

@Deprecated
void setStopLoss(double price,
                            OfferSide side)
                 throws JFException
Deprecated. changed to setStopLossPrice

Use setStopLossPrice(double, OfferSide) instead

Throws:
JFException

setStopLossPrice

void setStopLossPrice(double price,
                      OfferSide side,
                      double trailingStep)
                      throws JFException
Sets stop loss price. If price is 0, then stop loss condition will be removed. If trailingStep is bigger than 10, then trailing step logic will be applied for stop loss price. This method will send command to the server, getStopLossPrice() method will still return old value until server will accept this changes

Parameters:
price - price to set
side - side that will be used to check stop loss condition
trailingStep - if < 0 then adds stop loss order without trailing step. Should be 0 or >= 10
Throws:
JFException - trailingStep is > 0 and < 10 or when method fails for some reason

setStopLoss

@Deprecated
void setStopLoss(double price,
                            OfferSide side,
                            double trailingStep)
                 throws JFException
Deprecated. changed to setStopLossPrice

Use setStopLossPrice(double, OfferSide, double) instead

Throws:
JFException

getStopLossSide

OfferSide getStopLossSide()
Returns side that is used to check stop loss condition

Returns:
stop loss side

getTrailingStep

double getTrailingStep()
Returns current trailing step or 0 if no trailing step is set

Returns:
trailing step value

setTakeProfitPrice

void setTakeProfitPrice(double price)
                        throws JFException
Sets take profit price. If price is 0, then take profit condition will be removed. This method will send command to the server, getStopLossPrice() method will still return old value until server will accept this changes

Parameters:
price - price to set
Throws:
JFException - when method fails for some reason

setTakeProfit

@Deprecated
void setTakeProfit(double price)
                   throws JFException
Deprecated. changed to setTakeProfitPrice

Use setTakeProfitPrice(double) instead

Throws:
JFException

getComment

String getComment()
Returns comment that was set when order was submitted

Returns:
comment

setRequestedAmount

void setRequestedAmount(double amount)
                        throws JFException
Sets amount of order in IOrder.State.CREATED or IOrder.State.OPENED state

Parameters:
amount - new amount
Throws:
JFException - if order is not in IOrder.State.CREATED or IOrder.State.OPENED state or if amount is less than a minimum allowed

setOpenPrice

void setOpenPrice(double price)
                  throws JFException
Sets open price for order in IOrder.State.CREATED or IOrder.State.OPENED state

Parameters:
price - price of the opening condition
Throws:
JFException - when price change fails

close

void close(double amount,
           double price,
           double slippage)
           throws JFException
Sends a request to close the position with specified amount, price and slippage.

Parameters:
amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all amount will be closed
price - required close price. Close will be rejected if no liquidity at this price. This parameter doesn't affect entry (conditional) orders.
slippage - required price slippage.
Throws:
JFException - when called for order not in IOrder.State.FILLED state

close

void close(double amount,
           double price)
           throws JFException
Sends a request to close the position with specified amount, price and default slippage.

Parameters:
amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all amount will be closed
price - required close price. Close will be rejected if no liquidity at this price. This parameter doesn't affect entry (conditional) orders.
Throws:
JFException - when called for order not in IOrder.State.FILLED state

close

void close(double amount)
           throws JFException
Sends a request to close the position with specified amount, by market price and default slippage.

Parameters:
amount - closing amount. Can be less than opened amount, in this case partial close will take place. If 0 is provided then all amount will be closed
Throws:
JFException - when called for order not in IOrder.State.FILLED state

close

void close()
           throws JFException
Sends a request to fully close position by market price or cancel entry order This is the only allowed close() method for entry orders

Throws:
JFException

getState

IOrder.State getState()
Returns current IOrder.State of the order

Returns:
state

setGoodTillTime

void setGoodTillTime(long goodTillTime)
                     throws JFException
Sets "good till time" for BIDs and OFFERs

Parameters:
goodTillTime - time when BID or OFFER should be canceled
Throws:
JFException - when order is not place bid or offer

getGoodTillTime

long getGoodTillTime()
Returns time when order will be cancelled or 0 if order is "good till cancel"

Returns:
cancel time or 0

waitForUpdate

void waitForUpdate(long timeoutMills)
Blocks until order changes it's state, values or until timeout is elapsed (unblocks when system receives any message related to this order). Use with caution, strategy will stop receiving any messages until this function exits. All the ticks that platform received while waiting will be dropped. Method shouldn't be used for waiting long running events, like closing the order by stop loss, else buffer with messages will overflow and strategy will be stopped.

Parameters:
timeoutMills - timeout to wait for order state change


Copyright © 2009. All Rights Reserved.