com.dukascopy.api
Interface IEngine


public interface IEngine

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

Author:
Denis Larka

Nested Class Summary
static class IEngine.OrderCommand
          Specifies type of the order
static class IEngine.Type
          Type of the engine
 
Method Summary
 void closeOrders(IOrder... orders)
          Mass close.
 String getAccount()
          Returns account id
 IOrder getOrder(String label)
          Returns order by label, or null if no order was found
 IOrder getOrderById(String orderId)
          Returns order by id, or null if no order was found
 List<IOrder> getOrders()
          Returns list of orders in IOrder.State.CREATED, IOrder.State.OPENED and IOrder.State.FILLED state
 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.Type getType()
          Returns type of the engine, one of the IEngine.Type.LIVE, IEngine.Type.DEMO or IEngine.Type.TEST for tester.
 void mergeOrders(IOrder... orders)
          Deprecated. use mergeOrders(String label,IOrder... orders) throws JFException;
 IOrder mergeOrders(String label, IOrder... orders)
          Merges orders.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount)
          Submits new order.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price)
          Submits new order.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage)
          Submits new order.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice)
          Submits new order.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice, long goodTillTime)
          Submits new order.
 IOrder submitOrder(String label, Instrument instrument, IEngine.OrderCommand orderCommand, double amount, double price, double slippage, double stopLossPrice, double takeProfitPrice, long goodTillTime, String comment)
          Submits new order.
 

Method Detail

submitOrder

IOrder submitOrder(String label,
                   Instrument instrument,
                   IEngine.OrderCommand orderCommand,
                   double amount,
                   double price,
                   double slippage,
                   double stopLossPrice,
                   double takeProfitPrice,
                   long goodTillTime,
                   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 given user account.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then current market price will be used
slippage - slippage, if negative then default value of 5 ticks is used
stopLossPrice - price of the stop loss
takeProfitPrice - price of the take profit
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(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 given user account.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then current market price will be used
slippage - slippage, if negative then default value of 5 ticks is used
stopLossPrice - price of the stop loss
takeProfitPrice - price of the take profit
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(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 given user account.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then current market price will be used
slippage - slippage, if negative then default value of 5 ticks is used
stopLossPrice - price of the stop loss
takeProfitPrice - price of the take profit
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(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 given user account.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then current market price will be used
slippage - slippage, if negative then default value of 5 ticks is used
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(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

Parameters:
label - user defined identifier for the order. Label must be unique for given user account.
instrument - instrument
orderCommand - type of submitted order
amount - amount in millions for the order
price - preferred price for order. If zero, then current market price will be used
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(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

Parameters:
label - user defined identifier for the order. Label must be unique for given user account.
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

getOrder

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

Parameters:
label - order's label
Returns:
order or null
Throws:
JFException

getOrderById

IOrder getOrderById(String orderId)
Returns order by id, or null if no order was found

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

getOrders

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

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(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 - label of resulting order
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

String getAccount()
Returns account id

Returns:
account id


Copyright © 2009. All Rights Reserved.