Skip to content

Commit

Permalink
feat: add test cases for spot markets
Browse files Browse the repository at this point in the history
  • Loading branch information
cdummett committed May 22, 2024
1 parent 87ddbcf commit e6cbccf
Showing 1 changed file with 80 additions and 11 deletions.
91 changes: 80 additions & 11 deletions core/integration/features/verified/pegged_orders.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

Feature: Pegged orders do not cross

Aiming for full coverage of edge-cases, check the following:
Aiming for full coverage of edge-cases, check the following for both
derivative and spot markets:

- Market decimals > asset decimals
- Market decimals < asset decimals
Expand All @@ -22,19 +23,24 @@ Feature: Pegged orders do not cross
And the following assets are registered:
| id | decimal places | quantum |
| ETH.1.10 | 1 | 1 |
| BTC.1.10 | 1 | 1 |
And the following network parameters are set:
| name | value |
| limits.markets.maxPeggedOrders | 6 |
And the parties deposit on asset's general account the following amount:
| party | asset | amount |
| aux1 | ETH.1.10 | 1000000000000 |
| aux2 | ETH.1.10 | 1000000000000 |
| party1 | ETH.1.10 | 1000000000000 |
| party2 | ETH.1.10 | 1000000000000 |
Scenario Outline: # Market decimals > asset decimals
| party | asset | amount |
| aux1 | ETH.1.10 | 1000000000000000 |
| aux2 | ETH.1.10 | 1000000000000000 |
| party1 | ETH.1.10 | 1000000000000000 |
| party2 | ETH.1.10 | 1000000000000000 |
| aux1 | BTC.1.10 | 1000000000000000 |
| aux2 | BTC.1.10 | 1000000000000000 |
| party1 | BTC.1.10 | 1000000000000000 |
| party2 | BTC.1.10 | 1000000000000000 |
Scenario Outline: Derivative markets - market decimals > asset decimals

Given the markets:
| id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | decimal places | tick size |
Expand All @@ -52,7 +58,7 @@ Feature: Pegged orders do not cross
When the opening auction period ends for market "ETH.1.10/DEC21"
Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH.1.10/DEC21"

Examples:
Examples:
| bo | tick size | offset | error |
| 1010 | 1 | 1 | invalid offset - pegged mid will cross |
| 1010 | 1 | 10 | |
Expand All @@ -65,7 +71,7 @@ Feature: Pegged orders do not cross
| 1100 | 100 | 100 | |


Scenario Outline: # Market decimals < asset decimals
Scenario Outline: Derivative markets - market decimals < asset decimals

Given the markets:
| id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | decimal places | tick size |
Expand All @@ -83,7 +89,69 @@ Feature: Pegged orders do not cross
When the opening auction period ends for market "ETH.1.10/DEC21"
Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH.1.10/DEC21"

Examples:
Examples:
| bo | tick size | offset | error |
| 1001 | 1 | 1 | |
| 1001 | 1 | 10 | |
| 1001 | 1 | 100 | |
| 1010 | 10 | 1 | OrderError: price not in tick size |
| 1010 | 10 | 10 | |
| 1010 | 10 | 100 | |
| 1100 | 100 | 1 | OrderError: price not in tick size |
| 1100 | 100 | 10 | OrderError: price not in tick size |
| 1100 | 100 | 100 | |


Scenario Outline: Spot market - market decimals > asset decimals

Given the spot markets:
| id | name | base asset | quote asset | liquidity monitoring | risk model | auction duration | fees | price monitoring | sla params | decimal places | tick size |
| BTC/ETH | BTC/ETH | BTC.1.10 | ETH.1.10 | default-parameters | default-simple-risk-model | 1 | default-none | default-none | default-basic | 2 | <tick size> |
Given the parties place the following pegged orders:
| party | market id | side | pegged reference | volume | offset | reference | error |
| party1 | BTC/ETH | buy | MID | 10 | <offset> | peg-buy | <error> |
| party2 | BTC/ETH | sell | MID | 10 | <offset> | peg-sell | <error> |
And the parties place the following orders:
| party | market id | side | volume | price | resulting trades | type | tif | reference |
| aux1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b1-1 |
| aux1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b1-1 |
| aux2 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b2-1 |
| aux2 | BTC/ETH | sell | 1 | <bo> | 0 | TYPE_LIMIT | TIF_GTC | p3b2-1 |
When the opening auction period ends for market "BTC/ETH"
Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"

Examples:
| bo | tick size | offset | error |
| 1010 | 1 | 1 | invalid offset - pegged mid will cross |
| 1010 | 1 | 10 | |
| 1010 | 1 | 100 | |
| 1010 | 10 | 1 | OrderError: price not in tick size |
| 1010 | 10 | 10 | |
| 1010 | 10 | 100 | |
| 1100 | 100 | 1 | OrderError: price not in tick size |
| 1100 | 100 | 10 | OrderError: price not in tick size |
| 1100 | 100 | 100 | |


Scenario Outline: Spot market - market decimals < asset decimals

Given the spot markets:
| id | name | base asset | quote asset | liquidity monitoring | risk model | auction duration | fees | price monitoring | sla params | decimal places | tick size |
| BTC/ETH | BTC/ETH | BTC.1.10 | ETH.1.10 | default-parameters | default-simple-risk-model | 1 | default-none | default-none | default-basic | 0 | <tick size> |
Given the parties place the following pegged orders:
| party | market id | side | pegged reference | volume | offset | reference | error |
| party1 | BTC/ETH | buy | MID | 10 | <offset> | peg-buy | <error> |
| party2 | BTC/ETH | sell | MID | 10 | <offset> | peg-sell | <error> |
And the parties place the following orders:
| party | market id | side | volume | price | resulting trades | type | tif | reference |
| aux1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b1-1 |
| aux1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b1-1 |
| aux2 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b2-1 |
| aux2 | BTC/ETH | sell | 1 | <bo> | 0 | TYPE_LIMIT | TIF_GTC | p3b2-1 |
When the opening auction period ends for market "BTC/ETH"
Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"

Examples:
| bo | tick size | offset | error |
| 1001 | 1 | 1 | |
| 1001 | 1 | 10 | |
Expand All @@ -94,3 +162,4 @@ Feature: Pegged orders do not cross
| 1100 | 100 | 1 | OrderError: price not in tick size |
| 1100 | 100 | 10 | OrderError: price not in tick size |
| 1100 | 100 | 100 | |

0 comments on commit e6cbccf

Please sign in to comment.