ORDER MATCHING
The disclosure relates to an automated trading system, comprising an interface for receiving a plurality of orders comprising bid orders and ask orders and a trading module for matching the bid orders and the ask orders, the trading module comprising a memory for storing the plurality of orders, a subset sum module configured to find the subset sums of the bid orders and the subset sums of the ask orders of the plurality of orders, and an order matching module for matching a combination of bid orders to a combination of ask orders based on the subset sums for the bid orders and the subset sums of the ask orders.
The invention relates to a trading system for matching orders using a dynamic programming algorithm.
BACKGROUND OF THE INVENTIONAutomated trading systems receive bid orders and ask orders and match the bid orders and the ask orders to create trades. Depending on the conditions associated with the orders, the process of matching bid orders and ask orders can sometimes be complex.
An automated trading system may run call auctions, where the auction is held open to receive orders until a certain time and the orders are then matched after the auction has closed. Matching the orders often involves determining an equilibrium price for the orders and matching the orders willing to trade at the equilibrium price. It is desired to choose an equilibrium price that maximises the turnover
Some systems allow members to submit orders with minimum volume conditions. One type of minimum volume order condition is an All-or-None (AoN) order, meaning that either the bid is matched completely or the member does not want to trade. For example, if the order book of the trading system only comprises an AoN bid order of volume 4 and an AoN ask order of volume 6, a trade cannot be created. However, if the order book comprises two AoN bid orders of volume 4 and 5 respectively and two AoN ask orders of volume 3 and 6 respectively, the two bid orders can be combined and the two ask orders can be combined and all the orders can trade.
For a large number of orders, it can sometimes be difficult to find a combination of bid orders that match a combination of ask orders. In order to maximise the turnover, it is desired to find the largest common sum of the ask orders and the bid orders. In other words, given the set of ask orders Sa and the set of bid orders Sb, where Sa={a1, a2, . . . , an}, Sb={b1, b2, . . . , bm}, where ai and bi are a non-negative numbers, it is desired to find a subset
The problem is exasperated if members are allowed to submit more generalised minimum volume conditions. For example, a member may submit an order of a specific total volume accompanied with a condition specifying the minimum volume of the total volume that the member is willing to accept. For example, a member may submit a bid order of volume 100, with a minimum volume condition of 40. If the order book includes a matching ask order of volume 50, a trade is created for volume 50, because 50 is higher than the minimum volume condition of the bid order.
It is often desired to apply special rules to minimum volume condition orders. The rules may include rules that do not guarantee priority to minimum volume condition orders over orders with less generous prices. In more detail, for orders without volume conditions, a bid order with a high price must always be executed before a bid order with a lower price. Since the minimum volume conditions may prevent matching, this rule must be changed to allow for exceptions for minimum volume orders. Because of the larger number of different possible volumes, allowed by minimum volume condition orders, and the rules that need to be followed, minimum volume condition orders make it more complicated to match bid and ask orders.
Several trading systems offer matching of AoN orders and minimum volume conditions orders. However, the complexity of finding the optimal solution forces the systems to settle with a suboptimal solution, either by stopping the optimisation after a configurable number of steps or by implementing a “best effort” algorithm which does not guarantee the optimal solution but guarantees a result within a reasonable time.
Additionally, many of the known trading systems do not include orders with minimum volume conditions in the calculation of the equilibrium price. Instead, the equilibrium price is typically calculated from the set of orders without minimum volume conditions and the orders with minimum volume conditions are then matched with a best effort algorithm that takes the equilibrium price as input. The problem with this approach is that minimum volume conditions are usually applied to large orders. If the equilibrium price is only based on small orders, it does not reflect the true market situation.
Dynamic programming is a method of solving complex problems by breaking them down into simpler subproblems in a recursive manner. If a certain calculation is a sub-problem in a larger calculation, the result of the calculation can be stored and re-used in the larger calculation.
Dynamic programming on the word RAM by D. Pisinger, Algorithmica, 35:128-145, 2003, discloses a dynamic programming algorithm for solving a subset sum problem.
The invention was made in this context.
SUMMARY OF THE INVENTIONAccording to the invention, there is provided an automated trading system comprising an interface for receiving a plurality of orders comprising bid orders and ask orders; and a trading module for matching the bid orders and the ask orders, the trading module comprising a memory for storing the plurality of received orders; a subset sum module configured to find the subset sums of the bid orders and the subset sums of the ask orders; and an order matching module for matching a combination of bid orders with a combination of ask orders based on the subset sums of the bid orders and the subset sums of the ask orders, wherein the subset sum module is configured to find the subset sums of a set or orders by considering a first set of orders, determining the subset sums of the first set of orders, considering a second set of orders wherein the second set of orders comprises at least one more order than the first set of orders and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
The set of orders may comprise orders ai with minimum volume conditions c, and the subset sum module may be configured to determine a value gi,j indicating whether a set Si={a1, . . . ai} comprises a subset that sums to value j by noting that set Si={a1, . . . , ai} has a subset that sums to j, if Si−1 has a subset that sums to j or if Si−1 has a subset that sums to j-k, where ci≦k≦ai. The minimum volume condition orders can comprise one or more AoN orders, for which k=ai=ci.
The subset sum module may be arranged to construct a matrix in which every row correspond to a set of orders, Si,j, every column corresponds to a subset sum j and the element at a particular position i,j indicates whether the set Si has a subset summing to sum j and the subset sum module may be configured to populate a row by considering a set of orders comprising one more order than the set of orders corresponding to the previous row and using the value of the elements of the previous row.
If said one more order is an AoN order, the subset sum module may be configured to add a first copy of the previous row to the new row; and add a second copy of the previous row, shifted a number of columns corresponding to the volume of said one more order, to the new row.
If the one more order can be any minimum volume condition order, the subset sum module may be configured to add a first copy of the previous row to the new row; add a second copy of the previous row, shifted a number of columns corresponding to a possible volume of said one more order and spread to represent all the possible volumes of the order, to the new row.
The second copy may be shifted a number of columns corresponding to the minimum volume of said one more orders and the subset module may be configured to add the second copy, shifted said number of columns, to a temporary row; set element gi,j in the temporary row to indicate that j is a subset sum if gi,j−m of the second copy of the previous row, shifted said number of columns, indicates that j−m is a subset sum of the previous row, where m is an integer and 0<m≦ai−ci.
When all orders have been added and all rows have been populated, the final row in the matrix has elements set that indicate the volumes that can be attained in the complete set of orders. Consequently, the invention allows the subset sum problem to be solved comparatively fast. The heart of the algorithm and the reason for its speed can be considered to be that the algorithm works on the set of volume sums instead of on the set of element subsets. The algorithm can be considered to be a pseudo polynomial algorithm.
If gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, the subset sum module may be configured to populate the rows of the matrix by setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−j,j−a=1).
If gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, and the subset sum module may be configured to populate the rows of the matrix by setting g0,j=1 for j=0 and g0,j=0 for j>0 and use the recursion gi,j =1 iff (gi−1,j=1 or gi−1,j−k
The automated trading system may further comprise means for ordering the orders into a sequence with respect to price and the subset sum module may be configured to select said one more order as the next order in the sequence.
The trading module may further comprise means for finding the highest common sum of said subset sums for the bid orders and said subset sums for the set of ask orders and the order matching module may be configured to determine a combination of bid orders and a combination of ask orders that sum to the highest common sum.
Consequently, the invention allows the turnover to be maximised by fully solving the subset sum problems for the bid and ask orders.
The order matching module may further be configured to find, from the set of orders, a solution subset that sums to the highest common sum by
-
- a) setting parameter V equal to the highest common sum;
- b) finding the one more order added to form the set corresponding to the lowest row in the matrix with subset sum V,
- c) adding this order to the solution subset;
- d) determining the volume of said one more order that is allowed to trade and the volume Vnext that remains after said one more order is allowed to trade the determined volume;
- e) setting V=V−Vnext
- f) repeating steps b) to e) until V=0.
Consequently, the automated trading system makes sure that the same subset is always found given a matrix and a specific sum.
The trading module may be configured to determine the volume that is allowed to trade such that the volume that remains is maximised. To this end, the trading module may select the smallest volume possible for the order to trade while still ensuring that the combination of volumes that are allowed to trade sums to the highest common sum. Consequently, the volume that remains for orders with higher priority is maximised. To find the smallest possible volume of the order ai that is allowed to trade, the trading module may determine the volume vmax of the full order ai, the volume vmin of the minimum volume condition ci, and the difference vslack between vmax and vmin. The trading module then examines the columns in the interval [v−(vmin+vslack), v−vmin] on the row immediately above the current row and selects the highest subset sum Vnext in these columns.
The automated trading system may further comprise an equilibrium price calculation module configured to determine the turnover at each possible price based on the subset sum matrix.
The interface may be configured to receive the plurality of orders from a plurality of member terminals, the order matching module may be configured to create trades between said combination of bid orders and said combination of ask orders; and the interface may further be configured to communicate information about the matched orders that are allowed to trade to said member terminals.
According to the invention, there is also provided a method for matching orders in an automated trading system comprising: receiving a plurality of orders in an automated trading system, the plurality of orders comprising bid orders and ask orders; storing the plurality of orders submitted to the system in an order book; determining the subset sums of a set of orders corresponding to the bid orders and determining the subset sums of a set of orders corresponding to the ask orders; and matching a combination of bid orders with a combination of ask orders based on the determined subset sums for the bid orders and the subset sums for the ask orders, wherein determining the subset sums of a set of orders comprises determining the subset sums of a first set of orders, considering a second set of orders wherein the second set of orders comprises at least one more orders than the first set of orders, and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
The set of orders may comprise orders ai with a minimum volume conditions ci, and determining the subset sum of a set of orders may comprise determining a value gi,j indicating whether a set Si{a1, . . . , ai} comprises a subset that sums to value j by noting that set Si{a1, . . . , ai} has a subset that sums to j, if S1−1 has a subset that sums to j or if Si−1 has a subset that sums to j−k, where ci≦k≦ai. The minimum volume conditions orders may comprise at least one All-or-None (AoN) order, wherein k=ai=ci.
Determining the subset sum of a set of orders may comprise constructing a matrix in which every row correspond to a set of orders, Si,j every column corresponds to a subset sum j and the element at a particular position i,j indicates whether the set Si has a subset summing to value j, and populating a new row by considering a set of orders comprising one more order than the set of orders corresponding to the previous row and using the values of the elements of the previous row.
If said one more order is an AoN order, populating said new row may comprises adding a first copy of the previous row to said new row, adding a second copy of the previous row, shifted a number of columns corresponding to the volume of said one more order, to the new row.
When the one more order can be any minimum volume condition order, populating said new row may comprise adding a first copy of the previous row to said new row, adding a second copy of the previous row, shifted a number of columns corresponding to a possible volume of said one more order and smeared to represent all the possible volumes of the order, to the new row.
The second copy may be shifted a number of columns corresponding to the minimum volume of said one more order and populating said row may further comprise adding the second copy, shifted said number of columns, to a temporary row; setting element gi,j in the temporary row to indicate that j is a subset sum if gi,j−m of the second copy of the previous row, shifted said number of columns, indicates that j-m is a subset sum of the previous row, where m is an integer and 0<m≦ai−ci.
Populating said row may comprise setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or g i−1,j−a
Populating said row may comprise setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−1,j−k
The method may further comprise ordering the orders in terms of price into a sequence and selecting said one more order as the next order in the sequence.
Matching a combination of bid orders with a combination of ask orders may comprise determining the highest common sum of said subset sums for the bid orders and said subset sums for the ask orders.
Matching a combination of bid orders with a combination of ask orders may further comprise determining, from the set of orders, the solution subset that sums to the highest common sum by
-
- a) setting parameter V equal to the highest common sum;
- b) finding the one more order added to form the set corresponding to the lowest row in the matrix with subset sum v,
- c) adding this order to the solution subset;
- d) determining the volume of said one more order that is allowed to trade and the volume Vnext that remains after said one more order is allowed to trade the determined volume;
- e) setting V=V−Vnext
- f) repeating steps b) to e) until V=0.
The trading module may be configured to determine the volume that is allowed to trade such that the volume that remains is maximised.
The method may further comprise determining the turnover at each equilibrium price of a set of orders based on the constructed matrix.
In some embodiments, receiving a plurality of orders may comprise receiving a plurality of orders from a plurality of member terminals, the method may further comprise creating trades between the combination of ask orders and the combination of bid orders and communicating information about the matched orders that are allowed to trade to said member terminals.
According to the invention, there is also provided a computer program comprising instructions that when executed by a processor arrangement cause the processor arrangement to carry out the above method.
Embodiments of the invention will now be described, by way of example, with reference to the accompanying drawings, in which:
With reference to
The market members may submit the orders using a number of member terminals 9 and the interface 2 may receive the orders from the member terminals 9. The orders may be received from the member terminals via a communication network. The member terminals may for example be desktop computers but any suitable device is contemplated. Information indicating that submitted orders have been matched may be sent over the communication network to the member terminals 9 and displayed on the member terminals. The automated trading system 1 may further pass on information about the matched orders to a clearing system to allow trades resulting from the matched orders to be cleared and settled.
According to some embodiments, the trading system allows the market members to trade using a call auction. With reference to
It is known how to receive and store orders and the pre-call phase will therefore not be described in detail herein. The auction phase will be described below.
With reference to
As shown in
To find the highest common sum of the bid orders and the ask orders, two subset sum problems have to be solved. According to the invention, a dynamic programming algorithm, in which the problem is broken down into smaller problem, is used to reduce the complexity of the calculations.
Starting with the bid orders, a table is constructed for determining the subset sums as shown in
To construct the table, the full set of orders Sb{0, 3, 2, 7} where a0=0, a1=3, a2=2 and a3=7 is considered. The first set corresponding to the first row is selected as the empty set, with i=0. This set, S0={a0}, only comprises a0=0. The only sum for this set is therefore 0, as shown in
The third set is created by adding another element, a2=2, to the set. The third set is therefore S2={0, 3, 2}. The third row of the matrix is constructed by again copying the previous row, the second row, and adding a copy of the previous row shifted a number of columns equal to the value of the order added to the set. As a result, the third row shows all the sums of all the subsets of the set {0, 3, 2}, namely 0, 2, 3 and 5.
Finally, the fourth set is created by adding the last element, a3=7, to the set to form the full set S3={0, 3, 2, 7} and the fourth row is created by copying the third row and adding another copy of the third row, shifted seven positions. The fourth row shows the sum of all the subsets of the full set {0, 3, 2, 7}, namely, 0, 2, 3, 5, 7, 9, 10 and 12.
Using a more mathematical notation, it can be seen from
If gi,j denotes whether a set Si has a subset that sums to j and gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, the solution of gi,j is found by noting the initial state g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion
gi,j=1 iff (gi−1,j=1 or gi−1,j−a
Using this notation, the table of
A similar table to the one shown in
It is seen, from a quick comparison of the two matrices or the two tables, that the highest common subset sum is 9. The sum 9 is made up from bid orders 2 and 7 and ask orders 3 and 6. Consequently, bid orders 2 and 7 will trade with ask orders 3 and 6 and bid order 3 and ask order 5 will be left in the order book 6. Of course, the subset sums can quickly be found for a set of three orders. However, with a large number of orders, the problem gets more and more complex.
The system can also handle orders comprising some AoN order and some orders without minimum volume conditions. Orders without volume conditions are not handled directly in the matrix but are treated as offsets to the column numbers. Consequently, if the order book 6 also comprised a number of bid orders without minimum volume conditions with a total volume of 10, an offset of 10 is added to the subset sums and the sums of the last row in a matrix or a table for the orders of
Of course, in a more realistic situation, the bid orders and the ask orders will include orders at different prices. Using the same values for the volumes of the orders as in the previous examples,
The process needed for calculating the equilibrium price for a plurality of AoN orders with different prices, matching the orders and creating the trades will be described with respect to
It is desired to set the select the price that provides the highest turnover as the equilibrium price. A table is therefore constructed where every row represents a possible equilibrium price, as shown in
From the table in
The re-calculated tables created when the orders are ordered according to price are shows in
The first step in the process for calculating the equilibrium price and matching the orders involve ordering a set of orders according to price, step S1 of
The equilibrium price module then calculates the equilibrium price, step S3, by collating all the orders willing to trade at each possible prices and calculating the turnover and the imbalance at each possible prices. For calculating the turnover, the equilibrium calculation module makes a call to the common sum determination module 15. The equilibrium calculation module specifies the sets of orders between which the highest common sum need be found and the common sum determination unit determines the corresponding rows in the matrices and determines the highest common sum and returns this to the equilibrium calculation module. Once the equilibrium price has been calculated, the equilibrium price is stored and used by the order matching module 13 as an input for calculating matching orders and creating trades. The order matching module 13 makes a call to the common sum determination module to determine the highest common subset sum of the bid order and the ask orders, step S4. The common sum determination module performs this step by finding the highest common sum in the last row of the matrices. The order matching module then identifies the subsets for which the highest common sum is the sum, step S5, and creates the trades between the orders of the sets at step S6. If the order book includes a large number of trades, several order sets may sum to the highest common sum. A method for finding a subset that sums to a particular sum, according to some embodiments of the invention, will be described below with respect to
The calculation of the subset sum matrix, step S2 of
It is clear from the matrices that the last line of each matrix is still the same as in the corresponding matrix calculated without ordering the orders according to price. However, it is also clear that the other rows are different. For example, row 3 of matrix 3 now provides a solution to the subset sum problem for the bid order set {2, 7} needed to calculate the turnover at prices 10200p and 10100p and row 3 of matrix 4 provides a solution to the subset sum problem for ask order set {5, 6} needed to calculate the turnover at price 9800p.
As described with respect to
The turnover and the imbalance for the sets are then determined at step S303. This may be performed by the equilibrium price calculation module 12 forwarding information about the sets willing to trade at each price to the common sum determination module 15, and the common sum determination module 15 extracting the values of the rows corresponding to the specified sets from the two subset sum matrices, finding the highest common sum and returning this value to the equilibrium price calculation module 12. In more detail, to calculate the turnover at price 10200p, the highest common sum of the bid order set {0, 2} and the full ask order need to be determined. The common sum determination module 15 may receive sets {0, 2} and {6, 5, 3} as input from the equilibrium price calculation module 12 and, in response, analyse the first row of the subset sum matrix for the bid orders and the last row for the subset sum matrix for the ask orders to determine that the only common sum is 0. To calculate the turnover at price 10200p, the equilibrium price calculation module 12 specifies sets {0, 2, 7} and {6, 5, 3} to the function provided by the common sum determination module 15 and the common sum determination module 15 accesses the matrices and determines the highest common sum between the third row of the bid matrix, representing set {2, 7} and the last row of the ask matrix, representing the full set. It is realised that the highest common sum is 9 and that this would therefore be the turnover at price 10200p. This is also true at price 10100p. At price 10000p, all the bid orders would accept the price and so the last row of the bid matrix is compared to the last row of the ask matrix. The turnover is still 9. The same is true at price 9900p. At price 9800p, all the bid orders would accept the price, but only ask orders 5@9800, and 6@9700p would accept the price. To find the highest common sum for these orders, the last line of the bid matrix is compared to the third row of the ask matrix and it is realised that the highest sum is 6. All the rows of the turnover column of
The imbalance is then calculated based on the turnover. The imbalance can be calculated in different ways. The imbalance is typically calculated as the difference in volume between the bid orders and the ask orders without volume conditions that remain after the orders have been matched. In other words, the imbalance is the volume of orders without volume conditions that are not allowed to trade. Since it is difficult to define the imbalance for minimum volume condition orders, such as AoN orders, orders comprising minimum volume condition orders are not included in the final value of the imbalance, according to some implementations. However, if some of the orders with minimum volume conditions are allowed to trade, the orders indirectly affect the imbalance since it reduces the remaining volume of orders on the other side. Since all the orders described with respect to
The process then proceeds to step S304 and the equilibrium price calculation module determines the rows with the highest turnover. If the highest turnover can only be achieved at one price, this price is set as the equilibrium price at step S305. However, if the highest turnover can be achieved at more than one price, the process proceeds to step S306 and the rows with the highest turnover are noted. In
The rows are first analysed to find the lowest absolute value of imbalance. At step S307, it is determined if one row has a lower absolute value of imbalance than the other rows. If one of the rows has a lower absolute value of imbalance, the process proceeds to step S305 and the price of the row having the absolute value of imbalance is set as the equilibrium price. However, if more than one of the rows with the highest turnover have the lowest absolute value of imbalance at step S307, the rows with the same low absolute value of imbalance are noted at step S308. In
At step S309, it is checked if all the rows with the same low absolute value of imbalance have a positive imbalance. If all the rows have a positive imbalance, the row with the highest price is determined at step S310 and the price of this row is set to the equilibrium price at step S305. If, instead, all the rows do not have a positive imbalance, it is checked if all the rows have a negative imbalance at step S311. If all the rows have a negative imbalance, the row with the lowest price is determined at step S312 and the price of this row is set as the equilibrium price at step S305. A row would have a positive imbalance if the volume of bid orders without minimum volume conditions exceeds the volume of ask orders without minimum volume conditions and as a result, not all of the bid orders without minimum volume conditions are met. A row would have a negative imbalance if the volume of ask orders without minimum volume conditions exceeds the volume of bid orders without minimum volume conditions and as a result, one or more ask orders without minimum volume conditions is left in the order book 6 after the auction phase. If all the rows do not have a positive imbalance, step S309, or a negative imbalance, step S311, it is checked whether all the rows have a zero imbalance at step S313. If they do, the row with the midpoint price is determined at step S314 and the equilibrium price is set to the price of this row at step S305. In
The process for determining the equilibrium price, described with respect to
It is clear from the table of
Some trading systems allow all types of minimum volume condition orders and not just AoN orders to be submitted to call auctions. With reference to
The orders are first ordered according to price. The orders at the same prices may be ordered according to the time they were received. Subsequently, as shown in
The second set comprises orders {0, 6(4)} where ai(ci) denotes an order of volume ai willing to trade with a minimum volume of ci. Since the order a1(c1)=6(4) would be willing to trade a volume of 4, a volume of 5 and a volume of 6, the subset sums for this case comprise the subset sums of the previous set, the subset set sums created by adding 4 to the previous sums, by adding 5 to the previous sums and by adding 6 to the previous sums. According to some embodiments, the second row is therefore constructed by adding a copy of the previous row plus a copy of the previous row in which the subset sums are shifted a number of columns equal to the minimum volume that can be traded of the order and then smeared a number of positions corresponding to all the volumes between the minimum volume and the full volume.
The third set is created by adding another element, a2=5, to the set, forming set {0, 6(4), 5)}. The third row of the matrix is constructed by again copying the previous row, the second row, and adding a copy of the previous row shifted a number of columns equal to the value of the AoN order added to the set.
Finally, the fourth set is created by adding the last order for volume 15 with minimum volume condition 10 to the set. The fourth row is populated by copying the third row and adding a copy of the third row, shifted a number of positions equal to the minimum volume 10 and smeared a number of positions to cover all the possible volumes between the minimum volume and the full volume 15. Using a more mathematical notation, when an order ai has a minimum volume conditions ci, a set Si=}a1(c1), . . . , ai(ci)} has a subset that sums to j, if Si−1 has a subset that sums to j or if Si−1 has a subset that sums to j−k, for all k where ci≦k≦ai.
If denotes whether a set Si has a subset that sums to j and gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, the solution of gi,j is found by noting the initial state g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion
iff (gi,j−1 iff (gi−1,j−1 or gi−1,j−k
The table of
The process of constructing the subset sum matrix, step S2 of
The subset sum module 14 first arranges the set of orders in an array, step S2001, with the first element corresponding to an order of volume 0. The subset sum module then creates a matrix, where each row represents a set of orders and each column represents a sum of a subset of the set of orders. It further sets the parameter i, representing an order in the array, to 0, step S2002. The first row of the matrix is then populated, step S2003, by creating a first set S0 with the first order in the array, a0 and populating the first row by setting the first element to 1 and all the other elements to zero to show that the only subset sum of the empty set is zero.
The parameter representing an order in the array, i, is then increased by 1 at step S2004. A new row is created at step S2005 and a new set corresponding to the row is created by adding the order identified by the value of parameter i to the set. The new row is then populated by performing a number of copying steps. Firstly, the previous row is copied to the new row at step S2006. Secondly, a temporary row is created, the volume vmin of the minimum volume condition ci of the order is determined at step S2007 and another copy of the previous row, shifted a number of positions equal to the value of vmin, is added to a temporary row at step S2008. The values of the temporary row then have to be adjusted to take into account all the possible values that can trade between the minimum volume ci and the full order of ai. To this end, the subset sum values of the temporary row are smeared or spread a number of columns corresponding to the possible volumes of the order. This is done by determining the difference vslack between the full volume ai and ci at step S2009. A parameter m, representing the possible values added to the minimum volume condition to form the full volume is set to 1 at this stage. The subset sums j in the temporary row are found in step S2010 and the subset sums j+m are set at step S2011. Since m=1 to start with, this means that the subset sums corresponding to the minimum volume condition plus volume 1 is set at this step. It is then checked at step S2012 if m is smaller than vslack and if it is, m is increased by 1 at step S2013 and step S2011 is repeated. Consequently, the subset sums are spread another step corresponding to the volume created by adding another volume of 1 to the subset sums already in the temporary row. Steps S2011 to S2013 are repeated until m=vslack and the subset sums in the temporary row represent the subset sums that could be obtained by adding every possible volume of the order with the minimum volume condition to the previous row. The temporary row is then added to the new row at step S2014 with a logical OR operation.
The process then proceeds to step S2015 and it is checked whether all rows of the matrix have been populated. In other words, it is checked if all the orders in the array have been considered, in which case the parameter i equals n. If all orders have not been considered, steps S2004 to S2015 are repeated for the next set of orders created by adding the next order in the array to the current set of orders. When it is determined at step S2015 that the current set comprises all orders in the array, the process moves on to step S2016 and the matrix is stored in memory 16.
It should be realised that the process of
Moreover, it should be realised that the second copy may not have to be shifted a number of positions corresponding to the volume of ci, the second copy can be shifted a number of positions corresponding to any possible volume of the order and then bits can be spread in one or both directions as required.
In one embodiment, the subset sum module 14 may use different algorithms for different orders. For example, every time an order is added to a set, it may be determined if the order is an AoN order or a minimum volume condition order. If the order is an AoN order, the module may carry out steps S203 to S207 of
It is contemplated that instead of smearing the subset sums in the temporary row, a new temporary row can be created for each possible volume that is allowed to trade of the volume with the minimum volume condition. All the temporary rows can then be added to the new row with a simple OR operation. Alternatively, the matrix does not have to be obtained by copying. The value of gi,j can also be calculated using the recursions of equation 1 or 2 for each position in the matrix. However, copying the rows and may allow the matrices to be created in a shorter time since fewer operations may have to be performed.
The method of determining the set of orders corresponding to a particular subset sum in the matrix for any type of minimum volume condition orders will now be described with respect to
The system does not know at this point how much of that order is allowed to trade. This is determined at step S504. At step S504, the order matching module 13 determines the maximum volume vmax of the order that can trade, namely the full volume of ai, and the minimum volume vmin of the order that can trade, namely the volume of the minimum volume condition ci. The order matching module 13 then analyses at step S505 the columns in the previous row corresponding to sums in the interval V−vmax to V−vmin and determines the highest sum in the interval. The order matching module may determine the highest sum in the interval in the previous row by simply selecting the highest column number in the interval where a bit is set. This column number represents the volume that is left after the order has been allowed to trade some of its volume. The order matching module 13 may store this column number as Vnext. Another way of expressing the interval analysed to find the highest common sum is [V−(vmin+vslack), V−vmin], where vslack is the difference between the full volume vmax and the minimum volume vmin. At step S506 the order matching module 13 determines that the order is allowed to trade V−Vnext of its volume. Using the example above, the columns corresponding to the sums in the interval 20−15=5 to 20−10=10 are analysed and the highest sum in those columns in the previous row is 10. Vnext is therefore set to 10 and the volume of the order that is allowed to trade is 20−10=10. At step S507 it is determined if Vnext is zero. If not, V is set to Vnext at step S508 and steps S502 to S507 are repeated.
Continuing with the example, V is set to Vnext=10 and it is determined at step S502 that the third row is the lowest row where 10 is a subset sum and the order corresponding to this row, order 5, is added to the solution set at step S503. Since order 5 is an AoN order, the interval to analyse in the row immediately above at step S504 only comprises one value, namely 10−5=5. Vnext is therefore set to 5 and it is determined that AoN order gets to trade volume 10−5=5 at step S505. Since V., is still not zero, V is set to 5 and the process is repeated. It is found that the second row is the lowest row with a subset sum volume of 5 and the order 6(4) corresponding to this row is added to the solution set. The columns in interval 5−6=−1 and 5−4=1 are then analysed in the row immediately above and it is found that the only subset sum in this interval is the subset sum of 0. Vnext is set to 0 and the volume that is allowed to trade of order 6(4) is calculated as 5−0=0. It is then realised at step S507 that Vnext is 0 and the solution set is stored at step S509. In this case, the solution set comprises orders 15(10) allowed to trade volume 10, AoN order 5 allowed to completely trade and order 6(4) allowed to trade 5.
The process for finding the subset corresponding to the common subset sum has only been described above for one matrix. It should be realised that the subset corresponding to the subset sum in the other matrix would also need to be found using the same process.
It should also be realised that the process described with respect to
The method described with respect to
The handling of orders with general volume condition is applicable for orders with no volume conditions as well, since an order without a volume condition has an implicit minimum volume of 1. However, as mentioned above, for performance reasons, orders without volume conditions are not handled directly in the subset sum matrix, but are treated as offsets to the column numbers. Moreover, trading exchanges typically apply rules to the orders that give priority to orders without volume conditions if the orders are at the same price. Exchanges typically want to reward users that enter orders without conditions. Therefore, if an order set contains a number of volume condition orders and additionally some orders without volume conditions with aggregated volume 100, this is handled by adding an offset of 100 to all column numbers in the volume condition order matrix. Suppose that the matrix final row contains bit set in columns 0, 20, 30 and 40. The offset 100 is added and the result is that possible volumes are 0, 100, 120, 130 and 140. This is different from the copy-shift operation used to construct the matrix as described with respect to, for example,
According to some embodiments, the matrix can be stored by dividing a row in the matrix into blocks of equal size and storing the blocks in tree structures. The block size is configurable, but in one embodiment must be a multiple of a specific number of bits, for example 64 bits. In one implementation, every row is associated with a tree structure where blocks which contains at least one bit are stored. Blocks that do not have any set bits are not stored. This makes storage of sparse rows (i.e. rows with few bits set) effective. To improve the performance of dense row (i.e. rows with many bits set) storage, the tree structure does not keep block objects directly. Instead, it contains an object which can represent either one block where at least one bit is set, or several consecutive blocks where all bits are set. If the object represents one block with at least one bit set, the object may contain a bit array composed of a number of 64-bit integers where the corresponding bits are set together with an integer which represents the block number. If the object represents a consecutive number of blocks where all bits are set, the object only contains the start block number and the end block number. The objects are stored in a tree according to their start block number. A matrix consists of a number of such trees, one for every row.
The new rows can then be obtained by copying the blocks corresponding to the previous row into a new set of blocks. Creating a temporary set of blocks, copying the previous blocks into the temporary set of blocks and smearing the sums if required and then adding the bits of the temporary set of blocks to the new blocks with a logical OR operation.
Whilst specific examples of the invention have been described, the scope of the invention is defined by the appended claims and not limited to the examples. The invention could therefore be implemented in other ways, as would be appreciated by those skilled in the art. For example, it should be realised that the invention can also be used for a continuous system. The order matching module may receive a new bid or ask order and may determine whether a matching ask or bid resting order exist in the system. If a matching resting order exists, a trade is created.
Moreover, it should be realised that the arrangement of modules shown in
Additionally, it should be realised that the orders may not necessarily be received from a number of member terminals over a network. Orders may also be entered into the trading system, for example by officials associated with the trading system, using terminals connected to the trading system or directly via a user interface of the trading system.
Claims
1. An automated trading system, comprising:
- an interface for receiving a plurality of orders comprising bid orders and ask orders; and
- a trading module for matching the bid orders and the ask orders, the trading module comprising: a memory for storing the plurality of orders; a subset sum module configured to find the subset sums of the bid orders and the subset sums of the ask orders of the plurality of orders; and an order matching module for matching a combination of bid orders to a combination of ask orders based on the subset sums for the bid orders and the subset sums of the ask orders,
- wherein the subset sum module is configured to find the subset sums of a set of orders by considering a first set of orders of the set of orders, determining the subset sums of the first set of orders, considering a second set of orders of the orders wherein the second set of orders comprises at least one more order than the first set of orders and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
2. An automated trading system according to claim 1, wherein the set of orders comprise orders ai with minimum volume conditions ci, and wherein the subset sum module is configured to determine a value gi,j indicating whether a set Si={a1,..., ai} comprises a subset that sums to value j by noting that set Si={a1,... ai} has a subset that sums to j, if Si−1 has a subset that sums to j or if Si−1 has a subset that sums to j-k, where ci≦k≦ai.
3. An automated trading system according to claim 2, wherein the minimum volume condition orders comprise at least one All-or-None order, wherein k=ai=ci.
4. An automated trading system according to claim 2, wherein subset sum module is arranged to construct a matrix in which every row correspond to a set of orders, Si,j, every column corresponds to a subset sum j and the element gi,j at a particular position i,j indicates whether the set Si has a subset summing to sum j and the subset sum module is configured to populate a row by considering a set of orders comprising one more order than the set of orders corresponding to the previous row and using the value of the elements of the previous row.
5. An automated trading system according to claim 4, wherein said one more order is an AoN order and the subset sum module is configured to:
- add a first copy of the previous row to the new row; and
- add a second copy of the previous row, shifted a number of columns corresponding to the volume of said one more order, to the new row.
6. An automated trading system according to claim 4, wherein said one more order is any minimum volume condition order, and the subset sum module is configured to:
- add a first copy of the previous row to the new row; and
- add a second copy of the previous row, shifted a number of columns corresponding to a possible volume of said one more order and spread to represent all the possible volumes of the order, to the new row.
7. An automated trading system according to claim 6, wherein the second copy is shifted a number of columns corresponding to the minimum volume of said one more orders and the subset module is configured to:
- add the second copy, shifted said number of columns, to a temporary row; and
- set element gi,j in the temporary row to indicate that j is a subset sum if gi,j−m of the second copy of the previous row, shifted said number of columns, indicates that j-m is a subset sum of the previous row, where m is an integer 0<m≦ai−ci.
8. An automated trading system according to claims 4, wherein gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, and the subset sum module is configured to populate the rows of the matrix by setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−i,j−ai=1).
9. An automated trading system according to claim 4, wherein gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, and the subset sum module is configured to populate the rows of the matrix by setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−1,j−ki=1) where ci≦k≦ai.
10. An automated trading system according to claim 4, further comprising means for ordering the set orders into a sequence with respect to price and wherein the subset sum module is configured to select said one more order as the next order in the sequence.
11. An automated trading according to claim 4, wherein
- the trading module further comprises means for finding the highest common sum of said subset sums for the bid orders and said subset sums for the ask orders and the order matching module is configured to determine a combination of bid orders and a combination of ask orders that sum to the highest common sum.
12. An automated trading system according to claim 11, wherein the order matching module is configured to find, from the set of orders, a solution subset that sums to the highest common sum by
- a) setting parameter V equal to the highest common sum;
- b) finding the one more order added to form the set corresponding to the lowest row in the matrix with subset sum V;
- c) adding this order to the solution subset;
- d) determining the volume of said one more order that is allowed to trade and the volume Vnext that remains after said one more order is allowed to trade the determined volume;
- e) setting V=V−Vnext; and
- f) repeating steps b) to e) until V=0.
13. An automated trading system according to claims 4, further comprising an equilibrium price calculation module configured to determine the turnover at each possible price based on said matrix.
14. An automated trading system according to claim 1, wherein the interface is configured to receive the plurality of orders from a plurality of user terminals, the order matching module is configured to create trades between said combination of bid orders and said combination of ask orders; and the interface is further configured to communicate information about the matched orders that are allowed to trade to said user terminals.
15. A method for matching orders in an automated trading system comprising:
- receiving a plurality of orders in an automated trading system, the plurality of orders comprising bid orders and ask orders;
- storing the plurality of orders submitted to the system in an order book;
- determining the subset sums of a set or orders corresponding to the bid orders and determining the subset sums of a set or orders corresponding to the ask orders; and
- matching a combination of bid orders to a combination of ask orders based on the subset sums for the bid orders and the subset sums for the ask orders,
- wherein determining the subset sums of a set of orders comprises: considering a first set of orders, determining the subset sums of the first set of orders, considering a second set of orders wherein the second set of orders comprises at least one more orders than the first set of orders, and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
16. A method according to claim 15, wherein the set of orders comprise orders ai with minimum volume conditions ci, and the wherein determining the subset sum of a set of orders comprises determining a value gi,j indicating whether a set Si={a1,... ai} comprises a subset that sums to value j by noting that set Si={a1,... ai} has a subset that sums to j, if Si−1 has a subset that sums to j or if Si−1 has a subset that sums to j−k, where ci≦k≦ai.
17. A method according to claim 16, wherein the minimum volume condition orders comprise at least one All-or-None (AoN) order, wherein k=ai=ci.
18. A method according to claim 16, wherein determining the subset sum of a set of orders comprises:
- constructing a matrix in which every row correspond to a set of orders, Si,j every column corresponds to a subset sum j and the element gi,j at a particular position i,j indicates whether the set Si has a subset summing to value j, and
- populating a new row by considering a set of orders comprising one more order than the set of orders corresponding to the previous row and using the values of the elements of the previous row.
19. A method according to claim 18, wherein said one more order added is an AoN order, and populating said new row comprises:
- adding a first copy of the previous row to said new row, and
- adding a second copy of the previous row, shifted a number of columns corresponding to the volume of said one more order, to the new row.
20. A method according to claim 19, wherein the one more order is any minimum volume condition order, and populating said new row comprises:
- adding a first copy of the previous row to said new row, and
- adding a second copy of the previous row, shifted a number of columns corresponding to a possible volume of said one more order and smeared to represent all the possible volumes of the order, to the new row.
21. A method according to claim 20, wherein the second copy is shifted a number of columns corresponding to the minimum volume of said one more order and populating said row further comprises:
- adding the second copy, shifted said number of columns, to a temporary row; and
- setting element gi,j in the temporary row to indicate that j is a subset sum if gi,j−m of the second copy of the previous row, shifted said number of columns, indicates that j-m is a subset sum of the previous row, where m is an integer 0<m≦ai−ci.
22. A method according to claim 18, wherein gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, and the populating said row comprises setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−1,j−a=1).
23. A method according to claim 18, wherein gi,j=1 indicates that the set Si has a subset that sums to j and gi,j=0 indicates that the set Si does not have a subset that sums to j, and populating said row comprises setting g0,j=1 for j=0 and g0,j=0 for j>0 and using the recursion gi,j=1 iff (gi−1,j=1 or gi−1,j−ki=1) where ci≦k≦ai.
24. A method according to claim 18, wherein the method further comprises ordering the orders in terms of price into a sequence and selecting said one more order as the next order in the sequence.
25. A method according to claim 18, wherein matching a combination of bid orders to a combination of ask orders comprises determining the highest common sum of said subset sums for the bid orders and said subset sums for the ask orders.
26. A method according to claim 25 wherein matching a combination of bid orders to a combination of ask orders further comprises determining, from the set of orders, a solution subset that sums to the highest common sum by:
- a) setting parameter V equal to the highest common sum;
- b) finding the one more order added to form the set corresponding to the lowest row in the matrix with subset sum VII;
- c) adding this order to the solution subset;
- d) determining the volume of said one more order that is allowed to trade and the volume Vnext that remains after said one more order is allowed to trade the determined volume;
- e) setting V=V−Vnext; and
- f) repeating steps b) to e) until V=0.
27. A method according to claim 18, further comprising:
- determining the turnover at each equilibrium price of a set of orders based on the constructed matrix.
28. A method according to claim 18, wherein receiving a plurality of orders comprises receiving a plurality of orders from a plurality of member terminals, the method further comprises creating trades between the combination of ask orders and the combination of bid orders and communicating information about the matched orders that are allowed to trade to said member terminals.
29. (canceled)
30. An automated trading system, comprising:
- a trading module for matching orders, the trading module comprising a memory storing a plurality of orders submitted to the system and a subset sum module configured to find the subset sums of a set of orders of the plurality of orders by considering a first set of orders of the set of orders, determining the subset sums of the first set of orders, considering a second set of orders of the orders wherein the second set of orders comprises at least one more order than the first set of orders and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
31. A method for matching orders in an automated trading system comprising:
- storing an order book comprising a plurality of orders submitted to the system;
- determining the subset sums of a set of orders of the plurality of orders by: considering a first set of orders of the set of orders, determining the subset sums of the first set of orders, considering a second set of orders wherein the second set of orders comprises at least one more orders than the first set of orders, and determining the subset sums of the second set of orders by using the determined subset sums of the first set of orders.
Type: Application
Filed: Jan 4, 2011
Publication Date: Jan 17, 2013
Inventor: Hannes Jörgen Edvardson (Uppsala)
Application Number: 13/520,362
International Classification: G06Q 40/04 (20120101);