Ejemplo n.º 1
0
  /**
   * Test method for {@link
   * lt.norma.crossbow.indicators.MeasureList#orderUpdated(lt.norma.crossbow.trading.OrderUpdatedEvent)}
   * .
   *
   * @throws Throwable
   */
  @Test
  public void testOrderUpdated() throws Throwable {
    Contract c = new StockContract("B", Exchange.createNasdaq(), Currency.createEur());
    MarketOrder o = new MarketOrder(0, c, Direction.LONG, 500);
    OrderUpdatedEvent e = new OrderUpdatedEvent(this, o);

    MockMeasure m1 = new MockMeasure("AA", false);
    MockMeasure m2 = new MockMeasure("BB", false);
    MockIndicator i1 = new MockIndicator("CC", true);

    MeasureList l = new MeasureList(new TimePeriodSplitter(1000 * 60, DateTimeZone.UTC));
    l.add(m1);
    l.add(m2);
    l.add(i1);

    l.orderUpdated(e);

    assertEquals(o, m1.lastUpdatedOrder);
    assertEquals(o, m2.lastUpdatedOrder);
  }
Ejemplo n.º 2
0
  /**
   * Test method for {@link
   * lt.norma.crossbow.indicators.MeasureList#orderExecuted(lt.norma.crossbow.trading.OrderExecutedEvent)}
   * .
   *
   * @throws Throwable
   */
  @Test
  public void testOrderExecuted() throws Throwable {
    Contract c = new StockContract("B", Exchange.createNasdaq(), Currency.createEur());
    MarketOrder o = new MarketOrder(0, c, Direction.LONG, 500);
    FilledBlock b = new FilledBlock(Direction.LONG, 100, new BigDecimal("8"), new DateTime());
    ExecutionReport r = new ExecutionReport(o, b);
    OrderExecutedEvent e = new OrderExecutedEvent(this, r);

    MockMeasure m1 = new MockMeasure("AA", false);
    MockMeasure m2 = new MockMeasure("BB", false);
    MockIndicator i1 = new MockIndicator("CC", true);

    MeasureList l = new MeasureList(new TimePeriodSplitter(1000 * 60, DateTimeZone.UTC));
    l.add(m1);
    l.add(m2);
    l.add(i1);

    l.orderExecuted(e);

    assertEquals(r, m1.lastExecutionReport);
    assertEquals(r, m2.lastExecutionReport);
  }