co.vaughnvernon.tradercommon.quote.Quote.tickerSymbol()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中co.vaughnvernon.tradercommon.quote.Quote.tickerSymbol方法的一些代码示例,展示了Quote.tickerSymbol的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quote.tickerSymbol方法的具体详情如下:
包路径:co.vaughnvernon.tradercommon.quote.Quote
类名称:Quote
方法名:tickerSymbol

Quote.tickerSymbol介绍

暂无

代码示例

代码示例来源:origin: VaughnVernon/IDDD_NYSE

@Override
public String toString() {
  return "Quote [tickerSymbol=" + this.tickerSymbol() + ", price=" + this.price() + "]";
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public Quote(Quote aQuote) {
  this(aQuote.tickerSymbol(), aQuote.price());
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public boolean hasTickerSymbol(TickerSymbol aTickerSymbol) {
  return this.tickerSymbol().equals(aTickerSymbol);
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public Quote withUpdatedPrice(Money aPrice) {
  return new Quote(this.tickerSymbol(), aPrice);
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

@Override
public boolean equals(Object anObject) {
  boolean equalObjects = false;
  if (anObject != null && this.getClass() == anObject.getClass()) {
    Quote typedObject = (Quote) anObject;
    equalObjects =
        this.tickerSymbol().equals(typedObject.tickerSymbol()) &&
        this.price().equals(typedObject.price()) &&
        this.quantity() == typedObject.quantity();
  }
  return equalObjects;
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public StreamingQuote(Quote aQuote) {
  super();
  this.setQuote(aQuote);
  this.setSymbol(aQuote.tickerSymbol().symbol());
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

@Override
public int hashCode() {
  int hashCodeValue =
      + (75931 * 41)
      + this.tickerSymbol().hashCode()
      + this.price().hashCode()
      + this.quantity();
  return hashCodeValue;
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void requestSlice(Money aPrice, BigDecimal aSliceQuantity) {
  if (this.hasSharesRemaining()) {
    BigDecimal sharesToAcquire =
        this.min(this.sharesRemaining(), aSliceQuantity);
    this.setSharesRemaining(this.sharesRemaining().subtract(sharesToAcquire));
    DomainEventPublisher
      .instance()
      .publish(new AlgoSliceOrderSharesRequested(
          this.orderId(),
          this.quote().tickerSymbol(),
          aPrice,
          aSliceQuantity));
    if (!this.hasSharesRemaining()) {
      this.filled();
    }
  }
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public Holding holdingOfFilledOrder() {
  if (!this.isFilled()) {
    throw new IllegalStateException("Order must be filled before Holding can be queried.");
  }
  Holding holding = this.holding;
  if (holding == null) {
    int sharesOrdered = this.execution().quantityOfSharesOrdered();
    Money totalValue = this.quote().valueOfPricedShares(sharesOrdered);
    holding = new Holding(
          this.accountId(),
          this.orderId(),
          this.quote().tickerSymbol(),
          sharesOrdered,
          totalValue,
          this.execution().filledDate());
    this.setHolding(holding);
  }
  return holding;
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testQuoteTickerSymbol() throws Exception {
  Quote quote = new Quote(new TickerSymbol("GOOG"), new Money("723.41"));
  assertEquals(quote.tickerSymbol(), new TickerSymbol("GOOG"));
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

@Override
public void handleEvent(BuyOrderPlaced aDomainEvent) {
  reconcilableAccount.reconcileWith(
      new Payment(
          aDomainEvent.accountId(),
          aDomainEvent.orderId(),
          "BUY: "
              + aDomainEvent.quantityOfSharesOrdered()
              + " of "
              + aDomainEvent.quote().tickerSymbol()
              + " at "
              + aDomainEvent.quote().price(),
          aDomainEvent.cost(),
          aDomainEvent.orderFee(),
          aDomainEvent.placedOnDate()));
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testPlaceBuyOrder() throws Exception {
  Money money = new Money("10000.00");
  Account account = this.profileFixture().openAccount(money);
  Money orderFee = new Money("9.99");
  Money price = new Money("723.25");
  int shares = 10;
  TickerSymbol tickerSymbol = new TickerSymbol("GOOG");
  BuyOrder buyOrder = account.placeBuyOrder(tickerSymbol, price, shares, orderFee);
  assertEquals(account.accountId(), buyOrder.accountId());
  assertEquals(tickerSymbol, buyOrder.quote().tickerSymbol());
  assertEquals(price, buyOrder.quote().price());
  assertEquals(shares, buyOrder.quantityOfSharesOrdered());
  assertEquals(shares, buyOrder.execution().quantityOfSharesOrdered());
  assertEquals(shares, buyOrder.execution().quantityOfSharesOutstanding());
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testBuyOrderCreation() throws Exception {
  DomainEventPublisher.instance().subscribe(new DomainEventSubscriber<BuyOrderPlaced>() {
    @Override
    public void handleEvent(BuyOrderPlaced aDomainEvent) {
      buyOrderPlaced = aDomainEvent;
    }
    @Override
    public Class<BuyOrderPlaced> subscribedToEventType() {
      return BuyOrderPlaced.class;
    }
  });
  BuyOrder buyOrder = this.buyOrderFixture();
  assertNotNull(buyOrderPlaced);
  assertNotNull(buyOrder.accountId());
  assertNotNull(buyOrder.execution());
  assertFalse(buyOrder.isFilled());
  assertTrue(buyOrder.isOpen());
  assertEquals(NUMBER_OF_SHARES, buyOrder.quantityOfSharesOrdered());
  assertNotNull(buyOrder.quote());
  assertEquals(TICKER, buyOrder.quote().tickerSymbol().symbol());
  assertEquals(PRICE, buyOrder.quote().price());
  assertEquals(PRICE.multipliedBy(NUMBER_OF_SHARES), buyOrder.valueOfOrderedShares());
  try {
    buyOrder.holdingOfFilledOrder();
    fail("Holding must not have been created yet.");
  } catch (Exception e) {
    // success
  }
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testHoldingAfterFill() throws Exception {
  BuyOrder buyOrder = this.buyOrderFixture();
  assertTrue(buyOrder.isOpen());
  assertFalse(buyOrder.isFilled());
  buyOrder.sharesToPurchase(buyOrder.execution().quantityOfSharesOrdered());
  try {
    Holding holding = buyOrder.holdingOfFilledOrder();
    assertNotNull(holding);
    assertEquals(buyOrder.accountId(), holding.accountId());
    assertEquals(buyOrder.holdingOfFilledOrder().acquiredOn(), holding.acquiredOn());
    assertEquals(buyOrder.orderId(), holding.orderId());
    assertEquals(buyOrder.quantityOfSharesOrdered(), holding.numberOfShares());
    assertEquals(buyOrder.quote().tickerSymbol(), holding.tickerSymbol());
    assertEquals(buyOrder.quote().price().multipliedBy(buyOrder.quantityOfSharesOrdered()), holding.totalValue());
  } catch (Exception e) {
    fail("Holding should be available with filled order.");
  }
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testPlaceBuyOrder() throws Exception {
  DomainEventPublisher.instance().subscribe(new DomainEventSubscriber<BuyOrderPlaced>() {
    @Override
    public void handleEvent(BuyOrderPlaced aDomainEvent) {
      buyOrderPlaced = aDomainEvent;
    }
    @Override
    public Class<BuyOrderPlaced> subscribedToEventType() {
      return BuyOrderPlaced.class;
    }
  });
  BuyOrder buyOrder = this.buyOrderFixture(); // event published here
  assertNotNull(buyOrderPlaced);
  assertEquals(new Money("9.99"), buyOrderPlaced.orderFee());
  assertEquals(NUMBER_OF_SHARES, buyOrderPlaced.quantityOfSharesOrdered());
  assertEquals(PRICE, buyOrderPlaced.quote().price());
  assertEquals(TICKER, buyOrderPlaced.quote().tickerSymbol().symbol());
  assertEquals(PRICE.multipliedBy(NUMBER_OF_SHARES), buyOrder.valueOfOrderedShares());
  assertEquals(buyOrder.accountId(), buyOrderPlaced.accountId());
  assertEquals(buyOrder.orderId(), buyOrderPlaced.orderId());
  assertEquals(buyOrder.quantityOfSharesOrdered(), buyOrderPlaced.quantityOfSharesOrdered());
  assertEquals(buyOrder.quote(), buyOrderPlaced.quote());
}

代码示例来源:origin: VaughnVernon/IDDD_NYSE

public void testFillBuyOrder() throws Exception {
  DomainEventPublisher.instance().subscribe(new DomainEventSubscriber<BuyOrderFilled>() {
    @Override
    public void handleEvent(BuyOrderFilled aDomainEvent) {
      buyOrderFilled = aDomainEvent;
    }
    @Override
    public Class<BuyOrderFilled> subscribedToEventType() {
      return BuyOrderFilled.class;
    }
  });
  BuyOrder buyOrder = this.buyOrderFixture(); // event published here
  buyOrder.sharesToPurchase(NUMBER_OF_SHARES);
  assertNotNull(buyOrderFilled);
  assertTrue(buyOrder.isFilled());
  assertFalse(buyOrder.isOpen());
  Holding holding = null;
  try {
    holding = buyOrder.holdingOfFilledOrder();
    assertEquals(buyOrder.accountId(), holding.accountId());
    assertEquals(buyOrder.holdingOfFilledOrder().acquiredOn(), holding.acquiredOn());
    assertEquals(buyOrder.orderId(), holding.orderId());
    assertEquals(buyOrder.quantityOfSharesOrdered(), holding.numberOfShares());
    assertEquals(buyOrder.quote().tickerSymbol(), holding.tickerSymbol());
    assertEquals(buyOrder.quote().price().multipliedBy(buyOrder.quantityOfSharesOrdered()), holding.totalValue());
  } catch (Exception e) {
    fail("Holding should be available with filled order.");
  }
}

相关文章