Order matching logic sequencing issue [on hold]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
I have developed a trading exchange where orders are matched in real-time with least possible latency. The order matching service logic is functioning correctly. However, there's a minute error in the operation.
The sequence is wrong. To explain it below is the example of the order book.
Buy side:
Price =3 Qty =1
Price =2 Qty =1
Price =1 Qty =1
Now a user comes with a sell order of Qty=3 at price =1. In this case, all buy orders will execute, but in a sequence of:
First it will execute pending order with buy price of 3, then 2, and then 1.
My matching service executes the logic, but in reverse sequence. Below is the snippet of the code, can someone help ?
if (matchOrderRequest.getOrderType() == OrderType.BUY)
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceLessThanEqualOrderByPriceAscTimestampAsc(request.getMarket(), OrderType.SELL, request.getPrice());
}
else
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceGreaterThanEqualOrderByPriceDescTimestampAsc(request.getMarket(), OrderType.BUY, request.getPrice());
}
There's a lot of logic after this, but it wouldn't make sense to post everything, but if anyone needs to know a little more, I can post it.
java mongodb spring
New contributor
$endgroup$
put on hold as off-topic by Jamal♦ 12 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
I have developed a trading exchange where orders are matched in real-time with least possible latency. The order matching service logic is functioning correctly. However, there's a minute error in the operation.
The sequence is wrong. To explain it below is the example of the order book.
Buy side:
Price =3 Qty =1
Price =2 Qty =1
Price =1 Qty =1
Now a user comes with a sell order of Qty=3 at price =1. In this case, all buy orders will execute, but in a sequence of:
First it will execute pending order with buy price of 3, then 2, and then 1.
My matching service executes the logic, but in reverse sequence. Below is the snippet of the code, can someone help ?
if (matchOrderRequest.getOrderType() == OrderType.BUY)
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceLessThanEqualOrderByPriceAscTimestampAsc(request.getMarket(), OrderType.SELL, request.getPrice());
}
else
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceGreaterThanEqualOrderByPriceDescTimestampAsc(request.getMarket(), OrderType.BUY, request.getPrice());
}
There's a lot of logic after this, but it wouldn't make sense to post everything, but if anyone needs to know a little more, I can post it.
java mongodb spring
New contributor
$endgroup$
put on hold as off-topic by Jamal♦ 12 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago
add a comment |
$begingroup$
I have developed a trading exchange where orders are matched in real-time with least possible latency. The order matching service logic is functioning correctly. However, there's a minute error in the operation.
The sequence is wrong. To explain it below is the example of the order book.
Buy side:
Price =3 Qty =1
Price =2 Qty =1
Price =1 Qty =1
Now a user comes with a sell order of Qty=3 at price =1. In this case, all buy orders will execute, but in a sequence of:
First it will execute pending order with buy price of 3, then 2, and then 1.
My matching service executes the logic, but in reverse sequence. Below is the snippet of the code, can someone help ?
if (matchOrderRequest.getOrderType() == OrderType.BUY)
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceLessThanEqualOrderByPriceAscTimestampAsc(request.getMarket(), OrderType.SELL, request.getPrice());
}
else
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceGreaterThanEqualOrderByPriceDescTimestampAsc(request.getMarket(), OrderType.BUY, request.getPrice());
}
There's a lot of logic after this, but it wouldn't make sense to post everything, but if anyone needs to know a little more, I can post it.
java mongodb spring
New contributor
$endgroup$
I have developed a trading exchange where orders are matched in real-time with least possible latency. The order matching service logic is functioning correctly. However, there's a minute error in the operation.
The sequence is wrong. To explain it below is the example of the order book.
Buy side:
Price =3 Qty =1
Price =2 Qty =1
Price =1 Qty =1
Now a user comes with a sell order of Qty=3 at price =1. In this case, all buy orders will execute, but in a sequence of:
First it will execute pending order with buy price of 3, then 2, and then 1.
My matching service executes the logic, but in reverse sequence. Below is the snippet of the code, can someone help ?
if (matchOrderRequest.getOrderType() == OrderType.BUY)
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceLessThanEqualOrderByPriceAscTimestampAsc(request.getMarket(), OrderType.SELL, request.getPrice());
}
else
{
optionalMatchOrder=orderRepository.findFirstByMarketAndOrderTypeAndPriceGreaterThanEqualOrderByPriceDescTimestampAsc(request.getMarket(), OrderType.BUY, request.getPrice());
}
There's a lot of logic after this, but it wouldn't make sense to post everything, but if anyone needs to know a little more, I can post it.
java mongodb spring
java mongodb spring
New contributor
New contributor
edited 11 mins ago
Kaushal Thakker
New contributor
asked 19 mins ago
Kaushal ThakkerKaushal Thakker
11
11
New contributor
New contributor
put on hold as off-topic by Jamal♦ 12 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by Jamal♦ 12 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago
add a comment |
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
May I know the reason why it is marked off topic? I do see the reason that code not implemented, but it's just part of the code where I assume the problem is. The entire project is too big to be posted here.
$endgroup$
– Kaushal Thakker
10 mins ago