本文整理了Java中co.vaughnvernon.tradercommon.quote.Quote.price
方法的一些代码示例,展示了Quote.price
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quote.price
方法的具体详情如下:
包路径:co.vaughnvernon.tradercommon.quote.Quote
类名称:Quote
方法名:price
暂无
代码示例来源: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 Money valueOfPricedShares(int aQuantity) {
return this.price().multipliedBy(aQuantity);
}
代码示例来源: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
@Override
public int hashCode() {
int hashCodeValue =
+ (75931 * 41)
+ this.tickerSymbol().hashCode()
+ this.price().hashCode()
+ this.quantity();
return hashCodeValue;
}
代码示例来源: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
private void tradeUnfilledBuyOrdersUsing(QuoteBar aQuoteBar, VWAPAnalytic aVWAPAnalytic) {
Collection<AlgoOrder> algoOrders =
this.algoOrderRepository()
.unfilledBuyAlgoOrdersOfSymbol(
new TickerSymbol(aQuoteBar.symbol()));
AlgoSliceOrderSharesRequestedSubscriber subscriber =
new AlgoSliceOrderSharesRequestedSubscriber();
DomainEventPublisher.instance().subscribe(subscriber);
BigDecimal totalQuantityAvailable = aQuoteBar.totalQuantity();
Iterator<AlgoOrder> iterator = algoOrders.iterator();
while (iterator.hasNext() && totalQuantityAvailable.compareTo(BigDecimal.ZERO) > 0) {
AlgoOrder algoOrder = iterator.next();
if (aVWAPAnalytic.qualifiesAsTradePrice(algoOrder.quote().price())) {
this.attemptTradeFor(algoOrder, aVWAPAnalytic, subscriber);
totalQuantityAvailable =
totalQuantityAvailable
.subtract(new BigDecimal(subscriber.orderSharesRequested()));
}
}
}
代码示例来源: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 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 BuyOrder(
AccountId anAccountId,
Quote aQuote,
int aQuantityOfSharesOrdered,
Money anOrderFee) {
super();
this.setAccountId(anAccountId);
this.setExecution(new PurchaseExecution(aQuantityOfSharesOrdered));
this.setOrderId(OrderId.unique());
this.setQuote(aQuote);
DomainEventPublisher.instance().publish(
new BuyOrderPlaced(
this.accountId(),
this.orderId(),
this.quote(),
this.execution().quantityOfSharesOrdered(),
this.execution().openDate(),
aQuote.price().multipliedBy(aQuantityOfSharesOrdered),
anOrderFee));
}
代码示例来源: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
@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
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 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 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 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 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.");
}
}
内容来源于网络,如有侵权,请联系作者删除!