This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2021-109354, filed on Jun. 30, 2021, the entire contents of which are incorporated herein by reference.
The embodiments discussed herein are related to a non-transitory computer-readable recording medium storing a contract program, a contract method, and an information processing apparatus.
In a securities market, establishment of trading such as stock trading is called a “contract”. For example, a state in which conditions of a user who makes a sell order and a user who makes a buy order are matched and trading is established is referred to as a contract. In a case where a user makes an order (a sell order or a buy order), the user may make the order under a condition that a contract of a total amount is made or a contract of a certain order count is made.
Japanese Laid-open Patent Publication No. 2004-213546, and Japanese Laid-open Patent Publication No. 2001-306821 are disclosed as related art.
Meanwhile, in the related art described above, since order statuses of the sell order and the buy order of contract targets are separately handled, there is a problem that a large calculation cost is desirable for matching the contracts.
According to one aspect, an object is to provide a non-transitory computer-readable recording medium storing a contract program, a contract method, and an information processing apparatus capable of reducing a calculation cost when obtaining a contract of trading.
According to an aspect of the embodiments, a non-transitory computer-readable recording medium stores a contract program causing a computer to execute a process including: setting, for each of a sell order and a buy order having a condition that a contract count is designated, a first polynomial having a contract count designated under the condition of one order of the sell order and the buy order as a positive exponent, and a second polynomial having a contract count designated under the condition of the other order of the sell order and the buy order as a negative exponent; representing an order status in which the sell order and the buy order are combined, with one polynomial on a finite field by a product of the first polynomial and the second polynomial; and specifying a sell order and a buy order for making a contract based on the one polynomial on the finite field representing the order status.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention.
A minimum limit contract count, which is a condition set for an order, is referred to as a “minimum contract count”. For example, in a case where there is a sell order having an order count “N” with a condition of a minimum contract count “M”, and there is a buy order having an order count equal to or greater than the order count “M”, trading is established. There is a related art for obtaining a contract by matching such a sell order and a buy order.
Hereinafter, a non-transitory computer-readable recording medium storing a contract program, a contract method, and an information processing apparatus according to embodiments will be described below with reference to the drawings. In the embodiments, components having the same functions will be denoted by the same reference signs, and redundant description thereof will be omitted. The non-transitory computer-readable recording medium storing the contract program, the contract method, and the information processing apparatus to be described in the embodiments below are merely examples, and are not intended to limit the embodiment. Each embodiment below may be appropriately combined to the degree with which no inconsistency is caused.
First, a process of obtaining a contract by matching a sell order and a buy order with which the minimum contract count is set by dynamic programming will be described. In a process of specifying an order as a contract target by using dynamic programming, a Bool (T, F) array a is prepared for managing each of the sell order and the buy order, and an order as a contract target that maximizes a contract count is specified.
The Bool (T, F) array a is referred to as an “array a”. An index i equal to or greater than 0 is set for the array a, and “T” or “F” is set for an element corresponding to the index i of the array a. A case where the element corresponding to the index i in the array a is “T” means that there is an order of an order count i. A case where the element corresponding to the index i in the array a is “F” means that there is no order of the order count i. “T” is an example of a registration symbol.
The case where the element of the index i in the array a is “T” is indicated by a [i]=T. The case where the element of the index i in the array a is “F” is indicated by a [i]=F.
An array a storing information on a sell order is referred to as a “first array a”, and an array a storing information on a buy order is referred to as a “second array a”.
An initial state of the first array a is illustrated in step S10. In the initial state of the first array a, a [0]=T, and all other elements are “F”.
In a case where a sell order having an order count 3 is accepted, a state of the first array a is as illustrated in step S11. Since the first array a is a [0]=T, the information processing apparatus sets a [0+3]=T.
In a case where an order having an order count 5 is accepted, the state of the first array a is as illustrated in step S12. Since the first array a is a [0]=T, the information processing apparatus sets a [0+5]=T. Since the first array a is a [3]=T, the information processing apparatus sets a [3+5]=T.
An index in which an element of the first array a is T indicates a matchable contract quantity. For example, in the state of the first array a in step S12 in
For example, in a case where a buy order having an order count 2, a buy order having an order count 3, and a buy order having an order count 6 are accepted in this order, the state of the second array a is as illustrated in
The information processing apparatus compares the first array a of the sell orders described with reference to
Next, a process in which the information processing apparatus specifies an order to be a contract target will be described. In a case of accepting an order and setting “T” in an element of the array a for the first time, the information processing apparatus registers auxiliary information indicating an order reception sequence (order sequence) and a quantity (order count) for each index, and thus it is possible to specify an order as a contract target.
First (order reception sequence=1), in a case where a sell order having an order count 2 is accepted, a state of the first array a is as illustrated in step S21. Since the first array a in the initial state is a [0]=T, the information processing apparatus sets a [0+2]=T. Auxiliary information sub1-2 is registered at the index i=2. A sequence number “1” and a quantity “2” are set in the auxiliary information sub1-2.
Next (order reception sequence=2), in a case where a sell order having an order count 3 is accepted, the state of the first array a is as illustrated in step S22. Since the first array a is a [0]=T, the information processing apparatus sets a [0+3]=T, and registers auxiliary information sub1-3 to the index i=3. A sequence number “2” and a quantity “3” are set in the auxiliary information sub1-3.
Since the first array a is a [2]=T, the information processing apparatus sets a [2+3]=T, and registers auxiliary information sub1-5 to the index i=5. A sequence number “2” and a quantity “3” are set in the auxiliary information sub1-5.
Although not illustrated, also in a case where a buy order is accepted, the information processing apparatus sets “T” in an element of the second array a, and registers auxiliary information in an index in the same manner as in
After accepting the orders Or1-1 and Or1-2 in order, the information processing apparatus executes the process on the first array a in a case where the sell order is accepted so as to set the first array a to the state as illustrated in
The information processing apparatus sets auxiliary information sub1-3 to the index i=3 in the first array a. A sequence number “1” and a quantity “3” are set in the auxiliary information sub1-3. The information processing apparatus sets auxiliary information sub1-5 to the index i=5 in the first array a. A sequence number “2” and a quantity “5” are set in the auxiliary information sub1-5. The information processing apparatus sets auxiliary information sub1-8 to the index i=8 in the first array a. A sequence number “2” and a quantity “5” are set in the auxiliary information sub1-8.
After accepting the orders Or2-1, Or2-2, and Or2-3 in order, the information processing apparatus executes a process on the second array a in a case where the buy order is accepted so as to set the second array a to the state as illustrated in
The information processing apparatus sets auxiliary information sub2-2 to the index i=2 in the second array a. A sequence number “1” and a quantity “2” are set in the auxiliary information sub2-2. The information processing apparatus sets auxiliary information sub2-3 to the index i=3 in the second array a. A sequence number “2” and a quantity “3” are set in the auxiliary information sub2-3. The information processing apparatus sets auxiliary information sub2-5 to the index i=5 in the second array a. A sequence number “2” and a quantity “3” are set in the auxiliary information sub2-5.
The information processing apparatus sets auxiliary information sub2-6 to the index i=6 in the second array a. A sequence number “3” and a quantity “6” are set in the auxiliary information sub2-6. The information processing apparatus sets auxiliary information sub2-8 to the index i=8 in the second array a. A sequence number “3” and a quantity “6” are set in the auxiliary information sub2-8. The information processing apparatus sets auxiliary information sub2-9 to the index i=9 in the second array a. A sequence number “3” and a quantity “6” are set in the auxiliary information sub2-9. The information processing apparatus sets auxiliary information sub2-11 to the index i=11 in the second array a. A sequence number “3” and a quantity “6” are set in the auxiliary information sub2-11.
The information processing apparatus compares the first array a with the second array a, and calculates a largest index among indices in which both of an element of the first array a and an element of the second array a are “T”, as a contract count. According to the example illustrated in
After calculating the contract count, the information processing apparatus specifies an order as a contract target, based on the auxiliary information set in the array a. In a case of a contract with a contract count i0, the information processing apparatus sets an initial value of the index i=i0, and repeatedly executes the following process until i=0.
A process repeated by the information processing apparatus is the following process. The information processing apparatus treats an order with a [i]=T as a contract target. Next, the information processing apparatus specifies a quantity a included in the auxiliary information set in a [i], and updates the index i by i=i−a.
Based on the “first array a” in
The information processing apparatus treats, as a contract target, an order corresponding to the auxiliary information sub1-8 set to the index i=8 corresponding to the contract count “8”. The auxiliary information sub1-8 corresponds to the order Or1-2 with the sequence number “2” and the quantity “5”. The information processing apparatus acquires the quantity a=5 included in the auxiliary information sub1-8, and updates the index i=8−5=3.
The information processing apparatus treats an order corresponding to the auxiliary information sub1-3 set to index i=3 as a contract target. The auxiliary information 1-3 corresponds to the order Or1-1 with the sequence number “1” and the quantity “3”. The information processing apparatus acquires the quantity a=3 included in the auxiliary information sub1-3, and updates the index i=3−3=0. Since the index i=0, the information processing apparatus ends the process.
Based on the “second array a” in
The information processing apparatus treats, as a contract target, an order corresponding to the auxiliary information sub2-8 set to the index i=8 corresponding to the contract count “8”. The auxiliary information 2-8 corresponds to the order Or2-3 with the sequence number “3” and the quantity “6”. The information processing apparatus acquires the quantity a=6 included in the auxiliary information sub2-8, and updates the index i=8−6=2.
The information processing apparatus treats an order corresponding to the auxiliary information sub2-2 set to index i=2 as a contract target. The auxiliary information sub2-2 corresponds to the order Or2-1 with the sequence number “1” and the quantity “2”. The information processing apparatus acquires the quantity a=2 included in the auxiliary information sub2-2, and updates the index i=2−2=0. Since the index i=0, the information processing apparatus ends the process.
With the above-described process, the sell orders Or1-1 and Or1-2 and the buy orders Or2-1 and Or2-3 are specified as the contract targets.
In this manner, in a case where an array of order statuses related to remaining orders after an order as a contract target is specified or the order is canceled in dynamic programming, the array may not be obtained from the previously created array, and the array will be reconstructed each time. For this reason, there is a problem that efficiency in specifying an order as a contract target is poor, such as a memory for an index for specifying the order constituting the maximum contract is consumed.
In the present embodiment, the dynamic programming is regarded as multiplication (multiplication method) of a polynomial, and the dynamic programming is reduced to a polynomial. For example, in the information processing apparatus according to the present embodiment, each of accepted orders is represented by a polynomial having a contract count as an exponent, and an order status obtained by combining the respective orders is represented by multiplication of the polynomial of each order.
In the information processing apparatus according to the present embodiment, after an order as a contract target is specified, or after the order is canceled, subtraction of the orders is associated with division (division method) of the polynomial to obtain an order status related to the remaining order.
According to the present embodiment, by using the polynomial operation in this manner, it is possible to obtain the order status related to the remaining orders after specifying the order of the contract target or after canceling the order, without combining and reconstructing each order from the beginning. Accordingly, in the present embodiment, it is possible to efficiently specify the order as the contract target.
For example, an order with a condition that a contract count is k shares is represented by xk. For example, 1=x0 corresponds to “no contract”, and x3 corresponds to “contract with 3 shares”. Whether or not a contract of the order with 3 shares is made is represented by multiplying (1+x3). In the same manner, whether or not a contract of an order with 2 shares is made is represented by multiplying (1+x2). A combination of the orders with 3 shares and 2 shares is represented by multiplication of (1+x3) and (1+x2) as follows, and it is understood that a contract may be executed with 0, 2, 3, and 5 shares by a polynomial after the multiplication.
(combination of orders with 3 shares and 2 shares)=(1+x3)(1+x2)=1+x2+x3+x5
In the operation of the polynomial, 1 corresponds to T and 0 correspond to F, and addition and multiplication are defined as follows. · Addition is performed such that 0+0=0, 1+0=1, 0+1=1, and 1+1=1. · Multiplication is performed such that 0*0=0, 1*0=0, 0*1=0, and 1*1=1.
An initial state of the array a of the order statuses is illustrated in step S31. In the initial state of the array a, a [0]=1 corresponding to 1=x0 representing “no contract”, and all other elements are “0”.
Next, in a case where an order having an order count 3 is accepted (arrives), a state of the array a is as illustrated in step S32. The information processing apparatus multiplies 1 by (1+x3) of a polynomial corresponding to the order of the order count 3. Based on 1+x3 of the polynomial obtained by the multiplication, the information processing apparatus sets 1 to a [0] and a [3].
Next, in a case where an order having an order count 2 is accepted (arrives), the state of the array a is as illustrated in step S33. The information processing apparatus multiplies (1+x3) by (1+x2) of a polynomial corresponding to the order of the order count 2. Based on 1+x2+x3+x5 of the polynomial obtained by the multiplication, the information processing apparatus sets 1 to a [0], a [2], a [3], and a [5].
Next, in a case where an order having an order count 3 is accepted (arrives), the state of the array a is as illustrated in step S34. The information processing apparatus multiplies (1+x2+x3+x5) by (1+x3) of a polynomial of the order of the order count 3. Based on 1+x2+x3+x5+x6+x8 of the polynomial obtained by the multiplication, the information processing apparatus sets 1 to a [0], a [2], a [3], a [5], a [6], and a [8].
According to the above definition, there is no inverse operation (subtraction) for addition of T/F (0+0=0, 1+0=1, 0+1=1, and 1+1=1) and there is no inverse operation (division) for multiplication of T/F (0*0=0, 1*0=0, 0*1=0, and 1*1=1). In the present embodiment, the number system in the polynomial operation is changed to make the operation ready for reversibility. For example, a coefficient of each term in the polynomial operation is replaced with an integer on a finite field Fp, that is a remainder (mod p) divided with a specific prime number p. Therefore, the information processing apparatus of the present embodiment sets the polynomial representing the order status as a polynomial on a finite field, and obtains a state (polynomial) in which the order is canceled by an inverse operation (for example, division).
As an example, in a case where the prime number p is p=7 (mod 7), the prime number p is replaced with any integer of {0, 1, 2, 3, 4, 5, 6}. For example, addition is 3+5=8≡1. Subtraction is 3−5=−2≡5. Multiplication is 3*5=15≡1. Division is 3/5=3*3=9≡2 (since multiplication of 3 and 5 results in 1, “division by 5” is the same as “multiplication by 3”). In this manner, it is possible to handle as a set having a finite number of elements capable of addition, subtraction, multiplication, and division. In this manner, by setting the finite number, it becomes easy to handle in a computer operation. The prime number p used for an actual operation is a sufficiently large value to support the order count to be combined.
An initial state of the array a of order statuses is illustrated in step S41. In the initial state of the array a, a [0]=1 corresponding to 1=x0 representing “no contract”, and all other elements are “0”.
Next, in a case where an order having an order count 3 is accepted (arrives), a state of the array a is as illustrated in step S42. The information processing apparatus multiplies 1 by (1+x3) of a polynomial corresponding to the order of the order count 3. The information processing apparatus replaces a coefficient of each term with an integer on a finite field Fp divided by the prime number p (mod p) in an operation (for example, multiplication) of the polynomial. Based on 1+x3 of the polynomial obtained by the multiplication, the information processing apparatus sets 1 to a [0] and a [3] (all other elements are 0).
Next, in a case where an order having an order count 2 is accepted (arrives), the state of the array a is as illustrated in step S43. The information processing apparatus multiplies (1+x3) by (1+x2) of a polynomial corresponding to the order of the order count 2. Based on 1+x2+x3+x5 of the polynomial obtained by the multiplication, the information processing apparatus sets 1 to a [0], a [2], a [3], and a [5] (all the other elements are 0).
Next, in a case where an order having an order count 3 is accepted (arrives), the state of the array a is as illustrated in step S44. The information processing apparatus multiplies (1+x2+x3+x5) by (1+x3) of a polynomial of the order of the order count 3. Based on 1+x2+2x3+2x5+x6+x8 of the polynomial obtained by this multiplication, the information processing apparatus sets 1 to a [0] and a [2], sets 2 to a [3] and a [5], and sets 1 to a [6] and a [8](all the other elements are 0).
For example, the information processing apparatus performs division on 1+x2+2x3+2x5+x6+x8 in the array a in step S44 by (1+x2). Based on 1+2x3+x6 of the polynomial obtained by this division, the information processing apparatus sets 1 to a [0] and a [6], and sets 2 to a [3](all the other elements are 0).
The communication unit 110 is coupled to an external apparatus or the like in a wired or wireless manner, and transmits and receives information to and from the external apparatus or the like. The communication unit 110 is implemented by, for example, a network interface card (NIC) or the like. The communication unit 110 may be coupled to a network (not illustrated). For example, the communication unit 110 receives information on a sell order table 141 including information on sell orders, information on a buy order table 142 including information on buy orders, and the like from the external apparatus. For example, the external apparatus corresponds to a server that manages buying and selling of shares, and executes various types of processes related to an order as a contract target.
The input unit 120 is an input device that inputs various types of information to the information processing apparatus 100. The input unit 120 corresponds to a keyboard, a mouse, a touch panel, or the like.
The display unit 130 is a display device that displays information output from the control unit 150. The display unit 130 corresponds to a liquid crystal display, an organic electroluminescence (EL) display, a touch panel, or the like.
The storage unit 140 includes the sell order table 141, the buy order table 142, first polynomial information 143, second polynomial information 144, and contract result information 145. For example, the storage unit 140 is implemented by a semiconductor memory element such as a random-access memory (RAM) or a flash memory, or a storage device such as a hard disk or an optical disc.
The sell order table 141 is a table in which an order sequence and an order count of the sell order are held.
The buy order table 142 is a table in which an order sequence and an order count of the buy order are held.
The first polynomial information 143 is array information holding information of a polynomial corresponding to an order status in which orders related to sell orders are combined. For example, the array information is array information of a polynomial (array a) on a finite field representing a status of the sell order, which is obtained by multiplying each sell order by the corresponding polynomial.
The second polynomial information 144 is array information holding information of a polynomial corresponding to an order status in which orders related to buy orders are combined. For example, the array information is array information of a polynomial (array a) on a finite field representing a status of the buy order, which is obtained by multiplying each buy order by the corresponding polynomial.
The contract result information 145 holds a maximum contract count and information on an order as a contract target.
The control unit 150 includes an order reception unit 151, a polynomial generation unit 152, a calculation unit 153, a contract processing unit 154, and an output control unit 155. For example, the control unit 150 is implemented by a central processing unit (CPU) or a microprocessor unit (MPU). The control unit 150 may also be implemented by an integrated circuit such as an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA), for example.
The order reception unit 151 is a processing unit that accepts an order having a designated condition for a contract count. After acquiring data of the sell order table 141 from an external apparatus or the like, the order reception unit 151 stores the data of the sell order table 141 in the storage unit 140. The order reception unit 151 may acquire sell orders individually and sequentially, and register information on the acquired sell orders in the sell order table 141.
In a case of acquiring data of the buy order table 142 from the external apparatus or the like, the order reception unit 151 stores the data of the buy order table 142 in the storage unit 140. The order reception unit 151 may acquire buy orders individually and sequentially, and register information on the acquired buy orders in the buy order table 142.
The order reception unit 151 may accept information (identification information) on an order to be canceled, and may delete information on a sell order or a buy order registered in the sell order table 141 or the buy order table 142. At this time, the order reception unit 151 acquires information on the order to be deleted from the sell order table 141 or the buy order table 142, and notifies the calculation unit 153 of the information.
The polynomial generation unit 152 is a processing unit that generates a polynomial on a finite field (hereafter, also referred to as an existing polynomial) representing an order status obtained by combining the accepted orders. For each of the accepted orders, the polynomial generation unit 152 sets a polynomial having a contract count (order count) under the condition designated in the order, as an exponent. Next, the polynomial generation unit 152 represents an order status obtained by combining the accepted orders with the polynomial (existing polynomial) on a finite field by a product of the polynomials.
For example, based on the sell order table 141 related to the sell orders, the polynomial generation unit 152 sets, for each of the sell orders, a polynomial having the order count designated by the sell order as an exponent. Next, the polynomial generation unit 152 multiplies the order status to be combined with the accepted sell order by a polynomial of each sell order. By setting a coefficient of the polynomial obtained by the multiplication as a remainder (mod p) of a specific prime number (p), the polynomial generation unit 152 generates a polynomial (first existing polynomial) on a finite field corresponding to the order status of the sell order. Next, the polynomial generation unit 152 stores information on the generated polynomial in the storage unit 140 as the first polynomial information 143.
Based on the buy order table 142 related to the buy orders, the polynomial generation unit 152 sets a polynomial having the order count designated by the buy order as an exponent, for each buy order. Next, the polynomial generation unit 152 multiplies the order status to be combined with the accepted buy order by a polynomial of each buy order. By setting a coefficient of the polynomial obtained by the multiplication as a remainder (mod p) of the specific prime number (p), the polynomial generation unit 152 generates a polynomial (second existing polynomial) on a finite field corresponding to the order status of the buy order. Next, the polynomial generation unit 152 stores information on the generated polynomial as the second polynomial information 144 in the storage unit 140.
The calculation unit 153 is a processing unit that performs various operation processes on a polynomial on a finite field representing an order status. For example, the calculation unit 153 divides the polynomial (existing polynomial) on a finite field representing the order status by a polynomial corresponding to an order for a contract or an order to be canceled, and updates to the existing polynomial representing an order status after the contract or the cancellation. For example, the calculation unit 153 performs division on the existing polynomial of the first polynomial information 143 or the second polynomial information 144 by a polynomial corresponding to the order specified as a contract target by the contract processing unit 154 or the order to be canceled (deleted) notified by the order reception unit 151. Next, the calculation unit 153 stores information on the existing polynomial after the division in the storage unit 140, as the first polynomial information 143 or the second polynomial information 144.
For example, in a case where the order for a contract or the order to be canceled is a sell order, the calculation unit 153 generates a polynomial corresponding to the sell order for a contract or the sell order to be canceled by a method in the same manner as the polynomial generation unit 152. Next, the calculation unit 153 performs division on the first existing polynomial in the first polynomial information 143 by the generated polynomial so as to obtain a first existing polynomial corresponding to a status of the sell order after the contract or after the cancellation. Next, the calculation unit 153 stores information on the obtained first existing polynomial as the first polynomial information 143 in the storage unit 140.
In a case where the order for a contract or the order to be cancelled is a buy order, the calculation unit 153 generates a polynomial corresponding to the buy order for a contract or the buy order to be cancelled by a method in the same manner as the polynomial generation unit 152. Next, the calculation unit 153 performs division on the second existing polynomial in the second polynomial information 144 by the generated polynomial so as to obtain a second existing polynomial corresponding to a status of the buy order after the contract or the cancellation. Next, the calculation unit 153 stores information on the obtained second existing polynomial as the second polynomial information 144 in the storage unit 140.
The calculation unit 153 may determine whether or not to adopt the existing polynomial after the division as the existing polynomial representing an order status after the contract or the cancellation based on a coefficient of a term of a specific exponent. For example, as a result obtained by dividing the existing polynomial by the polynomial corresponding to the order as a contract target or a cancellation target, the calculation unit 153 adopts the polynomial when the coefficient of the specific term is not 0, and does not adopt the polynomial when the coefficient is 0.
As an example, a contract with 6 shares in a case where the existing polynomial is 1+x2+2x3+2x5+x6+x8 (available since a coefficient of x6 is not 0) is considered. When it is desired to determine whether or not an order with 2 shares is included in this contract, the original equation (existing polynomial described above) is divided by 1+x2. Next, since a coefficient of a term of x4 (for 4 shares from 6−2=4) in 1+2x3+x6 as a result of the division is 0, it is understood that the order is not included.
In this manner, the calculation unit 153 may determine adoption or non-adoption, based on a coefficient of a specific term in the existing polynomial after the division. In a case of non-adoption, the calculation unit 153 may cause the output control unit 155 to notify an error, or may return the process to the contract processing unit 154 so that another order becomes a contract target.
For example, in a case where the prime number p in the finite field is smaller than the number of combinations of orders, the coefficient in the existing polynomial after the operation may be a false positive. Accordingly, in the information processing apparatus 100, by determining adoption or non-adoption based on a coefficient of a specific term, it is possible to exclude a case of the false positive.
In a case where an order to be newly added is accepted by the order reception unit 151, the calculation unit 153 may multiply an existing polynomial by a polynomial of the order to update the existing polynomial to a polynomial representing an order status after the addition.
For example, in a case where the order which is newly added is a sell order, the calculation unit 153 generates a polynomial corresponding to the sell order to be added, by a method in the same manner as the polynomial generation unit 152. Next, the calculation unit 153 multiplies the first existing polynomial in the first polynomial information 143 by the generated polynomial to obtain a first existing polynomial corresponding to a status of the sell order after the addition. Next, the calculation unit 153 stores information on the obtained first existing polynomial as the first polynomial information 143 in the storage unit 140.
In a case where the order to be newly added is a buy order, the calculation unit 153 generates a polynomial corresponding to the buy order to be added, by a method in the same manner as the polynomial generation unit 152. Next, the calculation unit 153 multiplies the second existing polynomial in the second polynomial information 144 by the generated polynomial to obtain a second existing polynomial corresponding to a status of the buy order after the addition. Next, the calculation unit 153 stores information on the obtained second existing polynomial as the second polynomial information 144 in the storage unit 140.
The contract processing unit 154 is a processing unit that specifies an order to be a contract target, based on a maximum contract count, the first polynomial information 143, and the second polynomial information 144. A process of the contract processing unit 154 corresponds to the process described with reference to
For example, as described with reference to
Next, the contract processing unit 154 registers identification information of the order specified as a contract target by executing the above-described process, in the contract result information 145. The contract processing unit 154 acquires the information on the order of the contract target from the sell order table 141 or the buy order table 142, and notifies the calculation unit 153 of the information.
The output control unit 155 is a processing unit that outputs the contract result information 145 to the display unit 130 so as to display the contract result information 145. The output control unit 155 may transmit the contract result information 145 to an external apparatus, and request the external apparatus to execute various contract processes.
Next, based on the type (condition) of the accepted order, the polynomial generation unit 152 converts the order into a polynomial (Po) having a contract count (order count) under the condition designated in the order as an exponent (S102). In a case where the condition of the contract count has a range such as a case where a minimum contract count is a shares (for example, 3 shares) and an order count is b shares (for example, 5 shares), the polynomial generation unit 152 converts the order into a polynomial having the contract count of a to b shares as an exponent. For example, the polynomial generation unit 152 performs conversion into a polynomial of 1+xa+xa+1+xa+2+ . . . +xb.
Next, the calculation unit 153 determines whether or not the accepted order is an additional order (S103). In a case of the additional order (Yes in S103), the calculation unit 153 reads the first polynomial information 143 when the additional order is a sell order and the second polynomial information 144 when the additional order is a buy order, and acquires an existing polynomial (P). Next, the calculation unit 153 multiplies the acquired existing polynomial (P) by the polynomial (Po) (S104). Next, the calculation unit 153 updates the first polynomial information 143 or the second polynomial information 144 with the existing polynomial (P) after the multiplication, and ends the process.
In a case where the order is not an additional order but is canceled (No in S103), the calculation unit 153 reads the first polynomial information 143 in a case where the order to be canceled is a sell order, and reads the second polynomial information 144 in a case where the order to be canceled is a buy order, and acquires the existing polynomial (P). Next, the calculation unit 153 divides the acquired existing polynomial (P) by the polynomial (Po) (S105). Next, the calculation unit 153 updates the first polynomial information 143 or the second polynomial information 144 with the existing polynomial (P) after the division, and ends the process.
Next, for each of a sell order and a buy order, the contract processing unit 154 executes a loop process (S112 to S117) on the order as a contract target to specify an order for a contract. For example, in the case of
For example, the contract processing unit 154 generates a polynomial Q, based on a condition of the order i (S113). Next, the calculation unit 153 calculates a polynomial P′ by dividing the existing polynomial P (the first existing polynomial in a case where the order i is a sell order, and the second existing polynomial in a case where the order i is a buy order) by the polynomial Q (S114).
Next, the contract processing unit 154 determines a contract count M for the order i by comparing coefficients of the P, Q, and P′ (S115). Assuming that a coefficient of xN of P(x) is c in a polynomial operation P(x)=Q(x)*P′(x), when c is not 0, there is a case where c1≠c2 at c1xN−M of Q(x) and c2xN of P(x). The contract processing unit 154 determines M that satisfies the above-described condition. A case where M is 0 represents that a contract of 0 shares is made, for example, a contract of the order i is not made.
Next, the contract processing unit 154 subtracts the determined contract count M from N, and replaces the existing polynomial P with P′ (S116).
Next, after the loop process (S112 to S117), the contract processing unit 154 outputs the specified order for a contract (S118), and ends the process.
As described above, the information processing apparatus 100 accepts an order having a designated condition for a contract count. For each of the accepted orders, the information processing apparatus 100 uses a polynomial of which exponent is the contract count under the designated condition. The information processing apparatus 100 represents an order status obtained by combining the accepted orders by a polynomial on a finite field by a product of the polynomials. The information processing apparatus 100 performs division on the polynomial on the finite field representing the order status by a polynomial corresponding to an order for a contract or an order to be canceled, and updates to the polynomial on the finite field representing an order status after the contract or after the cancellation.
Therefore, in the information processing apparatus 100, it is possible to obtain the order status related to the remaining orders after specifying the order of the contract target or after canceling the order, without combining and reconstructing each order from the beginning. Accordingly, with the information processing apparatus 100, it is possible to efficiently specify the order to be the contract target.
The information processing apparatus 100 represents a buy order status obtained by combining the accepted buy orders by a first polynomial on a finite field by a product of the polynomials. The information processing apparatus 100 represents a sell order status obtained by combining the accepted sell orders by a second polynomial on a finite field by a product of the polynomials. Therefore, in the information processing apparatus 100, it is possible to efficiently obtain, for each of the buy order status in which the buy orders are combined and the sell order status in which the sell orders are combined, an order status after specifying the order as a contract target or after cancelling the order.
The information processing apparatus 100 determines whether or not to adopt the polynomial on the finite field after the division as the polynomial on the finite field representing the order status after the contract or the cancellation, based on a coefficient of a term of a specific exponent. In this manner, the information processing apparatus 100 may adopt or not adopt the polynomial on the finite field after the division, depending on the coefficient of the term of the specific exponent. Therefore, for example, the information processing apparatus 100 may exclude a case where the coefficient in the existing polynomial after the operation is a false positive.
According to the first embodiment, a sell order status in which sell orders are combined and a buy order status in which buy orders are combined are handled with different polynomials. For this reason, in the first embodiment, when the number of orders increases, calculation costs such as a calculation time or a memory region desirable for searching for a contract are increased.
According to a second embodiment, for one order of the sell order and the buy order, the polynomial generation unit 152 sets a polynomial in which a contract count under a designated condition is a positive exponent. For the other order of the sell order and the buy order, the polynomial generation unit 152 sets a polynomial in which a contract count under a designated condition is a negative exponent. As an example, the positive exponent is set for the sell order and the negative exponent is set for the buy order, and the positive and negative exponents may be reversed.
For example, the polynomial generation unit 152 represents a sell order of a shares as 1+xa (a sell contract with a shares: xa or no contract: 1). The polynomial generation unit 152 represents a buy order of a share as 1+x−a (a buy contract with a shares: x−a or no contract: 1). As an example, the polynomial generation unit 152 sets a sell order of one share to 1+x. The polynomial generation unit 152 sets a buy order of 3 shares to 1+x−3. The polynomial generation unit 152 sets a sell order of 2 shares to 1+x2.
Next, the polynomial generation unit 152 represents an order status in which the sell order and the buy order are combined as one polynomial on a finite field, by a product of the respective polynomials represented by positive and negative exponents for the sell order and the buy order. The polynomial generation unit 152 stores information on the generated polynomial as a polynomial information 143a in the storage unit 140.
For example, in a case where the sell order (1+x) of one share and the buy order (1+x−3) of 3 shares arrive, the polynomial generation unit 152 obtains a polynomial of an order status in which the sell order and the buy order are combined, as follows by using a product of the sell order (1+x) and the buy order (1+x−3).
(1+x)×(1+x−3)=x−3+x−2+1+x
After that, in a case where the sell order (1+x2) of 2 shares arrives, the polynomial generation unit 152 updates the polynomial of the order status in which the sell order and the buy order are combined, as follows by using a product with the sell order of 2 shares.
(x−3+x−2+1+x)×(1+x2)=x−3+x−2+x1+2+x+x2+x3
According to the second embodiment, the calculation unit 153 performs various operation processes based on the polynomial information 143a stored in the storage unit 140, in the same manner as the polynomial operation corresponding to the order status of each of the sell order and the buy order. Based on the polynomial information 143a, the contract processing unit 154 specifies an order to be a contract target.
With one polynomial on a finite field representing an order status in which a sell order and a buy order are combined, it may be determined that a contract is available when a constant term has a value other than 1. The constant term in this polynomial represents a position (the number of combinations) at which buying and selling are balanced, and for example, in a case where the constant term is 1, it represents that there is one set in which no contract is made. When the constant term has the value other than 1, there is at least one combination of which a contract is made as a combination other than a combination of which a contract is not made (the number of combinations of (the value of the constant term)−1). For this reason, the contract processing unit 154 determines whether or not the contract is available, based on the constant term in the polynomial indicated by the polynomial information 143a.
A method, in which the contract processing unit 154 specifies an order for a contract based on a polynomial indicated by the polynomial information 143a in a case where the contract processing unit 154 determines that a contract is available, will be described with reference to
As illustrated in
After that, the contract processing unit 154 initializes a variable (n) representing a sum (sell count−buy count) of order counts (the number of shares) and an array (A) indicating an order for a contract (0 or empty array) (S202).
After that, the contract processing unit 154 executes the loop process (S203 to S210) of each order with the order count (the number of shares) in each order (i) as ai.
For example, the contract processing unit 154 determines whether or not the order (i) to be processed is a sell order (S204). In a case of the sell order (Yes in S204), the contract processing unit 154 sets p(x) to 1+xai, and n′=n−ai (S205).
In a case of a buy order instead of the sell order (No in S204), the contract processing unit 154 sets p(x) to 1+x−ai, and n′=n+ai (S206).
After that, the contract processing unit 154 calculates P′(x)=P(x)/p(x), and obtains a polynomial by subtracting the order to be processed from an order status represented by the original polynomial (S207).
After that, the contract processing unit 154 determines whether or not a coefficient of xn′ of P′(x) is 0 (S208). In a case where the coefficient of xn′ is not 0 (Yes in S208), the contract processing unit 154 adds the order (i) to the array A, sets P(x)=P′(x) and n=n′ (S209), and returns to the next loop process. When the coefficient of xn′ is 0 (No in S208), the contract processing unit 154 returns P(x), and n to the next loop process as they are (S210).
After the loop process, the contract processing unit 154 determines whether n=0 and A is not empty (S211). In a case where n=0 and A is empty (No in S211), the contract processing unit 154 returns the process to S203. In a case where n=0 and A is not empty (Yes in S211), the contract processing unit 154 outputs the array (A) indicating an order for a contract (S212), and ends the process.
In the loop process described above, the orders (i) to be processed may be set in a reception sequence. Therefore, the contract processing unit 154 may set a priority sequence for contract to the reception sequence.
The above-described process is not for specifying the order such that the order count for the contract of the sell order and the buy order is the maximum count. A process of specifying an order such that the order count for the contract of the sell order and the buy order is the maximum count will be described.
First, in order to obtain the maximum contract, the polynomial generation unit 152 includes a label indicating the maximum number of a sum of combined order counts and identification information (for example, order number) of the combined orders in each term of one polynomial, as an index, in the polynomial information 143a.
Based on the index of each term included in the polynomial information 143a, the contract processing unit 154 specifies an order that maximizes the order count. For example, a label of a constant term included in a polynomial indicating an order status in which a sell order and a buy order are combined indicates a case where an order count is maximized (the maximum number of a sum of the order counts and a combination of orders). Accordingly, the contract processing unit 154 specifies the sell order and the buy order for a contract based on the label (index) of the constant term included in the polynomial information 143a.
For each term, the polynomial generation unit 152 gives, as [ ], the maximum number of a sum of the combined order counts and an index of identification information (order number) of the combined orders. According to the illustrated example, the index of each term is [maximum number of sum of combined order counts, (order number)].
After that, in a case where a sell order (1+x2) of 2 shares arrives, the polynomial generation unit 152 updates the polynomial of the order status in which the sell order and the buy order are combined and the index of each term, by a product with the sell order of 2 shares.
Since a constant term is 2, the contract processing unit 154 determines that the contract is available, and specifies an order for a contract based on the index of the constant term. According to the illustrated example, the contract processing unit 154 specifies the sell orders and the buy orders having order numbers (1), (2), and (3) as orders for a contract with the maximum order count 6.
An operation of the polynomial generation unit 152 that obtains an indexed polynomial to obtain a maximum contract will be described with reference to
As illustrated in
After that, the polynomial generation unit 152 creates Q(x) by copying P(x) (S222), and executes the loop process on each term cxk [s, v] of P(x) (S223 to S228). [ ] indicates an index of each term, s indicates a maximum value of an order count, and v indicates a column of an order (order number) reaching a total of s shares.
After the loop process is started, the polynomial generation unit 152 prepares, as v′, an order list in which the new order (Oi) is coupled to an end of v (S224). After that, the polynomial generation unit 152 determines whether or not the new order (Oi) is a sell order (S225).
In a case where the new order (Oi) is the sell order (Yes in S225), the polynomial generation unit 152 performs a merging process of adding cxk+n [s+n, v′] to Q(x) (S226), and advances the process to the next loop. In a case where the new order (Oi) is not the sell order but a buy order (No in S225), the polynomial generation unit 152 performs the merging process of adding cxk−n [s+n, v′] to Q(x) (S227), and advances the process to the next loop.
As illustrated in
After that, the polynomial generation unit 152 determines whether or not an item of xk exists in Q(x) (S232). In a case where there is no item of xk in Q(x) (No in S232), the polynomial generation unit 152 advances the process to S237.
In a case where the item of xk exists in Q(x) (Yes in S232), the polynomial generation unit 152 sets the term of xk of Q(x) to c′xk [s′, v′] (S233).
After that, the polynomial generation unit 152 determines whether or not s≥s′ is satisfied (S234), and in a case where s≥s′ is satisfied (Yes in S234), the polynomial generation unit 152 replaces the term of xk of Q(x) with (c+c′)xk [s, v] (S235). In a case where s≥s′ is not satisfied (No in S234), the polynomial generation unit 152 replaces the term of xk of Q(x) with (c+c′)xk [s′, v′] (S236).
After that, the polynomial generation unit 152 outputs Q(x) obtained in the above-described process (S231 to S236) as a processing result (S237), and ends the process.
After the above-described loop process, the polynomial generation unit 152 outputs the obtained Q(x) as a new polynomial with an index (S229), and ends the process. For example, the polynomial generation unit 152 updates the polynomial information 143a based on Q(x).
Although an index of each term is a list of orders and a memory use amount increases if the index is held as it is, the index may be held by using a memory structure such as a trie (a node of the trie corresponds to the index) since only the process of adding to the end is performed in the above-described process. For example, it is possible to suppress an increase in memory use amount with the compression of the indices.
As described above, for each of a sell order and a buy order for which a condition of a contract count is designated, the information processing apparatus 100 sets a first polynomial in which the contract count under the condition designated for one of the sell order and the buy order is a positive exponent. For each of the sell order and the buy order for which the condition of the contract count is designated, the information processing apparatus 100 sets a second polynomial in which the contract count under the condition designated for the other of the sell order and the buy order is a negative exponent. The information processing apparatus 100 represents an order status in which the sell order and the buy order are combined, by one polynomial on a finite field by a product of the first polynomial and the second polynomial. The information processing apparatus 100 specifies a sell order and a buy order for a contract based on the one polynomial on the finite field representing the order status.
In this manner, since the information processing apparatus 100 represents the order status in which the sell order and the buy order are combined, with the one polynomial on the finite field, the sell order and the buy order may be simultaneously handled, and thus memory efficiency is better than a case where the sell order and the buy order are separately handled. Accordingly, the information processing apparatus 100 may reduce a calculation cost in the process for obtaining the contract for trading.
In a case where a constant term included in one polynomial is an integer other than 1, the information processing apparatus 100 specifies a sell order and a buy order for a contract. The constant term included in one polynomial represents a case in which the sell order and the buy order are balanced, including a case in which a contract is not made (the constant term is 1). For example, in a case where the constant term is an integer other than 1, there is at least one case (a combination of a sell order and a buy order) in which a contract is made other than a case in which a contract is not made. Accordingly, in a case where the constant term is an integer other than 1, the information processing apparatus 100 may specify a combination of a sell order and a buy order satisfying the condition of the contract by specifying the sell order and the buy order for the contract.
The information processing apparatus 100 gives a label indicating a maximum number of a sum of the combined order counts and identification information on the combined orders, in each term of one polynomial, and specifies a sell order and a buy order for the contract based on the label. Therefore, the information processing apparatus 100 may easily specify the sell order and the buy order for the contract, based on the label given to each term of the one polynomial.
The information processing apparatus 100 specifies a sell order and a buy order for the contract, based on a label of a constant term included in the one polynomial. The label of the constant term included in the one polynomial indicates a case where the order count is maximized in a combination of the sell order and the buy order satisfying the condition of the contract. Accordingly, the information processing apparatus 100 may specify the sell order and the buy order for the contract based on the label of the constant term to maximizing the order count for the contract.
It is noted that each component of each apparatus illustrated in the drawings may not be physically configured as illustrated in the drawings. For example, specific forms of the separation and integration of each apparatus are not limited to those illustrated in the drawings. The entirety or part of the apparatus may be configured by functionally or physically separating into arbitrary units or integrating into an arbitrary unit in accordance with various loads, usage situations, and the like.
Although the present embodiment exemplifies a case to be applied to the case where an order is made under a condition of a total amount contract or a certain order count in stock trading in the securities trading market, the present embodiment is not limited to the application to the stock trading. For example, the present embodiment may be applied to trading other than stock trading, such as futures trading markets.
All or certain some of the various processing functions to be executed by the information processing apparatus 100 may be executed by a CPU (or a microcomputer such as an MPU or a micro controller unit (MCU)) or a graphics processing unit (GPU). Of course, all or arbitrary subset of the various processing functions may be executed in programs analyzed and executed by the CPU (or a microcomputer such as the MPU or MCU) or the GPU or may be executed in hardware using wired logic. The various processing functions performed in the information processing apparatus 100 may be executed in such a way that a plurality of computers cooperate with each other via cloud computing.
Next, an example of a hardware configuration of a computer that implements functions similar to those of the information processing apparatus 100 described in the above embodiment will be described.
As illustrated in
The hard disk device 307 includes an order reception program 307a, a polynomial generation program 307b, an operation program 307c, a contract processing program 307d, and an output control program 307e. The CPU 301 reads each of the programs 307a to 307e, and expands the program into the RAM 306.
The order reception program 307a functions as an order reception process 306a. The polynomial generation program 307b functions as a polynomial generation process 306b. The operation program 307c functions as an operation process 306c. The contract processing program 307d functions as a contract processing process 306d. The output control program 307e functions as an output control process 306e.
A process of the order reception process 306a corresponds to the process of the order reception unit 151. A process of the polynomial generation process 306b corresponds to the process of the polynomial generation unit 152. A process of the operation process 306c corresponds to the process of the calculation unit 153. A process of the contract processing process 306d corresponds to the process of the contract processing unit 154. A process of the output control process 306e corresponds to the process of the output control unit 155.
Each of the programs 307a to 307e may not be stored in the hard disk device 307 from the beginning. For example, each program may be stored in a “portable physical medium” such as a flexible disk (FD), a CD-ROM, a DVD, a magneto-optical disk, an IC card, or the like inserted in the computer 300. The computer 300 may read and execute each of the programs 307a to 307e. Each of the programs 307a to 307e may be stored in an external apparatus coupled to a network such as a public line, the Internet, a LAN, or the like, and each of the programs 307a to 307e may be read from the external apparatus coupled to the network and executed by the computer 300.
All examples and conditional language provided herein are intended for the pedagogical purposes of aiding the reader in understanding the invention and the concepts contributed by the inventor to further the art, and are not to be construed as limitations to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although one or more embodiments of the present invention have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2021-109354 | Jun 2021 | JP | national |