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


Java OrdType类代码示例

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


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

示例1: getPrice

import quickfix.field.OrdType; //导入依赖的package包/类
private Price getPrice(Message message) throws FieldNotFound {
    Price price;
    if (message.getChar(OrdType.FIELD) == OrdType.LIMIT && alwaysFillLimitOrders) {
        price = new Price(message.getDouble(Price.FIELD));
    } else {
        if (marketQuoteProvider == null) {
            throw new RuntimeException("No market data provider specified for market order");
        }
        char side = message.getChar(Side.FIELD);
        if (side == Side.BUY) {
            price = new Price(marketQuoteProvider.getAsk(message.getString(Symbol.FIELD)));
        } else if (side == Side.SELL || side == Side.SELL_SHORT) {
            price = new Price(marketQuoteProvider.getBid(message.getString(Symbol.FIELD)));
        } else {
            throw new RuntimeException("Invalid order side: " + side);
        }
    }
    return price;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:TradeExecutor.java

示例2: createNewOrderMessage

import quickfix.field.OrdType; //导入依赖的package包/类
private NewOrderSingle createNewOrderMessage() {
    NewOrderSingle order = new NewOrderSingle(
        new ClOrdID("CLIENT_ORDER_ID"), 
        new HandlInst('1'), 
        new Symbol("GOOG"), 
        new Side(Side.BUY), 
        new TransactTime(new Date()), 
        new OrdType(OrdType.LIMIT));
    
    order.set(new OrderQty(10));
    order.set(new Price(300.00));
    
    return order;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:TradeExecutorExample.java

示例3: TradeExecutor

import quickfix.field.OrdType; //导入依赖的package包/类
public TradeExecutor() throws ConfigError, FieldConvertError {
    setAlwaysFillLimitOrders(true);

    Set<String> validOrderTypes = new HashSet<String>();
    validOrderTypes.add(OrdType.LIMIT + "");
    validOrderTypes.add(OrdType.MARKET + "");
    setValidOrderTypes(validOrderTypes);

    setMarketQuoteProvider(new DefaultMarketQuoteProvider(10.00));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:TradeExecutor.java

示例4: isOrderExecutable

import quickfix.field.OrdType; //导入依赖的package包/类
private boolean isOrderExecutable(Message order, Price price) throws FieldNotFound {
    if (order.getChar(OrdType.FIELD) == OrdType.LIMIT) {
        BigDecimal limitPrice = new BigDecimal(order.getString(Price.FIELD));
        char side = order.getChar(Side.FIELD);
        BigDecimal thePrice = new BigDecimal(price.getValue());

        return (side == Side.BUY && thePrice.compareTo(limitPrice) <= 0)
            || ((side == Side.SELL || side == Side.SELL_SHORT) && thePrice.compareTo(limitPrice) >= 0);
    }
    return true;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:TradeExecutor.java

示例5: validateOrder

import quickfix.field.OrdType; //导入依赖的package包/类
private void validateOrder(Message order) throws IncorrectTagValue, FieldNotFound {
    OrdType ordType = new OrdType(order.getChar(OrdType.FIELD));
    if (!validOrderTypes.contains(Character.toString(ordType.getValue()))) {
        LOG.error("Order type not in ValidOrderTypes setting");
        throw new IncorrectTagValue(ordType.getField());
    }
    if (ordType.getValue() == OrdType.MARKET && marketQuoteProvider == null) {
        LOG.error("DefaultMarketPrice setting not specified for market order");
        throw new IncorrectTagValue(ordType.getField());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:TradeExecutor.java

示例6: getFixOrderType

import quickfix.field.OrdType; //导入依赖的package包/类
public static OrdType getFixOrderType(Order order) {

		if (order instanceof MarketOrder) {
			return new OrdType(OrdType.MARKET);
		} else if (order instanceof LimitOrder) {
			return new OrdType(OrdType.LIMIT);
		} else if (order instanceof StopOrder) {
			return new OrdType(OrdType.STOP);
		} else if (order instanceof StopLimitOrder) {
			return new OrdType(OrdType.STOP_LIMIT);
		} else {
			throw new IllegalArgumentException("unsupported order type " + order.getClass().getName());
		}
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:15,代码来源:FixUtil.java

示例7: testPopulate

import quickfix.field.OrdType; //导入依赖的package包/类
/**
 * 
 * <pre>
 * <fixr:fieldRef id="11" name="ClOrdID" added="FIX.2.7" updated="FIX.5.0SP2" updatedEP="188">
     <fixr:assign>in.ClOrdID</fixr:assign>
   </fixr:fieldRef>
   
    <fixr:groupRef id="1012" name="Parties" added="FIX.4.3" updated="FIX.5.0SP2" updatedEP="188">
    <fixr:blockAssignment>
        <fixr:fieldRef id="448" name="PartyID">
            <fixr:assign>"ABC"</fixr:assign>
        </fixr:fieldRef>
        <fixr:fieldRef id="447" name="PartyIDSource">
            <fixr:assign>^GeneralIdentifier</fixr:assign>
        </fixr:fieldRef>
        <fixr:fieldRef id="452" name="PartyRole">
            <fixr:assign>^ExecutingFirm</fixr:assign>
        </fixr:fieldRef>
    </fixr:blockAssignment>
    <fixr:blockAssignment>
        <fixr:fieldRef id="448" name="PartyID">
            <fixr:assign>"DEF"</fixr:assign>
        </fixr:fieldRef>
        <fixr:fieldRef id="447" name="PartyIDSource">
            <fixr:assign>^GeneralIdentifier</fixr:assign>
        </fixr:fieldRef>
        <fixr:fieldRef id="452" name="PartyRole">
            <fixr:assign>^ClearingFirm</fixr:assign>
        </fixr:fieldRef>
    </fixr:blockAssignment>
    </fixr:groupRef>
   </pre>
 */
@Test
public void testPopulate() throws ModelException, quickfix.FieldNotFound {
  MessageType inboundMessageType = repositoryAdapter.getMessage("NewOrderSingle", "base");
  MessageType outboundMessageType = repositoryAdapter.getMessage("ExecutionReport", "traded");
  
  NewOrderSingle inboundMessage = new NewOrderSingle();
  String clOrdId = "ABC123";
  // required fields
  inboundMessage.set(new ClOrdID(clOrdId));
  inboundMessage.set(new Account("ABC"));
  inboundMessage.set(new Side('2'));
  inboundMessage.set(new OrdType('2'));
  inboundMessage.set(new TimeInForce('2'));
  
  ExecutionReport outboundMessage = new ExecutionReport();

  populator.populate(inboundMessage, inboundMessageType, outboundMessage, outboundMessageType);
   
  System.out.println(outboundMessage.toString());
  assertEquals(clOrdId, outboundMessage.getClOrdID().getValue());
 }
 
开发者ID:FIXTradingCommunity,项目名称:fix-orchestra,代码行数:55,代码来源:PopulatorTest.java


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