co.vaughnvernon.tradercommon.quote.Quote类的使用及代码示例

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

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

Quote介绍

暂无

代码示例

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

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

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

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

代码示例来源: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 void createAlgoBuyOrder(
    String anOrderId,
    String aSymbol,
    Money aPrice,
    int aQuantity) {
  AlgoOrder algoOrder =
      new AlgoOrder(
          anOrderId,
          OrderType.Buy,
          new Quote(
              new TickerSymbol(aSymbol),
              aPrice,
              aQuantity));
  this.algoOrderRepository().save(algoOrder);
}

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

public void testValueOfPricedShares() throws Exception {
    Quote quote = new Quote(new TickerSymbol("GOOG"), new Money("723.41"));

    assertEquals(new Money("2893.64"), quote.valueOfPricedShares(4));

    assertEquals(quote.price().multipliedBy(4), quote.valueOfPricedShares(4));
  }
}

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

UUID.randomUUID().toString().toUpperCase(),
        OrderType.Buy,
        new Quote(
            new TickerSymbol("GOOG"),
            new Money("725.50"),
assertNotNull(algoOrder.fill());
assertEquals(algoOrder.quote().price(), algoOrder.fill().price());
assertEquals(algoOrder.quote().quantity(), algoOrder.fill().quantity().intValue());
assertNotNull(algoOrder.fill().filledOn());

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

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

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

public Money valueOfPricedShares(int aQuantity) {
  return this.price().multipliedBy(aQuantity);
}

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

private void filled() {
  if (this.isFilled()) {
    throw new IllegalStateException("Algo order is already filled.");
  }
  if (this.hasSharesRemaining()) {
    throw new IllegalStateException("Algo order is not yet filled.");
  }
  this.setFill(
      new Fill(
          this.quote().price(),
          new BigDecimal(this.quote().quantity()),
          new Date()));
  DomainEventPublisher
    .instance()
    .publish(new AlgoOrderFilled(
        this.orderId(),
        this.type().name(),
        this.quote()));
}

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

public BuyOrder placeBuyOrder(
    TickerSymbol aTickerSymbol,
    Money aPrice,
    int aNumberOfShares,
    Money anOrderFee) {
  Quote quote = new Quote(aTickerSymbol, aPrice);
  Money totalCost = anOrderFee.addedTo(quote.valueOfPricedShares(aNumberOfShares));
  if (totalCost.isGreaterThan(this.cashBalance())) {
    // TODO: Charge credit card for order
    throw new IllegalStateException("Cash balance is too low for this buy order.");
  }
  return new BuyOrder(
      this.accountId(),
      quote,
      aNumberOfShares,
      anOrderFee);
}

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

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

代码示例来源: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 AlgoOrder(
    String anOrderId,
    OrderType aType,
    Quote aQuote) {
  super();
  if (aQuote.quantity() < 500) {
    throw new IllegalArgumentException("Cannot be less than 500 shares.");
  }
  this.setOrderId(anOrderId);
  this.setType(aType);
  this.setQuote(aQuote);
  this.setSharesRemaining(new BigDecimal(aQuote.quantity()));
}

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

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

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

public Money valueOfOrderedShares() {
  return this.quote().valueOfPricedShares(this.quantityOfSharesOrdered());
}

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

public void testQuoteCopy() throws Exception {
  Quote quote = new Quote(new TickerSymbol("GOOG"), new Money("723.41"));
  Quote quoteCopy = new Quote(quote);
  assertEquals(quote, quoteCopy);
  assertNotSame(quote, quoteCopy);
}

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

public Money latestPriceFor(TickerSymbol aTickerSymbol) {
  StreamingQuote streamingQuote =
      this.streamingQuoteRepository()
        .streamingQuoteOfSymbol(aTickerSymbol.symbol());
  return streamingQuote == null ? null : streamingQuote.quote().price();
}

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

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

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

int totalQuantity = this.algoOrder.quote().quantity();

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

@Override
public Collection<AlgoOrder> unfilledBuyAlgoOrdersOfSymbol(TickerSymbol aTickerSymbol) {
  List<AlgoOrder> algoOrders = new ArrayList<AlgoOrder>();
  for (AlgoOrder algoOrder : this.algoOrders().values()) {
    if (algoOrder.quote().hasTickerSymbol(aTickerSymbol)) {
      if (algoOrder.hasSharesRemaining()) {
        algoOrders.add(algoOrder);
      }
    }
  }
  return algoOrders;
}

相关文章