當前位置: 首頁>>代碼示例>>Java>>正文


Java OrderCommand類代碼示例

本文整理匯總了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;
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:15,代碼來源:StopLoss.java

示例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();
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:10,代碼來源:DummySubmitRunner.java

示例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();
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:34,代碼來源:SubmitParamsFactory.java

示例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));
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:9,代碼來源:TradeUtilityTest.java

示例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));
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:9,代碼來源:TradeUtilityTest.java

示例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));
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:11,代碼來源:PriceProviderTest.java

示例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));
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:9,代碼來源:SubmitParamsFactoryTest.java

示例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);
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:10,代碼來源:BrokerTradeDataTest.java

示例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();
}
 
開發者ID:caub,項目名稱:JForexJetty,代碼行數:10,代碼來源:DataStrategy.java

示例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;
}
 
開發者ID:csikosbalint,項目名稱:forex-strategy,代碼行數:30,代碼來源:ThreePigsOpen.java

示例11: orderCommandForContracts

import com.dukascopy.api.IEngine.OrderCommand; //導入依賴的package包/類
public OrderCommand orderCommandForContracts(final int contracts) {
    return contracts > 0
            ? OrderCommand.BUY
            : OrderCommand.SELL;
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:6,代碼來源:TradeUtility.java

示例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);
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:6,代碼來源:PriceProvider.java

示例13: orderCommand

import com.dukascopy.api.IEngine.OrderCommand; //導入依賴的package包/類
public OrderCommand orderCommand() {
    return orderCommand;
}
 
開發者ID:juxeii,項目名稱:dztools,代碼行數:4,代碼來源:BrokerBuyData.java

示例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());
}
 
開發者ID:csikosbalint,項目名稱:forex-strategy,代碼行數:44,代碼來源:StateMachine.java

示例15: getType

import com.dukascopy.api.IEngine.OrderCommand; //導入依賴的package包/類
public OrderCommand getType() {
	return type;
}
 
開發者ID:csikosbalint,項目名稱:forex-strategy,代碼行數:4,代碼來源:Signal.java


注:本文中的com.dukascopy.api.IEngine.OrderCommand類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。