本文整理汇总了Java中com.dukascopy.api.IEngine.OrderCommand类的典型用法代码示例。如果您正苦于以下问题:Java OrderCommand类的具体用法?Java OrderCommand怎么用?Java OrderCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrderCommand类属于com.dukascopy.api.IEngine包,在下文中一共展示了OrderCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: slPriceForPips
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
private double slPriceForPips(final Instrument instrument,
final OrderCommand orderCommand,
final double slDistance) {
final double rawSLPrice = calculationUtil.slPriceForPips(instrument,
orderCommand,
slDistance);
final double slPrice = MathUtil.roundPrice(rawSLPrice, instrument);
logger.trace("Calculated SL price for " + instrument + ":\n"
+ " orderCommand: " + orderCommand + "\n"
+ " slDistance: " + slDistance + "\n"
+ " slPrice: " + slPrice);
return slPrice;
}
示例2: orderParams
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public OrderParams orderParams() {
return OrderParams
.forInstrument(Instrument.EURUSD)
.withOrderCommand(OrderCommand.BUYSTOP)
.withAmount(amount)
.withLabel(orderLabel)
.price(price)
.build();
}
示例3: create
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
private SubmitParams create(final Instrument instrument,
final BrokerBuyData brokerBuyData,
final double slPrice) {
final String orderLabel = brokerBuyData.orderLabel();
final int orderID = brokerBuyData.orderID();
final OrderCommand orderCommand = brokerBuyData.orderCommand();
final double amount = brokerBuyData.amount();
final OrderParams orderParams = OrderParams
.forInstrument(instrument)
.withOrderCommand(orderCommand)
.withAmount(amount)
.withLabel(orderLabel)
.stopLossPrice(slPrice)
.build();
return SubmitParams
.withOrderParams(orderParams)
.doOnStart(() -> logger.info("Trying to open order for " + instrument + ":\n"
+ "command: " + orderCommand + "\n"
+ "amount: " + amount + "\n"
+ "label: " + orderLabel + "\n"
+ "ID: " + orderID + "\n"
+ "slPrice: " + slPrice))
.doOnError(e -> logger.error("Opening order for " + instrument
+ " with ID " + orderID
+ " failed!" + e.getMessage()))
.doOnComplete(() -> logger.info("Opening order for " + instrument
+ " with ID " + orderID
+ " done."))
.retryOnReject(retryParams)
.build();
}
示例4: orderCommandForPositiveContractsIsBuy
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
@Test
public void orderCommandForPositiveContractsIsBuy() {
final int contracts = 125000;
final OrderCommand command = tradeUtility.orderCommandForContracts(contracts);
assertThat(command, equalTo(OrderCommand.BUY));
}
示例5: orderCommandForNegativeContractsIsSell
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
@Test
public void orderCommandForNegativeContractsIsSell() {
final int contracts = -125000;
final OrderCommand command = tradeUtility.orderCommandForContracts(contracts);
assertThat(command, equalTo(OrderCommand.SELL));
}
示例6: forOrderIsCorrect
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
@Test
public void forOrderIsCorrect() {
when(orderMockA.getInstrument()).thenReturn(instrumentForTest);
when(orderMockA.getOrderCommand()).thenReturn(OrderCommand.BUY);
when(calculationUtilMock.currentQuoteForOrderCommand(instrumentForTest, OrderCommand.BUY))
.thenReturn(priceForOrder);
assertThat(priceProvider.forOrder(orderMockA), equalTo(priceForOrder));
}
示例7: assertOrderParamsValues
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
@Test
public void assertOrderParamsValues() {
assertThat(orderParams.instrument(), equalTo(instrumentForTest));
assertThat(orderParams.orderCommand(), equalTo(OrderCommand.BUY));
assertThat(orderParams.amount(), equalTo(amount));
assertThat(orderParams.label(), equalTo(orderLabel));
assertThat(orderParams.stopLossPrice(), equalTo(slPrice));
}
示例8: setUpMocks
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
private void setUpMocks() {
when(priceProviderMock.forOrder(orderMockA)).thenReturn(price);
when(orderMockA.getInstrument()).thenReturn(instrumentForTest);
when(orderMockA.getOrderCommand()).thenReturn(OrderCommand.BUY);
when(orderMockA.getOpenPrice()).thenReturn(pOpen);
when(orderMockA.getAmount()).thenReturn(orderAmount);
when(orderMockA.getProfitLossInAccountCurrency()).thenReturn(pProfit);
}
示例9: onStart
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public void onStart(IContext context) throws JFException {
IEngine engine = context.getEngine();
Instrument i = parseInstrument(instr);
OrderCommand cmd = type.equals("BUY")?OrderCommand.BUY:OrderCommand.SELL;
double am = Double.parseDouble(amount);
IOrder order = engine.submitOrder(randId+count++, i, cmd, am);
send(session, order);
context.stop();
}
示例10: calc
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
@Override
protected double calc(Signal challenge, Period period, IBar askBar, IBar bidBar, State actual) {
IIndicators indicators = StateMachine.getInstance().getContext().getIndicators();
try {
/*
* ASK
*/
double sma55weekly = indicators.sma(challenge.getInstrument(), Period.WEEKLY, OfferSide.ASK, AppliedPrice.MEDIAN_PRICE, 55, 0);
double sma21daily = indicators.sma(challenge.getInstrument(), Period.DAILY, OfferSide.ASK, AppliedPrice.MEDIAN_PRICE, 21, 0);
double sma34fhours = indicators.sma(challenge.getInstrument(), Period.FOUR_HOURS, OfferSide.ASK, AppliedPrice.CLOSE, 34, 0);
double price = askBar.getClose();
if ( price > sma55weekly && price > sma21daily && price > sma34fhours ) {
challenge.setType(OrderCommand.SELL);
return this.max;
}
sma55weekly = indicators.sma(challenge.getInstrument(), Period.WEEKLY, OfferSide.BID, AppliedPrice.MEDIAN_PRICE, 55, 0);
sma21daily = indicators.sma(challenge.getInstrument(), Period.DAILY, OfferSide.BID, AppliedPrice.MEDIAN_PRICE, 21, 0);
sma34fhours = indicators.sma(challenge.getInstrument(), Period.FOUR_HOURS, OfferSide.BID, AppliedPrice.CLOSE, 34, 0);
price = bidBar.getClose();
if ( price < sma55weekly && price < sma21daily && price < sma34fhours ) {
challenge.setType(OrderCommand.BUY);
return this.max;
}
} catch (JFException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return 0;
}
示例11: orderCommandForContracts
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public OrderCommand orderCommandForContracts(final int contracts) {
return contracts > 0
? OrderCommand.BUY
: OrderCommand.SELL;
}
示例12: forOrder
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public double forOrder(final IOrder order) {
final Instrument instrument = order.getInstrument();
final OrderCommand orderCommand = order.getOrderCommand();
return calculationUtil.currentQuoteForOrderCommand(instrument, orderCommand);
}
示例13: orderCommand
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public OrderCommand orderCommand() {
return orderCommand;
}
示例14: checkCapabilities
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
private void checkCapabilities() throws RobotException, JFException {
if (!context.isFullAccessGranted()) {
logger.fatal("Full access need to run this strategy!");
throw new RobotException("Full access need to run this strategy!");
}
setStartBalance(context.getAccount().getBalance());
if (context.getEngine().getType().equals(IEngine.Type.TEST)) {
for (IChart c : charts) {
setChartDecoration(c);
}
}
/*
* check if this is the only robot at account
* if true, than mark the account by startID
*/
if (!context.getEngine().getType().equals(IEngine.Type.TEST)) {
for (IOrder order : context.getEngine().getOrders()) {
if (order.getLabel().contains("START")) {
throw new RobotException("Robot with label \"" + order.getLabel() + "\" is already running!");
}
logger.info("checking #" + order.getId() + "@" + order.getInstrument());
}
Set<Instrument> temp = context.getSubscribedInstruments();
Set<Instrument> eurusd = new HashSet<Instrument>();
eurusd.add(Instrument.EURUSD);
context.setSubscribedInstruments(eurusd);
context.getEngine().submitOrder("START" + String.valueOf(startID), Instrument.EURUSD,
OrderCommand.SELLLIMIT, 0.001, 2.500);
context.setSubscribedInstruments(temp);
}
logger.info("start ID: " + startID);
logger.info("mail send: OK");
logger.info("engine type: " + context.getEngine().getType().name());
logger.info("account user: " + context.getAccount().getAccountId());
logger.info("account state: " + context.getAccount().getAccountState());
logger.info("account balance: " + context.getAccount().getBalance() + " "
+ context.getAccount().getCurrency().getCurrencyCode());
logger.info("account is global: " + context.getAccount().isGlobal());
logger.info("current leverage: 1:" + context.getAccount().getLeverage());
}
示例15: getType
import com.dukascopy.api.IEngine.OrderCommand; //导入依赖的package包/类
public OrderCommand getType() {
return type;
}