code.vegaprotocol.io/vega@v0.79.0/core/integration/features/auctions/opening-auction-uncross.feature (about)

     1  Feature: Set up a market, with an opening auction, then uncross the book
     2  
     3    Background:
     4  
     5      Given the markets:
     6        | id        | quote name | asset | risk model                  | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
     7        | ETH/DEC19 | BTC        | BTC   | default-simple-risk-model-4 | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures |
     8      And the parties deposit on asset's general account the following amount:
     9        | party  | asset | amount    |
    10        | party1 | BTC   | 100000000 |
    11        | party2 | BTC   | 100000000 |
    12        | party3 | BTC   | 100000000 |
    13        | party4 | BTC   | 100000000 |
    14        | party5 | BTC   | 1         |
    15        | lpprov | BTC   | 100000000 |
    16      And the following network parameters are set:
    17        | name                                    | value |
    18        | limits.markets.maxPeggedOrders          | 2     |
    19  
    20    Scenario: set up 2 parties with balance
    21      When the parties place the following orders:
    22        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    23        | party3 | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | t3-b-1    |
    24        | party4 | ETH/DEC19 | sell | 1      | 11000 | 0                | TYPE_LIMIT | TIF_GTC | t4-s-1    |
    25        | party1 | ETH/DEC19 | buy  | 5      | 10000 | 0                | TYPE_LIMIT | TIF_GFA | t1-b-1    |
    26        | party2 | ETH/DEC19 | sell | 5      | 10000 | 0                | TYPE_LIMIT | TIF_GFA | t2-s-1    |
    27        | party1 | ETH/DEC19 | buy  | 5      | 10000 | 0                | TYPE_LIMIT | TIF_GFA | t1-b-2    |
    28        | party2 | ETH/DEC19 | sell | 5      | 10001 | 0                | TYPE_LIMIT | TIF_GFA | t2-s-2    |
    29        | party1 | ETH/DEC19 | buy  | 4      | 3000  | 0                | TYPE_LIMIT | TIF_GFA | t1-b-3    |
    30        | party2 | ETH/DEC19 | sell | 3      | 3000  | 0                | TYPE_LIMIT | TIF_GFA | t2-s-3    |
    31      And the parties submit the following liquidity provision:
    32        | id  | party  | market id | commitment amount | fee | lp type    |
    33        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    34        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    35      And the parties place the following pegged iceberg orders:
    36        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    37        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | MID              | 50         | 100    |
    38        | lpprov | ETH/DEC19 | 2         | 1                    | sell | MID              | 50         | 100    |
    39      Then the parties should have the following margin levels:
    40        | party  | market id | maintenance |
    41        | party1 | ETH/DEC19 | 14000       |
    42        | party2 | ETH/DEC19 | 13000       |
    43      Then the parties should have the following account balances:
    44        | party  | asset | market id | margin | general  |
    45        | party1 | BTC   | ETH/DEC19 | 16800  | 99983200 |
    46        | party2 | BTC   | ETH/DEC19 | 15600  | 99984400 |
    47      When the parties withdraw the following assets:
    48        | party  | asset | amount   |
    49        | party1 | BTC   | 99949760 |
    50        | party2 | BTC   | 99951320 |
    51      Then the parties should have the following account balances:
    52        | party  | asset | market id | margin | general |
    53        | party1 | BTC   | ETH/DEC19 | 16800  | 33440   |
    54        | party2 | BTC   | ETH/DEC19 | 15600  | 33080   |
    55      Then the opening auction period ends for market "ETH/DEC19"
    56      And the following trades should be executed:
    57        | buyer  | price | size | seller |
    58        | party1 | 10000 | 3    | party2 |
    59        | party1 | 10000 | 2    | party2 |
    60        | party1 | 10000 | 3    | party2 |
    61      And the mark price should be "10000" for the market "ETH/DEC19"
    62      When the network moves ahead "1" blocks
    63      Then the orders should have the following status:
    64        | party  | reference | status           |
    65        | party1 | t1-b-1    | STATUS_FILLED    |
    66        | party2 | t2-s-1    | STATUS_FILLED    |
    67        | party1 | t1-b-2    | STATUS_CANCELLED |
    68        | party2 | t2-s-2    | STATUS_CANCELLED |
    69        | party1 | t1-b-3    | STATUS_CANCELLED |
    70        | party2 | t2-s-3    | STATUS_FILLED    |
    71      Then the parties should have the following account balances:
    72        | party  | asset | market id | margin | general |
    73        | party2 | BTC   | ETH/DEC19 | 33600  | 15080   |
    74        | party1 | BTC   | ETH/DEC19 | 33600  | 16640   |
    75  
    76    Scenario: Uncross auction via order amendment
    77      When the parties place the following orders:
    78        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    79        | party3 | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | t3-b-1    |
    80        | party4 | ETH/DEC19 | sell | 1      | 11000 | 0                | TYPE_LIMIT | TIF_GTC | t4-s-1    |
    81        | party1 | ETH/DEC19 | buy  | 5      | 9999  | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
    82        | party2 | ETH/DEC19 | sell | 5      | 10000 | 0                | TYPE_LIMIT | TIF_GFA | t2-s-1    |
    83      And the parties submit the following liquidity provision:
    84        | id  | party  | market id | commitment amount | fee | lp type    |
    85        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    86        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    87      And the parties place the following pegged iceberg orders:
    88        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    89        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | MID              | 50         | 100    |
    90        | lpprov | ETH/DEC19 | 2         | 1                    | sell | MID              | 50         | 100    |
    91      Then the network moves ahead "2" blocks
    92      And the parties amend the following orders:
    93        | party  | reference | price | size delta | tif     |
    94        | party1 | t1-b-1    | 10000 | 2          | TIF_GTC |
    95  
    96      Then the opening auction period ends for market "ETH/DEC19"
    97      And the market data for the market "ETH/DEC19" should be:
    98        | trading mode            | auction trigger             |
    99        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
   100      And the mark price should be "10000" for the market "ETH/DEC19"
   101      And the following trades should be executed:
   102        | buyer  | price | size | seller |
   103        | party1 | 10000 | 5    | party2 |
   104   
   105    Scenario: Party cannot afford pegged orders upon uncrossing so they get stopped
   106      Given the following network parameters are set:
   107        | name                                                | value |
   108        | limits.markets.maxPeggedOrders                      | 10    | 
   109      When the parties place the following pegged orders:
   110        | party  | market id | side | volume | pegged reference | offset |
   111        | party4 | ETH/DEC19 | buy  | 100000 | BID              | 1      |
   112        | party4 | ETH/DEC19 | buy  | 100000 | MID              | 1      |
   113        | party5 | ETH/DEC19 | sell | 100000 | ASK              | 1      |
   114        | party5 | ETH/DEC19 | sell | 100000 | MID              | 1      |
   115      And the parties place the following orders:
   116        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   117        | party3 | ETH/DEC19 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC |
   118        | party4 | ETH/DEC19 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
   119        | party1 | ETH/DEC19 | buy  | 5      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   120        | party2 | ETH/DEC19 | sell | 5      | 1000  | 0                | TYPE_LIMIT | TIF_GFA |
   121      And the parties submit the following liquidity provision:
   122        | id  | party  | market id | commitment amount | fee | lp type    |
   123        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   124        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   125      And the parties place the following pegged iceberg orders:
   126        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference |
   127        | lpprov | ETH/DEC19 | 100       | 1                    | buy  | MID              | 100    | 100    | ice-buy   |
   128        | lpprov | ETH/DEC19 | 82        | 82                   | sell | MID              | 86     | 100    | ice-sell  |
   129      Then the pegged orders should have the following states:
   130        | party  | market id | side | volume | reference | offset | price | status        |
   131        | party4 | ETH/DEC19 | buy  | 100000 | BID       | 1      | 0     | STATUS_PARKED |
   132        | party4 | ETH/DEC19 | buy  | 100000 | MID       | 1      | 0     | STATUS_PARKED |
   133        | party5 | ETH/DEC19 | sell | 100000 | ASK       | 1      | 0     | STATUS_PARKED |
   134        | party5 | ETH/DEC19 | sell | 100000 | MID       | 1      | 0     | STATUS_PARKED |
   135      
   136      When the opening auction period ends for market "ETH/DEC19"
   137      Then the market data for the market "ETH/DEC19" should be:
   138        | mark price | trading mode            | auction trigger             |
   139        | 1000       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
   140      And the pegged orders should have the following states:
   141        | party  | market id | side | volume | reference | offset | price | status           |
   142        | party4 | ETH/DEC19 | buy  | 100000 | BID       | 1      | 899   | STATUS_ACTIVE    |
   143        | party4 | ETH/DEC19 | buy  | 100000 | MID       | 1      | 999   | STATUS_ACTIVE    |
   144        | party5 | ETH/DEC19 | sell | 100000 | ASK       | 1      | 1101  | STATUS_CANCELLED |
   145        | party5 | ETH/DEC19 | sell | 100000 | MID       | 1      | 1001  | STATUS_CANCELLED |
   146      And the order book should have the following volumes for market "ETH/DEC19":
   147        | side | price | volume |
   148        | sell | 1101  |      0 |
   149        | sell | 1100  |     83 |
   150        | sell | 1001  |      0 |
   151        | buy  | 999   | 100000 |
   152        | buy  | 900   |    101 |
   153        | buy  | 899   | 100000 |
   154      
   155      # Move the best bid and assure the orders don't resurrect
   156      When the parties place the following orders with ticks:
   157        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   158        | party3 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   159      And the parties cancel the following orders:
   160        | party  | reference |
   161        | lpprov | ice-sell  |
   162        | lpprov | ice-buy   |
   163      And the parties place the following pegged iceberg orders:
   164        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   165        | lpprov | ETH/DEC19 | 86        | 86                   | sell | MID              | 86     | 100    |
   166        | lpprov | ETH/DEC19 | 106       | 1                    | buy  | MID              | 106    | 100    |
   167      Then the network moves ahead "3" blocks
   168      Then the pegged orders should have the following states:
   169        | party  | market id | side | volume | reference | offset | price | status           |
   170        | lpprov | ETH/DEC19 | buy  | 100    | MID       | 100    | 850   | STATUS_ACTIVE    |
   171        | lpprov | ETH/DEC19 | sell | 86     | MID       | 100    | 1050  | STATUS_ACTIVE    |
   172        | party4 | ETH/DEC19 | buy  | 100000 | BID       | 1      | 899   | STATUS_ACTIVE    |
   173        | party4 | ETH/DEC19 | buy  | 100000 | MID       | 1      | 949   | STATUS_ACTIVE    |
   174        | party5 | ETH/DEC19 | sell | 100000 | ASK       | 1      | 1101  | STATUS_CANCELLED |
   175        | party5 | ETH/DEC19 | sell | 100000 | MID       | 1      | 1001  | STATUS_CANCELLED |
   176      And the order book should have the following volumes for market "ETH/DEC19":
   177        | side | price | volume |
   178        | sell | 1101  |      0 |
   179        | sell | 1100  |      1 |
   180        | sell | 1050  |     86 |
   181        | sell | 1001  |      0 |
   182        | sell | 1000  |      1 |
   183        | sell | 999   |      0 |
   184        | sell | 951   |      0 |
   185        | buy  | 999   |      0 |
   186        | buy  | 949   | 100000 |
   187        | buy  | 900   |      1 |
   188        | buy  | 899   | 100000 |
   189        | buy  | 850   |    106 |
   190  
   191  Scenario: max volume doesn't come from best bid and ask only
   192      When the parties place the following orders:
   193        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   194        | party1 | ETH/DEC19 | buy  | 2      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   195        | party2 | ETH/DEC19 | sell | 2      |  1    | 0                | TYPE_LIMIT | TIF_GTC |
   196        | party3 | ETH/DEC19 | buy  | 3      | 90    | 0                | TYPE_LIMIT | TIF_GTC |
   197        | party4 | ETH/DEC19 | sell | 3      |  7    | 0                | TYPE_LIMIT | TIF_GTC |
   198      Then the market data for the market "ETH/DEC19" should be:
   199        | indicative price | indicative volume |
   200        | 48               | 5                 |
   201      
   202      When the opening auction period ends for market "ETH/DEC19"
   203      Then the market data for the market "ETH/DEC19" should be:
   204        | mark price | open interest |
   205        | 48         | 5             |