Package org.fudgemsg

Examples of org.fudgemsg.MutableFudgeMsg


    assertEquals(3, normalized.getAllFields().size());
    assertEquals(50.815, normalized.getDouble(MarketDataRequirementNames.IMPLIED_VOLATILITY), 0.0001);
  }

  public void history() {
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add(MarketDataRequirementNames.IMPLIED_VOLATILITY, 50.80);
   
    FieldHistoryStore store = new FieldHistoryStore();
    store.liveDataReceived(msg);
   
    MutableFudgeMsg normalized = _calculator.apply(OpenGammaFudgeContext.getInstance().newMessage(), "123", store);
    assertEquals(1, normalized.getAllFields().size());
    assertEquals(50.80, normalized.getDouble(MarketDataRequirementNames.IMPLIED_VOLATILITY), 0.0001);
  }
View Full Code Here


public class RequiredFieldFilterTest {

  public void noRequiredFields() {
    RequiredFieldFilter filter = new RequiredFieldFilter();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("Foo", "1");
    msg.add("Bar", 2.0);
    msg.add("Baz", 500);
   
    MutableFudgeMsg normalized = filter.apply(msg, "123", new FieldHistoryStore());
    assertNotNull(normalized);
    assertSame(normalized, msg);
  }
View Full Code Here

  }

  public void requiredFieldsNotSatisfied() {
    RequiredFieldFilter filter = new RequiredFieldFilter("Foo", "Fibble");
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("Foo", "1");
    msg.add("Bar", 2.0);
    msg.add("Baz", 500);
   
    MutableFudgeMsg normalized = filter.apply(msg, "123", new FieldHistoryStore());
    assertNull(normalized);
  }
View Full Code Here

  }

  public void requiredFieldsSatisfied() {
    RequiredFieldFilter filter = new RequiredFieldFilter("Foo");
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("Foo", "1");
    msg.add("Bar", 2.0);
    msg.add("Baz", 500);
   
    MutableFudgeMsg normalized = filter.apply(msg, "123", new FieldHistoryStore());
    assertNotNull(normalized);
    assertSame(normalized, msg);
  }
View Full Code Here

  public MutableFudgeMsg buildMessage(FudgeSerializer serializer, LiveDataSpecification object) {
    return LiveDataSpecificationFudgeBuilder.toFudgeMsg(serializer, object);
  }

  public static MutableFudgeMsg toFudgeMsg(FudgeSerializer serializer, LiveDataSpecification object) {
    final MutableFudgeMsg msg = serializer.newMessage();
    LiveDataSpecificationFudgeBuilder.toFudgeMsg(serializer, object, msg);
    return msg;
  }
View Full Code Here

  public void testSequenceNumber() {
    MarketDataDistributor mdd = getTestDistributor();
    assertEquals(LiveDataValueUpdate.SEQUENCE_START, mdd.getNumMessagesSent());
    mdd.updateFieldHistory(FudgeContext.EMPTY_MESSAGE);
    assertEquals(0, mdd.getNumMessagesSent());
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("foo", "bar");
    mdd.distributeLiveData(msg);
    assertEquals(1, mdd.getNumMessagesSent());
   
    mdd.distributeLiveData(FudgeContext.EMPTY_MESSAGE); // empty msg not sent
    assertEquals(1, mdd.getNumMessagesSent());
View Full Code Here

  @Test
  public void noNormalization() {
    NormalizationRuleSet ruleSet = StandardRules.getNoNormalization();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("Foo", "1");
    msg.add("Bar", 2.0);
    msg.add("Baz", 500);
   
    FieldHistoryStore store = new FieldHistoryStore();
    FudgeMsg normalizedMsg = ruleSet.getNormalizedMessage(msg, "123", store);
    assertEquals(msg, normalizedMsg);
  }
View Full Code Here

  @Test
  public void unitChange() {
    UnitChange unitChange = new UnitChange("Foo", 10);
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("Foo", 2.0);
    msg.add("Bar", "2");
   
    MutableFudgeMsg normalized = unitChange.apply(msg, "123", new FieldHistoryStore());
    assertEquals(2, normalized.getAllFields().size());
    assertEquals(20.0, normalized.getDouble("Foo"), 0.0001);
  }
View Full Code Here

    RedisLastKnownValueStoreProvider provider = new RedisLastKnownValueStoreProvider();
    provider.setServer(REDIS_SERVER);
    provider.setGlobalPrefix(generatePrefix("testBasicFunctionality"));
    provider.setWriteThrough(true);
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
   
    LastKnownValueStore store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    FudgeMsg currFields = store.getFields();
    assertTrue(currFields.isEmpty());
   
    msg.add("bid", 1.0d);
    msg.add("ask", 2.0d);
   
    store.updateFields(msg);
   
    currFields = store.getFields();
    assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Reset the store.
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(1.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Write through another value and confirm it works.
    msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("bid", 5.0d);
    store.updateFields(msg);
   
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    // Reset the store. This time don't write through.
    provider.setWriteThrough(false);
    store = provider.newInstance(ExternalId.of("Test", "testBasicFunctionality"), "no-norm");
    currFields = store.getFields();
    assertEquals(5.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(2.0d, currFields.getDouble("ask"), 0.0005d);
   
    msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add("bid", 3.0d);
    msg.add("ask", 4.0d);
    store.updateFields(msg);
    currFields = store.getFields();
    assertEquals(3.0d, currFields.getDouble("bid"), 0.0005d);
    assertEquals(4.0d, currFields.getDouble("ask"), 0.0005d);
View Full Code Here

public class MarketValueCalculatorTest {

  public void bidAskLast() {
    MarketValueCalculator calculator = new MarketValueCalculator();
   
    MutableFudgeMsg msg = OpenGammaFudgeContext.getInstance().newMessage();
    msg.add(MarketDataRequirementNames.BID, 50.80);
    msg.add(MarketDataRequirementNames.ASK, 50.90);
    msg.add(MarketDataRequirementNames.LAST, 50.89);
   
    FieldHistoryStore store = new FieldHistoryStore();
    store.liveDataReceived(msg);
   
    MutableFudgeMsg normalized = calculator.apply(msg, "123", store);
    assertEquals(4, normalized.getAllFields().size());
    assertEquals(50.85, normalized.getDouble(MarketDataRequirementNames.MARKET_VALUE), 0.0001);
  }
View Full Code Here

TOP

Related Classes of org.fudgemsg.MutableFudgeMsg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.