Order Amounts
In JForex API amounts of orders are represented in millions, meaning that by submitting a long order with amount 1 and instrument EUR/USD, on full, successful fill 1 million units (i.e. 1'000'000 EUR) will get bought. The minimum order amount is 1000 units (with the exception of XAG/USD and XAU/USD which have the minimum amounts 50 and 1 units (i.e. 50 and 1 ounces) respectively).
For instance, one would make 3 orders of minimum amounts for the particular instruments in the following way:
engine.submitOrder("eurusdMinOrder", Instrument.EURUSD, OrderCommand.BUY, 0.001);
engine.submitOrder("xauusdMinOrder", Instrument.XAUUSD, OrderCommand.BUY, 0.000001);
engine.submitOrder("xagusdMinOrder", Instrument.XAGUSD, OrderCommand.BUY, 0.00005);
Order amount increment
Order amount minimum increment is one unit. For example, the following code will create two orders with amounts of 1234 and 1001 units in EUR/USD.
engine.submitOrder("order1", Instrument.EURUSD, OrderCommand.BUY, 0.001234);
engine.submitOrder("order2", Instrument.EURUSD, OrderCommand.BUY, 0.001001);
However, the following code will create an order of amount of 1235 units in EUR/USD (note the rounding):
engine.submitOrder("order1", Instrument.EURUSD, OrderCommand.BUY, 0.00123456789);
Creating an order of minimum amount
Consider a function which returns minimum order amount for a given instrument:
private double getMinAmount(Instrument instrument){
switch (instrument){
case XAUUSD : return 0.000001;
case XAGUSD : return 0.00005;
default : return 0.001;
}
}
Consider a strategy using this method: