@Test public void test_partial_close_and_fully_close(){ assertValue(account, portfolio, 1_000_000, 0.0, 1_000_000, 0.0, 0.0, 1_000_000); Order buyOrder = limitOrder(instrument1.getInstId(), 10000, 2, Side.Buy); ExecutionReport er1 = executionReport(buyOrder, 10000, 2); buyOrder.add(er1); portfolioProcessor.add(buyOrder); assertValue(account, portfolio, 980_000, 20_000, 1_000_000, -20_000, -20_000, 1_000_000); Order sellOrder1 = limitOrder(instrument1.getInstId(), 15000, 1, Side.Sell); ExecutionReport er2 = executionReport(sellOrder1, 15000, 1); sellOrder1.add(er2); portfolioProcessor.add(sellOrder1); assertValue(account, portfolio, 995_000, 15000 , 1_010_000, -5000, -5000, 1_010_000); Order sellOrder2 = limitOrder(instrument1.getInstId(), 20000, 1, Side.Sell); ExecutionReport er3 = executionReport(sellOrder2, 20000, 1); sellOrder2.add(er3); portfolioProcessor.add(sellOrder2); assertValue(account, portfolio, 1_015_000, 0 , 1_015_000, 0, 0, 1_015_000); }
public void add(Order order){ double newDebt = addOrderToPosition(order); Currency currency = refDataStore.getCurrency(refDataStore.getInstrument(order.instId()).getCcyId()); AccountTransaction accountTransaction = new AccountTransaction(order.clOrderId(), order.dateTime(), currency, order.cashFlow() + newDebt, order.text()); account.add(accountTransaction); portfolio.performance().valueChanged(clock.now(), coreEquity(), totalEquity()); }
PortfolioProcessor extends MultiEventProcessor implements MarketDataHandler, OrderEventHandler, ExecutionEventHandler { public void add(Order order){ double newDebt = addOrderToPosition(order); Currency currency = refDataStore.getCurrency(refDataStore.getInstrument(order.instId()).getCcyId()); AccountTransaction accountTransaction = new AccountTransaction(order.clOrderId(), order.dateTime(), currency, order.cashFlow() + newDebt, order.text()); account.add(accountTransaction); portfolio.performance().valueChanged(clock.now(), coreEquity(), totalEquity()); } }
PortfolioProcessor extends MultiEventProcessor implements MarketDataHandler, OrderEventHandler, ExecutionEventHandler { public void add(Order order){ double newDebt = addOrderToPosition(order); Currency currency = refDataStore.getCurrency(refDataStore.getInstrument(order.instId()).getCcyId()); AccountTransaction accountTransaction = new AccountTransaction(order.clOrderId(), order.dateTime(), currency, order.cashFlow() + newDebt, order.text()); account.add(accountTransaction); portfolio.performance().valueChanged(clock.now(), coreEquity(), totalEquity()); } PortfolioProcessor(AppConfig appConfig, Portfolio portfolio, Account account, RingBuffer... providers);  PortfolioProcessor(Portfolio portfolio, Account account, RefDataStore refDataStore, Clock clock, RingBuffer... providers); }
PortfolioProcessor extends MultiEventProcessor implements MarketDataHandler, OrderEventHandler, ExecutionEventHandler { public void add(Order order){ double newDebt = addOrderToPosition(order); Currency currency = refDataStore.getCurrency(refDataStore.getInstrument(order.instId()).getCcyId()); AccountTransaction accountTransaction = new AccountTransaction(order.clOrderId(), order.dateTime(), currency, order.cashFlow() + newDebt, order.text()); account.add(accountTransaction); portfolio.performance().valueChanged(clock.now(), coreEquity(), totalEquity()); } PortfolioProcessor(AppConfig appConfig, Portfolio portfolio, Account account, RingBuffer... providers);  PortfolioProcessor(Portfolio portfolio, Account account, RefDataStore refDataStore, Clock clock, RingBuffer... providers); int portfolioId(); Portfolio portfolio(); @Override void onEvent(Event event); @Override void onBar(Bar bar); @Override void onQuote(Quote quote); @Override void onTrade(Trade trade); @Override void onExecutionReport(ExecutionReport executionReport); @Override void onNewOrderRequest(Order order); @Override void onOrderUpdateRequest(Order order); @Override void onOrderCancelRequest(Order order); void add(Order order); void updatePerformance(long dateTime); void updatePerformance(); void reconstruct(); double positionValue(); double accountValue(); double value(); double marginValue(); double debtValue(); double coreEquity(); double totalEquity(); double leverage(); double debtEquityRatio(); double cashFlow(); double netCashFlow(); }
PortfolioProcessor extends MultiEventProcessor implements MarketDataHandler, OrderEventHandler, ExecutionEventHandler { public void add(Order order){ double newDebt = addOrderToPosition(order); Currency currency = refDataStore.getCurrency(refDataStore.getInstrument(order.instId()).getCcyId()); AccountTransaction accountTransaction = new AccountTransaction(order.clOrderId(), order.dateTime(), currency, order.cashFlow() + newDebt, order.text()); account.add(accountTransaction); portfolio.performance().valueChanged(clock.now(), coreEquity(), totalEquity()); } PortfolioProcessor(AppConfig appConfig, Portfolio portfolio, Account account, RingBuffer... providers);  PortfolioProcessor(Portfolio portfolio, Account account, RefDataStore refDataStore, Clock clock, RingBuffer... providers); int portfolioId(); Portfolio portfolio(); @Override void onEvent(Event event); @Override void onBar(Bar bar); @Override void onQuote(Quote quote); @Override void onTrade(Trade trade); @Override void onExecutionReport(ExecutionReport executionReport); @Override void onNewOrderRequest(Order order); @Override void onOrderUpdateRequest(Order order); @Override void onOrderCancelRequest(Order order); void add(Order order); void updatePerformance(long dateTime); void updatePerformance(); void reconstruct(); double positionValue(); double accountValue(); double value(); double marginValue(); double debtValue(); double coreEquity(); double totalEquity(); double leverage(); double debtEquityRatio(); double cashFlow(); double netCashFlow();  }