com.dukascopy.api
Interface IEngine


public interface IEngine

Interface to the main engine, that allows orders submission, merging etc


Nested Class Summary
static class IEngine.OrderCommand
          Specifies type of the order
static class IEngine.StrategyMode
          Specifies strategy running mode.
static class IEngine.Type
          Type of the engine
 
Method Summary
 void broadcast(java.lang.String topic, java.lang.String message)
          Broadcast message
 void closeOrders(IOrder... orders)
          Mass close.
 java.lang.String getAccount()
          Returns account name
 IOrder getOrder(java.lang.String label)
          Returns order by label, or null if no order was found
 IOrder getOrderById(java.lang.String orderId)
          Returns order in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state by id, or null if no order was found
 java.util.List<IOrder> getOrders()
          Returns list of orders in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state
 java.util.List<IOrder> getOrders(Instrument instrument)
          Returns list of orders in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state for specified instrument
 IEngine.StrategyMode getStrategyMode()
          Returns strategy running mode, one of the IEngine.StrategyMode.INDEPENDENT or IEngine.StrategyMode.SIGNALS.
 IEngine.Type getType()
          Returns type of the engine, one of the IEngine.Type.LIVE, IEngine.Type.DEMO or IEngine.Type.TEST for tester.
 java.lang.String groupToOCO(IOrder order1, IOrder order2)
           
 void mergeOrders(IOrder... orders)
          Deprecated. use mergeOrders(String label,IOrder... orders) throws JFException;
 IOrder mergeOrders(java.lang.String label, IOrder... orders)
          Merges orders.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount)
          Submits new order.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price)
          Submits new order.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage)
          Submits new order.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice)
          Submits new order.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice, long goodTillTime)
          Submits new order.
 IOrder submitOrder(java.lang.String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice, long goodTillTime, java.lang.String comment)
          Submits new order.
 java.lang.String ungroupOCO(IOrder order)
           
 

Method Detail

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price,
                   double slippage,
                   double stopLossPrice,
                   double takeProfitPrice,
                   long goodTillTime,
                   java.lang.String comment)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then last market price visible on the JForex will be used. Price should be divisible by 0.1 pips or order will be rejected. In case of market orders, incorrect price (worse than current market) will be changed to current price and slippage
slippage - slippage. The value of slippage means following:
  • if negative then default value of 5 pips is used
  • if Double.isNaN(slippage) == true then no slippage is used
  • otherwise, slippage is set in pips, you should pass 1, not 0.0001
stopLossPrice - price of the stop loss. Price should be divisible by 0.1 pips or order will be rejected
takeProfitPrice - price of the take profit. Price should be divisible by 0.1 pips or order will be rejected
goodTillTime - how long order should live if not executed. Only if > 0, then orderCommand should be IEngine.OrderCommand.PLACE_BID or IEngine.OrderCommand.PLACE_OFFER
comment - comment that will be saved in order
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if goodTillTime > 0 and orderCommand is not BID/OFFER, if amount is less than minimum allowed, if some of the required parameters is null

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price,
                   double slippage,
                   double stopLossPrice,
                   double takeProfitPrice,
                   long goodTillTime)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then last market price visible on the JForex will be used. Price should be divisible by 0.1 pips or order will be rejected. In case of market orders, incorrect price (worse than current market) will be changed to current price and slippage
slippage - slippage. The value of slippage means following:
  • if negative then default value of 5 pips is used
  • if Double.isNaN(slippage) == true then no slippage is used
  • otherwise, slippage is set in pips, you should pass 1, not 0.0001
stopLossPrice - price of the stop loss. Price should be divisible by 0.1 pips or order will be rejected
takeProfitPrice - price of the take profit. Price should be divisible by 0.1 pips or order will be rejected
goodTillTime - how long order should live if not executed. Only if > 0, then orderCommand should be IEngine.OrderCommand.PLACE_BID or IEngine.OrderCommand.PLACE_OFFER
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if goodTillTime > 0 and orderCommand is not BID/OFFER, if amount is less than minimum allowed, if some of the required parameters is null

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price,
                   double slippage,
                   double stopLossPrice,
                   double takeProfitPrice)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then last market price visible on the JForex will be used. Price should be divisible by 0.1 pips or order will be rejected. In case of market orders, incorrect price (worse than current market) will be changed to current price and slippage
slippage - slippage. The value of slippage means following:
  • if negative then default value of 5 pips is used
  • if Double.isNaN(slippage) == true then no slippage is used
  • otherwise, slippage is set in pips, you should pass 1, not 0.0001
stopLossPrice - price of the stop loss. Price should be divisible by 0.1 pips or order will be rejected
takeProfitPrice - price of the take profit. Price should be divisible by 0.1 pips or order will be rejected
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if amount is less than minimum allowed, if some of the required parameters is null

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price,
                   double slippage)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then last market price visible on the JForex will be used. Price should be divisible by 0.1 pips or order will be rejected. In case of market orders, incorrect price (worse than current market) will be changed to current price and slippage
slippage - slippage. The value of slippage means following:
  • if negative then default value of 5 pips is used
  • if Double.isNaN(slippage) == true then no slippage is used
  • otherwise, slippage is set in pips, you should pass 1, not 0.0001
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if amount is less than minimum allowed, if some of the required parameters is null

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation.
Note: default value of 5 pips slippage is used. To specify custom slippage, or disable slippage at all, please use extended submitOrder(...) methods.

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then last market price visible on the JForex will be used. Price should be divisible by 0.1 pips or order will be rejected. In case of market orders, incorrect price (worse than current market) will be changed to current price and slippage
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if amount is less than minimum allowed, if some of the required parameters is null
See Also:
submitOrder(String, Instrument, OrderCommand, double, double, double), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double, long), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double, long, String)

submitOrder

IOrder submitOrder(java.lang.String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount)
                   throws JFException
Submits new order. Returned order is in IOrder.State.CREATED status and will be updated to IOrder.State.OPENED status after server confirmation.
Note: default value of 5 pips slippage is used. To specify custom slippage, or disable slippage at all, please use extended submitOrder(...) methods.

Parameters:
label - user defined identifier for the order. Label must be unique for the given user account among the current orders. Allowed characters: letters, numbers and "_". Label must have at most 256 characters.
instrument - instrument
orderCommand - type of submitted order. Only IEngine.OrderCommand.BUY and IEngine.OrderCommand.SELL allowed in this method
amount - amount in millions for the order
Returns:
new order instance in IOrder.State.CREATED state
Throws:
JFException - if label is not valid or already exists, if amount is less than minimum allowed, if some of the required parameters is null or if orderCommand is not BUY or SELL
See Also:
submitOrder(String, Instrument, OrderCommand, double, double, double), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double, long), submitOrder(String, Instrument, OrderCommand, double, double, double, double, double, long, String)

getOrder

IOrder getOrder(java.lang.String label)
                throws JFException
Returns order by label, or null if no order was found

Parameters:
label - order's label
Returns:
order in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state or null
Throws:
JFException

getOrderById

IOrder getOrderById(java.lang.String orderId)
Returns order in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state by id, or null if no order was found

Parameters:
orderId - order's id
Returns:
order or null.

getOrders

java.util.List<IOrder> getOrders(Instrument instrument)
                                 throws JFException
Returns list of orders in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state for specified instrument

Parameters:
instrument - instrument
Returns:
list of orders
Throws:
JFException

getOrders

java.util.List<IOrder> getOrders()
                                 throws JFException
Returns list of orders in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state

Returns:
list of orders
Throws:
JFException

mergeOrders

void mergeOrders(IOrder... orders)
                 throws JFException
Deprecated. use mergeOrders(String label,IOrder... orders) throws JFException;

Merges orders. Merge process closes all passed in parameter orders notifying strategy with appropriate onMessage event. If there is some amount left, opens new order. Finally notifies strategy calling onMessage with message with IMessage.Type.ORDERS_MERGE_OK type and resulting order or null if there is no amount left for order. If there is less than 2 orders, then method exits after checking conditions, which are one instrument, IOrder.State.FILLED state and no stop loss/take profit conditions

Parameters:
orders - orders to merge
Throws:
JFException - if orders not in IOrder.State.FILLED state, have stop loss or take profit set or doesn't belong to one instrument

mergeOrders

IOrder mergeOrders(java.lang.String label,
                   IOrder... orders)
                   throws JFException
Merges orders. Merge process closes all passed in parameter orders notifying strategy with appropriate onMessage event. If there is some amount left, opens new order with specified label. Finally notifies strategy calling onMessage with message with IMessage.Type.ORDERS_MERGE_OK type and resulting order, which can be in closed state if there is no amount left for order. If there is less than 2 orders, then method exits after checking conditions, which are one instrument, IOrder.State.FILLED state and no stop loss/take profit conditions

Parameters:
label - user defined identifier for the resulting order. Label must be unique for the given user account among the current orders
orders - orders to merge
Returns:
resulting order in CREATED state
Throws:
JFException - if orders not in IOrder.State.FILLED state, have stop loss or take profit set or doesn't belong to one instrument

closeOrders

void closeOrders(IOrder... orders)
                 throws JFException
Mass close. Closes all orders passed in parameter(s)

Parameters:
orders - orders to close
Throws:
JFException - if orders not in IOrder.State.FILLED state.

getType

IEngine.Type getType()
Returns type of the engine, one of the IEngine.Type.LIVE, IEngine.Type.DEMO or IEngine.Type.TEST for tester.

Returns:
type of the engine

getAccount

java.lang.String getAccount()
Returns account name

Returns:
account name

broadcast

void broadcast(java.lang.String topic,
               java.lang.String message)
               throws JFException
Broadcast message

Throws:
JFException

groupToOCO

java.lang.String groupToOCO(IOrder order1,
                            IOrder order2)
                            throws JFException
Throws:
JFException

ungroupOCO

java.lang.String ungroupOCO(IOrder order)
                            throws JFException
Throws:
JFException

getStrategyMode

IEngine.StrategyMode getStrategyMode()
Returns strategy running mode, one of the IEngine.StrategyMode.INDEPENDENT or IEngine.StrategyMode.SIGNALS.

Returns:
strategy running mode


Copyright © 2012. All Rights Reserved.