当前位置: 首页>>代码示例>>Java>>正文


Java OrdStatus类代码示例

本文整理汇总了Java中quickfix.field.OrdStatus的典型用法代码示例。如果您正苦于以下问题:Java OrdStatus类的具体用法?Java OrdStatus怎么用?Java OrdStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OrdStatus类属于quickfix.field包,在下文中一共展示了OrdStatus类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStatus

import quickfix.field.OrdStatus; //导入依赖的package包/类
public static Status getStatus(OrdStatus ordStatus, CumQty cumQty) {

		if (ordStatus.getValue() == OrdStatus.NEW || ordStatus.getValue() == OrdStatus.PENDING_NEW) {
			return Status.SUBMITTED;
		} else if (ordStatus.getValue() == OrdStatus.PARTIALLY_FILLED) {
			return Status.PARTIALLY_EXECUTED;
		} else if (ordStatus.getValue() == OrdStatus.FILLED) {
			return Status.EXECUTED;
		} else if (ordStatus.getValue() == OrdStatus.CANCELED || ordStatus.getValue() == OrdStatus.PENDING_CANCEL || ordStatus.getValue() == OrdStatus.REJECTED) {
			return Status.CANCELED;
		} else if (ordStatus.getValue() == OrdStatus.REPLACED || ordStatus.getValue() == OrdStatus.PENDING_REPLACE) {
			if (cumQty.getValue() == 0) {
				return Status.SUBMITTED;
			} else {
				return Status.PARTIALLY_EXECUTED;
			}
		} else {
			throw new IllegalArgumentException("unknown orderStatus " + ordStatus.getValue());
		}
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:21,代码来源:FixUtil.java

示例2: createExecutionReport

import quickfix.field.OrdStatus; //导入依赖的package包/类
private quickfix.fix44.ExecutionReport createExecutionReport(
		quickfix.fix44.NewOrderSingle order) throws FieldNotFound {
	quickfix.fix44.ExecutionReport execReport = new ExecutionReport(new OrderID("ORD_" + currentOrdId++),
			new ExecID("EXEC_" + currentExecId++),
			new ExecType(ExecType.NEW),
			new OrdStatus(OrdStatus.PENDING_NEW),
			new Side(order.getSide().getValue()),
			new LeavesQty(0.0),
			new CumQty(0.0),
			new AvgPx(order.getPrice().getValue()));
	execReport.set(order.getClOrdID());
	execReport.set(order.getAccount());
	execReport.set(order.getOrderQty());
	execReport.set(order.getPrice());
	execReport.set(order.getOrdType());
	execReport.set(order.getSymbol());

	return execReport;
}
 
开发者ID:RockManJoe64,项目名称:fixprotocol-test-suite,代码行数:20,代码来源:OrderManagerServer.java

示例3: getOrderStatus

import quickfix.field.OrdStatus; //导入依赖的package包/类
public ExecutionReport getOrderStatus(OrderStatusRequest request) throws FieldNotFound {
    LOG.info("Received order status request for orderId=" + request.getOrderID().getValue());
    return new ExecutionReport(request.getOrderID(), 
        new ExecID(UUID.randomUUID().toString()),
        new ExecTransType(ExecTransType.STATUS), 
        new ExecType(ExecType.REJECTED),
        new OrdStatus(OrdStatus.REJECTED),
        new Symbol("GOOG"),
        new Side(Side.BUY),
        new LeavesQty(100),
        new CumQty(0),
        new AvgPx(0));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:RequestReplyExample.java

示例4: onMessage

import quickfix.field.OrdStatus; //导入依赖的package包/类
private void onMessage(quickfix.fix40.NewOrderSingle order, SessionID sessionID) throws FieldNotFound, UnsupportedMessageType, IncorrectTagValue {
    try {
        validateOrder(order);

        OrderQty orderQty = order.getOrderQty();

        Price price = getPrice(order);

        quickfix.fix40.ExecutionReport accept = new quickfix.fix40.ExecutionReport(genOrderID(), genExecID(),
                new ExecTransType(ExecTransType.NEW), new OrdStatus(OrdStatus.NEW), order.getSymbol(), order.getSide(),
                orderQty, new LastShares(0), new LastPx(0), new CumQty(0), new AvgPx(0));

        accept.set(order.getClOrdID());
        sendMessage(sessionID, accept);

        if (isOrderExecutable(order, price)) {
            quickfix.fix40.ExecutionReport fill = new quickfix.fix40.ExecutionReport(genOrderID(), genExecID(),
                    new ExecTransType(ExecTransType.NEW), new OrdStatus(OrdStatus.FILLED), order.getSymbol(), order
                            .getSide(), orderQty, new LastShares(orderQty.getValue()), new LastPx(price.getValue()),
                    new CumQty(orderQty.getValue()), new AvgPx(price.getValue()));

            fill.set(order.getClOrdID());

            sendMessage(sessionID, fill);
        }
    } catch (RuntimeException e) {
        LogUtil.logThrowable(sessionID, e.getMessage(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:TradeExecutor.java

示例5: onMessage

import quickfix.field.OrdStatus; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void onMessage(ExecutionReport executionReport, SessionID sessionID) throws FieldNotFound {

	long number = Long.parseLong(executionReport.getClOrdID().getValue());

	if (executionReport.getOrdStatus().getValue() == OrdStatus.REJECTED) {
		logger.error("order " + number + " has been rejected, reason: " + executionReport.getText().getValue());
	}

	// for orders that have been cancelled by the system get the number from OrigClOrdID
	if (executionReport.getOrdStatus().getValue() == OrdStatus.CANCELED) {
		if (!executionReport.isSetExecRestatementReason()) {
			number = Long.parseLong(executionReport.getOrigClOrdID().getValue());

			// if the field ExecRestatementReason exists, there is something wrong
		} else {
			logger.error("order " + number + " has been canceled, reason: " + executionReport.getText().getValue());
		}
	}

	// get the order from the OpenOrderWindow
	List<Order> orders = (List<Order>)ServiceLocator.serverInstance().getRuleService().executeQuery(StrategyImpl.BASE, "select * from OpenOrderWindow where number = " + number);
	if (orders.size() == 0) {
		throw new IllegalArgumentException("order was not found");
	} else if (orders.size() > 1) {
		throw new IllegalArgumentException("more than one order exists");
	}
	
	Order order = orders.get(0);
	
	if (order == null) {
		logger.error("order could not be found " + number + " for execution " + executionReport);
		return;
	}

	// get the other fields
	Status status = FixUtil.getStatus(executionReport.getOrdStatus(), executionReport.getCumQty());
	long filledQuantity = (long) executionReport.getCumQty().getValue();
	long remainingQuantity = (long) (executionReport.getOrderQty().getValue() - executionReport.getCumQty().getValue());

	// assemble the orderStatus
	OrderStatus orderStatus = OrderStatus.Factory.newInstance();
	orderStatus.setStatus(status);
	orderStatus.setFilledQuantity(filledQuantity);
	orderStatus.setRemainingQuantity(remainingQuantity);
	orderStatus.setParentOrder(order);

	ServiceLocator.serverInstance().getRuleService().sendEvent(StrategyImpl.BASE, orderStatus);

	// only create fills if status is PARTIALLY_FILLED or FILLED
	if (executionReport.getOrdStatus().getValue() == OrdStatus.PARTIALLY_FILLED || executionReport.getOrdStatus().getValue() == OrdStatus.FILLED) {

		// get the fields
		Date dateTime = executionReport.getTransactTime().getValue();
		Side side = FixUtil.getSide(executionReport.getSide());
		long quantity = (long) executionReport.getLastShares().getValue();
		BigDecimal price = RoundUtil.getBigDecimal(executionReport.getLastPx().getValue(), order.getSecurity().getSecurityFamily().getScale());

		// assemble the fill
		Fill fill = Fill.Factory.newInstance();
		fill.setDateTime(dateTime);
		fill.setSide(side);
		fill.setQuantity(quantity);
		fill.setPrice(price);
		fill.setParentOrder(order);
	
		ServiceLocator.serverInstance().getRuleService().sendEvent(StrategyImpl.BASE, fill);
	}
}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:70,代码来源:FixMessageHandler.java


注:本文中的quickfix.field.OrdStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。