├── README.md ├── src └── org │ └── jopenexchg │ ├── MatcherDemo.java │ ├── hldg │ ├── HldgKey.java │ ├── HldgTable.java │ └── Hldg.java │ ├── matcher │ ├── Order.java │ ├── Matcher.java │ ├── TradedInst.java │ ├── PriceLeader.java │ ├── TradedInstList.java │ ├── biz │ │ ├── BizAdaptor.java │ │ └── impl │ │ │ └── BondBizAdaptorImpl.java │ ├── CallAuctionResult.java │ └── event │ │ ├── impl │ │ ├── EventHandlerHldgImpl.java │ │ └── EventHandlerDebugImpl.java │ │ └── EventHandler.java │ └── pool │ ├── AllocOnlyPool.java │ ├── RecyclablePool.java │ └── WithId.java └── run.bat /README.md: -------------------------------------------------------------------------------- 1 | # jOpenExchg 2 | 3 | This is a Java Match Engine for stocks. It aims at high throughput. 4 | -------------------------------------------------------------------------------- /src/org/jopenexchg/MatcherDemo.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/MatcherDemo.java -------------------------------------------------------------------------------- /src/org/jopenexchg/hldg/HldgKey.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/hldg/HldgKey.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/Order.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/Order.java -------------------------------------------------------------------------------- /src/org/jopenexchg/hldg/HldgTable.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/hldg/HldgTable.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/Matcher.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/Matcher.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/TradedInst.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/TradedInst.java -------------------------------------------------------------------------------- /src/org/jopenexchg/pool/AllocOnlyPool.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/pool/AllocOnlyPool.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/PriceLeader.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/PriceLeader.java -------------------------------------------------------------------------------- /src/org/jopenexchg/pool/RecyclablePool.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/pool/RecyclablePool.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/TradedInstList.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/TradedInstList.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/biz/BizAdaptor.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/biz/BizAdaptor.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/CallAuctionResult.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/CallAuctionResult.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/biz/impl/BondBizAdaptorImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/biz/impl/BondBizAdaptorImpl.java -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/event/impl/EventHandlerHldgImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gelupa/jOpenExchg/HEAD/src/org/jopenexchg/matcher/event/impl/EventHandlerHldgImpl.java -------------------------------------------------------------------------------- /run.bat: -------------------------------------------------------------------------------- 1 | set CLASSPATH=.\bin 2 | set GCDEBUG= 3 | 4 | rem set GCDEBUG=-XX:+PrintGCDetails -XX:+PrintGCTimeStamps 5 | 6 | java -Xmx800M -Xms800M -Xmn50M -Xss32K -XX:SurvivorRatio=10 %GCDEBUG% -cp %CLASSPATH% org.jopenexchg.MatcherDemo 7 | 8 | pause 9 | 10 | -------------------------------------------------------------------------------- /src/org/jopenexchg/pool/WithId.java: -------------------------------------------------------------------------------- 1 | /* Java Open Exchange(jOpenExchg) Project 2 | * 3 | * Copyright (C) 2013 Alex Song 4 | * 5 | * This file is part of jOpenExchg. 6 | * 7 | * jOpenExchg is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * jOpenExchg is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | package org.jopenexchg.pool; 23 | 24 | public interface WithId 25 | { 26 | int getId(); 27 | 28 | void setId(int id); 29 | } 30 | -------------------------------------------------------------------------------- /src/org/jopenexchg/hldg/Hldg.java: -------------------------------------------------------------------------------- 1 | /* Java Open Exchange(jOpenExchg) Project 2 | * 3 | * Copyright (C) 2013 Alex Song 4 | * 5 | * This file is part of jOpenExchg. 6 | * 7 | * jOpenExchg is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * jOpenExchg is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | package org.jopenexchg.hldg; 23 | 24 | public final class Hldg 25 | { 26 | public HldgKey key = new HldgKey(); 27 | 28 | public long A = 0; 29 | public long B = 0; 30 | public long C = 0; 31 | public long D = 0; 32 | public long E = 0; 33 | 34 | public final void resetVal() 35 | { 36 | A = 0; 37 | B = 0; 38 | C = 0; 39 | D = 0; 40 | E = 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/event/EventHandler.java: -------------------------------------------------------------------------------- 1 | /* Java Open Exchange(jOpenExchg) Project 2 | * 3 | * Copyright (C) 2013 Alex Song 4 | * 5 | * This file is part of jOpenExchg. 6 | * 7 | * jOpenExchg is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * jOpenExchg is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | package org.jopenexchg.matcher.event; 23 | 24 | import org.jopenexchg.matcher.*; 25 | 26 | public interface EventHandler 27 | { 28 | public void incomingOrder(Order order); 29 | 30 | public void enterOrderBook(Order order); 31 | 32 | public void match(Order newOrder, Order oldOrder, long matchQty, long matchPrice); 33 | 34 | public void callAuctionMatch(Order buyOrder, Order sellOrder, long matchQty, long matchPrice); 35 | 36 | public void noMoreCallAuction(Order order); 37 | 38 | public void leaveOrderBook(Order order); 39 | 40 | public void noMoreMatch(Order order); 41 | } 42 | -------------------------------------------------------------------------------- /src/org/jopenexchg/matcher/event/impl/EventHandlerDebugImpl.java: -------------------------------------------------------------------------------- 1 | /* Java Open Exchange(jOpenExchg) Project 2 | * 3 | * Copyright (C) 2013 Alex Song 4 | * 5 | * This file is part of jOpenExchg. 6 | * 7 | * jOpenExchg is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * jOpenExchg is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | */ 22 | package org.jopenexchg.matcher.event.impl; 23 | 24 | import org.jopenexchg.matcher.Order; 25 | import org.jopenexchg.matcher.event.EventHandler; 26 | 27 | public final class EventHandlerDebugImpl implements EventHandler 28 | { 29 | 30 | @Override 31 | public void enterOrderBook(final Order order) 32 | { 33 | System.out.println(""); 34 | System.out.println("[enterOrderBook]"); 35 | System.out.println(" + " + order); 36 | } 37 | 38 | @Override 39 | public void leaveOrderBook(final Order order) 40 | { 41 | System.out.println(""); 42 | System.out.println("[leaveOrderBook]"); 43 | System.out.println(" - " + order); 44 | } 45 | 46 | @Override 47 | public void match(final Order newOrder, final Order oldOrder, long matchQty, long matchPrice) 48 | { 49 | System.out.println(""); 50 | System.out.println("[match]: matchPrice = " + matchPrice + " matchQty = " + matchQty); 51 | System.out.println(" new " + newOrder); 52 | System.out.println(" old " + oldOrder); 53 | } 54 | 55 | @Override 56 | public void noMoreMatch(final Order order) 57 | { 58 | System.out.println(""); 59 | System.out.println("[noMoreMatch]"); 60 | System.out.println(" + " + order); 61 | } 62 | 63 | 64 | @Override 65 | public void incomingOrder(final Order order) 66 | { 67 | System.out.println("------------------------"); 68 | System.out.println("[incomingOrder]"); 69 | System.out.println(" + " + order); 70 | } 71 | 72 | 73 | @Override 74 | public void callAuctionMatch(final Order buyOrder, final Order sellOrder, long matchQty, 75 | long matchPrice) 76 | { 77 | System.out.println(""); 78 | System.out.println("[ocall match]: matchPrice = " + matchPrice + " matchQty = " + matchQty); 79 | System.out.println(" buy " + buyOrder); 80 | System.out.println(" sell " + sellOrder); 81 | 82 | } 83 | 84 | 85 | @Override 86 | public void noMoreCallAuction(Order order) 87 | { 88 | // TODO Auto-generated method stub 89 | 90 | } 91 | 92 | } 93 | --------------------------------------------------------------------------------