Created
December 25, 2012 18:10
-
-
Save prystupa/4374554 to your computer and use it in GitHub Desktop.
Partial matches for limit orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Core matching logic for limit orders | |
Background: Submit initial non-crossing orders to work with | |
Given the following orders are submitted in this order: | |
| Broker | Side | Qty | Price | | |
| A | Buy | 100 | 10.4 | | |
| B | Buy | 200 | 10.3 | | |
| C | Sell | 100 | 10.7 | | |
| D | Sell | 200 | 10.8 | | |
Then no trades are generated | |
And market order book looks like: | |
| Broker | Qty | Price | Price | Qty | Broker | | |
| A | 100 | 10.4 | 10.7 | 100 | C | | |
| B | 200 | 10.3 | 10.8 | 200 | D | | |
# Omitted tests for exact order size match | |
# ... | |
Scenario: Matching a Buy order large enough to clear the Sell book | |
When the following orders are submitted in this order: | |
| Broker | Side | Qty | Price | | |
| E | Buy | 350 | 10.8 | | |
Then the following trades are generated: | |
| Buying broker | Selling broker | Qty | Price | | |
| E | C | 100 | 10.7 | | |
| E | D | 200 | 10.8 | | |
And market order book looks like: | |
| Broker | Qty | Price | Price | Qty | Broker | | |
| E | 50 | 10.8 | | | | | |
| A | 100 | 10.4 | | | | | |
| B | 200 | 10.3 | | | | | |
Scenario: Matching a Sell order large enough to clear the Buy book | |
When the following orders are submitted in this order: | |
| Broker | Side | Qty | Price | | |
| E | Sell | 350 | 10.3 | | |
Then the following trades are generated: | |
| Buying broker | Selling broker | Qty | Price | | |
| A | E | 100 | 10.4 | | |
| B | E | 200 | 10.3 | | |
And market order book looks like: | |
| Broker | Qty | Price | Price | Qty | Broker | | |
| | | | 10.3 | 50 | E | | |
| | | | 10.7 | 100 | C | | |
| | | | 10.8 | 200 | D | | |
Scenario: Matching a large Buy order partially | |
When the following orders are submitted in this order: | |
| Broker | Side | Qty | Price | | |
| E | Buy | 350 | 10.7 | | |
Then the following trades are generated: | |
| Buying broker | Selling broker | Qty | Price | | |
| E | C | 100 | 10.7 | | |
And market order book looks like: | |
| Broker | Qty | Price | Price | Qty | Broker | | |
| E | 250 | 10.7 | 10.8 | 200 | D | | |
| A | 100 | 10.4 | | | | | |
| B | 200 | 10.3 | | | | | |
Scenario: Matching a large Sell order partially | |
When the following orders are submitted in this order: | |
| Broker | Side | Qty | Price | | |
| E | Sell | 350 | 10.4 | | |
Then the following trades are generated: | |
| Buying broker | Selling broker | Qty | Price | | |
| A | E | 100 | 10.4 | | |
And market order book looks like: | |
| Broker | Qty | Price | Price | Qty | Broker | | |
| B | 200 | 10.3 | 10.4 | 250 | E | | |
| | | | 10.7 | 100 | C | | |
| | | | 10.8 | 200 | D | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment