View Javadoc

1   /*
2    *  
3    *  author nambi sankaran
4    *  copyright (C) 2009 nambi sankaran.
5    *
6    *  This program is free software: you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation, either version 3 of the License, or
9    *  (at your option) any later version.
10   *
11   *  This program is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   *  GNU General Public License for more details.
15   *
16   *  You should have received a copy of the GNU General Public License
17   *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   *
19   */
20  package net.sf.emarket.trade.service;
21  
22  import java.io.Serializable;
23  import java.util.List;
24  
25  import net.sf.emarket.account.service.NotEnoughCashException;
26  import net.sf.emarket.account.service.NotEnoughPositionsException;
27  import net.sf.emarket.account.service.NotValidAccountException;
28  import net.sf.emarket.order.domain.Order;
29  import net.sf.emarket.order.service.OrderCannotBeFilledException;
30  import net.sf.emarket.order.service.OrderFillQuantityMismatchException;
31  import net.sf.emarket.trade.domain.MarketDepth;
32  import net.sf.emarket.trade.domain.OrderBook;
33  import net.sf.emarket.trade.domain.OrderBookLock;
34  import net.sf.emarket.trade.domain.OrderFill;
35  import net.sf.emarket.trade.domain.OrderMatch;
36  import net.sf.emarket.trade.domain.ReceivedOrder;
37  
38  /***
39   * ITradingService implements low level services of the matching engine.
40   * @author snambi
41   */
42  interface ITradingService extends Serializable {
43  	
44  	public ReceivedOrder getReceivedOrderById( String orderId );
45  	public void addReceivedOrder( ReceivedOrder order);
46  	
47  	public OrderBookLock lockOrderBook( String symbol);
48  	public void releaseOrderBook(String symbol);
49  	
50  	public OrderBook getOrderBook(String symbol);
51  	public void updateOrderBook( ReceivedOrder order );
52  	
53  	public List<OrderFill> createOrderFills( List<OrderMatch> matches);
54  	public void addMatchedOrders( List<OrderMatch> matches );	
55  	public List<OrderMatch> getMatchedOrders( ReceivedOrder order );
56  	public void updateOrderBook( ReceivedOrder receivedOrder, List<OrderMatch> matches, int matchedQuantity );
57  	
58  	public void matchOrder(Order order);
59  	public void sendOrderFills(List<OrderFill> fills) throws OrderCannotBeFilledException, OrderFillQuantityMismatchException;
60  	public void sendOrderMatches(List<OrderMatch> matches) throws OrderCannotBeFilledException, NotEnoughCashException, NotValidAccountException, NotEnoughPositionsException;
61  	
62  	public MarketDepth getMarketDepth(String symbol);
63  
64  }