public interface IOrder
Contains order data and allows order manipulation
| 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. |
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. |
boolean |
compare(IOrder order)
Compares order to current one |
double |
getAmount()
Returns amount of the order. |
java.util.List<ICloseOrder> |
getCloseHistory()
Returns ordered history of order closing. |
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 |
java.lang.String |
getComment()
Returns comment that was set when order was submitted |
double |
getCommission()
Return position's commission in account currency. |
double |
getCommissionInUSD()
Return position's commission in USD For global accounts (i.e., IAccount.isGlobal()) returns the accumulated commission
of the instrument's position that has been accumulated over the current trading session. |
long |
getCreationTime()
Returns creation time. |
java.util.List<IFillOrder> |
getFillHistory()
Returns ordered history of order filling. |
long |
getFillTime()
Returns time of the fill |
long |
getGoodTillTime()
Returns time when order will be cancelled or 0 if order is "good till cancel" |
java.lang.String |
getId()
Returns position or entry ID |
Instrument |
getInstrument()
Returns instrument of the order |
java.lang.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 |
getOriginalAmount()
Returns original constant amount of the order. |
double |
getProfitLossInAccountCurrency()
Returns profit/loss in account currency |
double |
getProfitLossInPips()
Returns profit/loss in pips |
double |
getProfitLossInUSD()
Returns profit/loss in USD |
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, OFFERs and LIMIT orders Applicable to orders of state IOrder.State.OPENED. |
void |
setLabel(java.lang.String label)
Sets label of order in IOrder.State.OPENED state and with
conditional order command
May not be called on the same order more than once per second. |
void |
setOpenPrice(double price)
Sets open price for order in IOrder.State.OPENED state or pending part of partially filled order
May not be called on the same order more than once per second. |
void |
setRequestedAmount(double amount)
Sets amount of order in IOrder.State.OPENED state or cancels pending part of partially
filled order when amount equals to zero is set. |
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 |
setTakeProfitPrice(double price)
Sets take profit price. |
IMessage |
waitForUpdate(IOrder.State... states)
Blocks until order changes it's state value to one of the expected states (or to any value if expected states are not specified). |
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). |
IMessage |
waitForUpdate(long timeoutMills,
IOrder.State... states)
Blocks until order changes it's state value to one of the expected states (or to any value if expected states are not specified). |
IMessage |
waitForUpdate(long timeout,
java.util.concurrent.TimeUnit unit)
Blocks until order changes it's state, values or until timeout is elapsed (unblocks when system receives any message related to this order). |
IMessage |
waitForUpdate(long timeout,
java.util.concurrent.TimeUnit unit,
IOrder.State... states)
Blocks until order changes it's state value to one of the expected states (or to any value if expected states are not specified). |
| Method Detail |
|---|
Instrument getInstrument()
java.lang.String getLabel()
java.lang.String getId()
long getCreationTime()
long getCloseTime()
IEngine.OrderCommand getOrderCommand()
IEngine.OrderCommand of this message.
After the order fill returns IEngine.OrderCommand.BUY if the order is LONG,
IEngine.OrderCommand.SELL otherwise.
boolean isLong()
getOrderCommand().isLong()
long getFillTime()
double getOriginalAmount()
IEngine.submitOrder(String, Instrument, com.dukascopy.api.IEngine.OrderCommand, double)double getAmount()
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).
double getRequestedAmount()
double getOpenPrice()
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
double getClosePrice()
double getStopLossPrice()
double getTakeProfitPrice()
void setStopLossPrice(double price)
throws JFException
getStopLossPrice() method will still return old value until server
will accept this changes.
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. May not be called on the same order more than once per second.
price - price to set
JFException - when method fails for some reason
void setStopLossPrice(double price,
OfferSide side)
throws JFException
getStopLossPrice() method will still return old value until server will accept this changes
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. May not be called on the same order more than once per second.
price - price to setside - side that will be used to check stop loss condition
JFException - when method fails for some reason
void setStopLossPrice(double price,
OfferSide side,
double trailingStep)
throws JFException
getStopLossPrice() method will still
return old value until server will accept this changes
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. May not be called on the same order more than once per second.
price - price to setside - side that will be used to check stop loss conditiontrailingStep - if < 0 then adds stop loss order without trailing step. Should be 0 or >= 10
JFException - trailingStep is > 0 and < 10 or when method fails for some reason
void setLabel(java.lang.String label)
throws JFException
IOrder.State.OPENED state and with
conditional order command
May not be called on the same order more than once per second.
label - new label
JFException - if order is not in IOrder.State.OPENED state or new label is null or emptyOfferSide getStopLossSide()
double getTrailingStep()
void setTakeProfitPrice(double price)
throws JFException
getTakeProfitPrice() method will still return old value until server will accept this changes
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED. May not be called on the same order more than once per second.
price - price to set
JFException - when method fails for some reasonjava.lang.String getComment()
void setRequestedAmount(double amount)
throws JFException
IOrder.State.OPENED state or cancels pending part of partially
filled order when amount equals to zero is set.
May not be called on the same order more than once per second.
amount - new amount
JFException - if order is not in IOrder.State.OPENED state or amount is not 0
for IOrder.State.FILLED state or if amount is less than a minimum allowed
void setOpenPrice(double price)
throws JFException
IOrder.State.OPENED state or pending part of partially filled order
May not be called on the same order more than once per second.
price - price of the opening condition
JFException - when price change fails
void close(double amount,
double price,
double slippage)
throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED
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 closedprice - 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.
JFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state.
And if order is IOrder.State.OPENED, but amount != 0 or price != 0 or slippage >= 0
void close(double amount,
double price)
throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED
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 closedprice - required close price. Close will be rejected if no liquidity at this price. This parameter doesn't affect
entry (conditional) orders.
JFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state.
And if order is IOrder.State.OPENED, but amount != 0 or price != 0
void close(double amount)
throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED
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
JFException - when called for order not in IOrder.State.OPENED or IOrder.State.FILLED state.
And if order is IOrder.State.OPENED, but amount != 0
void close()
throws JFException
Applicable to orders of state IOrder.State.OPENED and IOrder.State.FILLED
This is the only allowed close() method for entry orders
JFExceptionIOrder.State getState()
IOrder.State of the order
void setGoodTillTime(long goodTillTime)
throws JFException
Applicable to orders of state IOrder.State.OPENED. May not be called on the same order more than once per second.
goodTillTime - time when BID, OFFER or LIMIT orders should be canceled
JFException - when order is simple market orderlong getGoodTillTime()
void waitForUpdate(long timeoutMills)
timeoutMills - timeout to wait for order state change
IMessage waitForUpdate(long timeout,
java.util.concurrent.TimeUnit unit)
timeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter
IMessage waitForUpdate(IOrder.State... states)
throws JFException
JFException will be thrown due to order is in state that cannot be changed to one of expected ones.
states - a set of expected states. If null or empty - blocks until order changes it's state to any value.
JFException - when order is in state that cannot be changed to one of expected states
IMessage waitForUpdate(long timeoutMills,
IOrder.State... states)
throws JFException
timeoutMills - timeout to wait for order state changestates - a set of expected states. If null or empty - blocks until order changes it's state to any value.
JFException - when order is in state that cannot be changed to one of expected states
IMessage waitForUpdate(long timeout,
java.util.concurrent.TimeUnit unit,
IOrder.State... states)
throws JFException
timeout - how long to wait before giving up, in units of
unitunit - a TimeUnit determining how to interpret the
timeout parameter.states - a set of expected states. If null or empty - blocks until order changes it's state to any value.
JFException - when order is in state that cannot be changed to one of expected statesdouble getProfitLossInPips()
double getProfitLossInUSD()
double getProfitLossInAccountCurrency()
double getCommission()
For global accounts (i.e., IAccount.isGlobal()) returns the accumulated commission
of the instrument's position that has been accumulated over the current trading session.
Which means that the value gets reset with every platform reconnect.
double getCommissionInUSD()
For global accounts (i.e., IAccount.isGlobal()) returns the accumulated commission
of the instrument's position that has been accumulated over the current trading session.
Which means that the value gets reset with every platform reconnect.
java.util.List<IFillOrder> getFillHistory()
java.util.List<ICloseOrder> getCloseHistory()
boolean compare(IOrder order)
order - to compare with current