code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/price-monitoring-lognormal.feature (about)

     1  Feature: Price monitoring test using forward risk model (bounds for the valid price moves around price of 100000 for the two horizons are: [99460,100541], [98999,101008])
     2  
     3    Background:
     4      Given time is updated to "2020-10-16T00:00:00Z"
     5      And the price monitoring named "my-price-monitoring":
     6        | horizon | probability | auction extension |
     7        | 60      | 0.95        | 240               |
     8        | 600     | 0.99        | 360               |
     9      And the price monitoring named "my-price-monitoring-2":
    10        | horizon | probability | auction extension |
    11        | 60      | 0.95        | 240               |
    12        | 120     | 0.99        | 360               |
    13      And the log normal risk model named "my-log-normal-risk-model":
    14        | risk aversion | tau                    | mu | r     | sigma |
    15        | 0.000001      | 0.00011407711613050422 | 0  | 0.016 | 2.0   |
    16      And the markets:
    17        | id        | quote name | asset | risk model                    | margin calculator         | auction duration | fees         | price monitoring      | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    18        | ETH/DEC20 | ETH        | ETH   | default-log-normal-risk-model | default-margin-calculator | 60               | default-none | my-price-monitoring   | default-eth-for-future | 0.01                   | 0                         | default-futures |
    19        | ETH/DEC21 | ETH        | ETH   | default-log-normal-risk-model | default-margin-calculator | 60               | default-none | my-price-monitoring-2 | default-eth-for-future | 0.01                   | 0                         | default-futures |
    20      And the following network parameters are set:
    21        | name                           | value |
    22        | market.auction.minimumDuration | 60    |
    23        | limits.markets.maxPeggedOrders | 2     |
    24  
    25    Scenario: Persistent order results in an auction (one trigger breached), no orders placed during auction, auction terminates with a trade from order that originally triggered the auction. (0032-PRIM-006)
    26  
    27      Given the parties deposit on asset's general account the following amount:
    28        | party  | asset | amount       |
    29        | party1 | ETH   | 10000000000  |
    30        | party2 | ETH   | 10000000000  |
    31        | aux    | ETH   | 100000000000 |
    32        | aux2   | ETH   | 100000000000 |
    33        | lpprov | ETH   | 100000000000 |
    34  
    35      When the parties submit the following liquidity provision:
    36        | id  | party  | market id | commitment amount | fee | lp type    |
    37        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    38        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    39      And the parties place the following pegged iceberg orders:
    40        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    41        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    42        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    43  
    44      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    45      When the parties place the following orders:
    46        | party | market id | side | volume | price  | resulting trades | type       | tif     |
    47        | aux   | ETH/DEC20 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
    48        | aux   | ETH/DEC20 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
    49        | aux2  | ETH/DEC20 | buy  | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
    50        | aux   | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
    51      Then the opening auction period ends for market "ETH/DEC20"
    52      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    53      And the mark price should be "110000" for the market "ETH/DEC20"
    54  
    55      #T0 + 10 min
    56      When time is updated to "2020-10-16T00:10:00Z"
    57  
    58      Then the parties place the following orders:
    59        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    60        | party1 | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    61        | party2 | ETH/DEC20 | buy  | 1      | 110000 | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    62  
    63      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    64  
    65      And the mark price should be "110000" for the market "ETH/DEC20"
    66  
    67      #T1 = T0 + 02min10s (auction start)
    68      Then time is updated to "2020-10-16T00:12:10Z"
    69  
    70      When the parties place the following orders:
    71        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    72        | party1 | ETH/DEC20 | sell | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    73        | party2 | ETH/DEC20 | buy  | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    74  
    75      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    76  
    77      And the mark price should be "110000" for the market "ETH/DEC20"
    78  
    79      #T1 + 04min00s (last second of the auction)
    80      Then time is updated to "2020-10-16T00:13:10Z"
    81  
    82      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    83  
    84      #T1 + 04min01s (auction ended)
    85      Then time is updated to "2020-10-16T00:20:11Z"
    86  
    87      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    88  
    89      And the mark price should be "111000" for the market "ETH/DEC20"
    90  
    91    Scenario: Non-persistent order do not result in an auction (one trigger breached) (0032-PRIM-003)
    92  
    93      Given the parties deposit on asset's general account the following amount:
    94        | party  | asset | amount       |
    95        | party1 | ETH   | 10000000000  |
    96        | party2 | ETH   | 10000000000  |
    97        | aux    | ETH   | 100000000000 |
    98        | aux2   | ETH   | 100000000000 |
    99        | lpprov | ETH   | 100000000000 |
   100  
   101      When the parties submit the following liquidity provision:
   102        | id  | party  | market id | commitment amount | fee | lp type    |
   103        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   104        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   105      And the parties place the following pegged iceberg orders:
   106        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   107        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   108        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   109  
   110      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   111      When the parties place the following orders:
   112        | party | market id | side | volume | price  | resulting trades | type       | tif     |
   113        | aux   | ETH/DEC20 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
   114        | aux   | ETH/DEC20 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
   115        | aux2  | ETH/DEC20 | buy  | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   116        | aux   | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   117      Then the opening auction period ends for market "ETH/DEC20"
   118      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   119      And the mark price should be "110000" for the market "ETH/DEC20"
   120  
   121      #T0 + 10 min
   122      When time is updated to "2020-10-16T00:10:00Z"
   123  
   124      Then the parties place the following orders:
   125        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   126        | party1 | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   127        | party2 | ETH/DEC20 | buy  | 1      | 110000 | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   128  
   129      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   130      And the mark price should be "110000" for the market "ETH/DEC20"
   131  
   132      #T1 = T0 + 10s
   133      When time is updated to "2020-10-16T00:10:10Z"
   134  
   135      Then the parties place the following orders:
   136        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference | error                                                       |
   137        | party1 | ETH/DEC20 | sell | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |                                                             |
   138        | party2 | ETH/DEC20 | buy  | 1      | 111000 | 0                | TYPE_LIMIT | TIF_FOK | ref-2     | OrderError: non-persistent order trades out of price bounds |
   139  
   140      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   141      And the mark price should be "110000" for the market "ETH/DEC20"
   142  
   143    Scenario: Non-persistent order results in an auction (one trigger breached), orders placed during auction result in trade with indicative price outside the price monitoring bounds, hence auction get extended, additional orders resulting in more trades placed, auction concludes. (0032-PRIM-008)
   144  
   145      Given the parties deposit on asset's general account the following amount:
   146        | party  | asset | amount       |
   147        | party1 | ETH   | 10000000000  |
   148        | party2 | ETH   | 10000000000  |
   149        | aux    | ETH   | 100000000000 |
   150        | aux2   | ETH   | 100000000000 |
   151        | lpprov | ETH   | 100000000000 |
   152  
   153      When the parties submit the following liquidity provision:
   154        | id  | party  | market id | commitment amount | fee | lp type    |
   155        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   156        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   157      And the parties place the following pegged iceberg orders:
   158        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   159        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   160        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   161  
   162      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   163      When the parties place the following orders:
   164        | party | market id | side | volume | price  | resulting trades | type       | tif     |
   165        | aux   | ETH/DEC20 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
   166        | aux   | ETH/DEC20 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
   167        | aux2  | ETH/DEC20 | buy  | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   168        | aux   | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   169      Then the opening auction period ends for market "ETH/DEC20"
   170      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   171      And the mark price should be "110000" for the market "ETH/DEC20"
   172  
   173      #T0 + 2 min (end of auction)
   174      When time is updated to "2020-10-16T00:02:00Z"
   175  
   176      Then the parties place the following orders:
   177        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   178        | party1 | ETH/DEC20 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   179        | party2 | ETH/DEC20 | buy  | 1      | 110000 | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   180  
   181      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   182  
   183      And the mark price should be "110000" for the market "ETH/DEC20"
   184  
   185      #T1 = T0 + 10s
   186      When time is updated to "2020-10-16T00:02:10Z"
   187  
   188      Then the parties place the following orders:
   189        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   190        | party1 | ETH/DEC20 | sell | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   191        | party2 | ETH/DEC20 | buy  | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   192  
   193      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   194  
   195      And the mark price should be "110000" for the market "ETH/DEC20"
   196  
   197      #T1 + 04min00s (last second of the auction)
   198      When time is updated to "2020-10-16T00:03:10Z"
   199  
   200      Then the parties place the following orders:
   201        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   202        | party1 | ETH/DEC20 | sell | 2      | 133000 | 0                | TYPE_LIMIT | TIF_GFA | ref-1     |
   203        | party2 | ETH/DEC20 | buy  | 2      | 133000 | 0                | TYPE_LIMIT | TIF_GFA | ref-2     |
   204  
   205      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   206  
   207      #T1 + 04min01s (auction extended due to 2nd trigger)
   208      When time is updated to "2020-10-16T00:06:11Z"
   209  
   210      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   211  
   212      And the mark price should be "110000" for the market "ETH/DEC20"
   213  
   214      #T1 + 10min00s (last second of the extended auction)
   215      When time is updated to "2020-10-16T00:08:11Z"
   216      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   217  
   218      Then the parties place the following orders:
   219        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference  |
   220        | party1 | ETH/DEC20 | sell | 10     | 303000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1      |
   221        | party2 | ETH/DEC20 | buy  | 10     | 303000 | 0                | TYPE_LIMIT | TIF_GFA | ref-2-last |
   222  
   223      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   224  
   225      And the mark price should be "110000" for the market "ETH/DEC20"
   226  
   227      #T1 + 10min01s (extended auction finished) // this is not finished, not order left in the book.
   228      Then time is updated to "2020-10-16T00:12:11Z"
   229  
   230      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   231  
   232      And the mark price should be "303000" for the market "ETH/DEC20"
   233  
   234    Scenario: Start with high first indicative uncrossing price and much lower final auction price
   235      Given the parties deposit on asset's general account the following amount:
   236        | party  | asset | amount       |
   237        | party1 | ETH   | 10000000000  |
   238        | party2 | ETH   | 10000000000  |
   239        | aux    | ETH   | 100000000000 |
   240        | aux2   | ETH   | 100000000000 |
   241        | lpprov | ETH   | 100000000000 |
   242  
   243      When the parties submit the following liquidity provision:
   244        | id  | party  | market id | commitment amount | fee | lp type    |
   245        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   246        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   247      And the parties place the following pegged iceberg orders:
   248        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   249        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   250        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   251  
   252      When the parties place the following orders:
   253        | party | market id | side | volume | price   | resulting trades | type       | tif     |
   254        | aux   | ETH/DEC20 | buy  | 1      | 1       | 0                | TYPE_LIMIT | TIF_GTC |
   255        | aux   | ETH/DEC20 | sell | 1      | 200000  | 0                | TYPE_LIMIT | TIF_GTC |
   256        | aux2  | ETH/DEC20 | buy  | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GTC |
   257        | aux   | ETH/DEC20 | sell | 1      | 1000000 | 0                | TYPE_LIMIT | TIF_GTC |
   258  
   259      Then the network moves ahead "59" blocks
   260      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20"
   261  
   262      When the parties place the following orders:
   263        | party | market id | side | volume | price | resulting trades | type       | tif     |
   264        | aux2  | ETH/DEC20 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   265        | aux   | ETH/DEC20 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   266  
   267      Then the opening auction period ends for market "ETH/DEC20"
   268  
   269      And the market data for the market "ETH/DEC20" should be:
   270        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   271        | 1000       | TRADING_MODE_CONTINUOUS | 60      | 995       | 1005      | 7434         | 90000000       | 10            |
   272        | 1000       | TRADING_MODE_CONTINUOUS | 600     | 978       | 1022      | 7434         | 90000000       | 10            |
   273  
   274    Scenario: Start with low first indicative uncrossing price and much higher final auction price
   275      Given the parties deposit on asset's general account the following amount:
   276        | party  | asset | amount       |
   277        | party1 | ETH   | 10000000000  |
   278        | party2 | ETH   | 10000000000  |
   279        | aux    | ETH   | 100000000000 |
   280        | aux2   | ETH   | 100000000000 |
   281        | lpprov | ETH   | 100000000000 |
   282  
   283      When the parties submit the following liquidity provision:
   284        | id  | party  | market id | commitment amount | fee | lp type    |
   285        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   286        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   287      And the parties place the following pegged iceberg orders:
   288        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   289        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   290        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   291  
   292      When the parties place the following orders:
   293        | party | market id | side | volume | price  | resulting trades | type       | tif     |
   294        | aux   | ETH/DEC20 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
   295        | aux   | ETH/DEC20 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
   296        | aux2  | ETH/DEC20 | buy  | 1      | 1000   | 0                | TYPE_LIMIT | TIF_GTC |
   297        | aux   | ETH/DEC20 | sell | 1      | 1000   | 0                | TYPE_LIMIT | TIF_GTC |
   298  
   299      Then the network moves ahead "59" blocks
   300      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20"
   301  
   302      When the parties place the following orders:
   303        | party | market id | side | volume | price   | resulting trades | type       | tif     |
   304        | aux2  | ETH/DEC20 | buy  | 10     | 1000000 | 0                | TYPE_LIMIT | TIF_GTC |
   305        | aux   | ETH/DEC20 | sell | 10     | 1000000 | 0                | TYPE_LIMIT | TIF_GTC |
   306  
   307      Then the opening auction period ends for market "ETH/DEC20"
   308  
   309      And the market data for the market "ETH/DEC20" should be:
   310        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   311        | 1000000    | TRADING_MODE_CONTINUOUS | 60      | 994606    | 1005415   | 7434000      | 90000000       | 10            |
   312        | 1000000    | TRADING_MODE_CONTINUOUS | 600     | 977751    | 1022678   | 7434000      | 90000000       | 10            |
   313  
   314    Scenario: Non-persistent order results in an auction (one trigger breached), orders placed during auction result in trade with indicative price outside the price monitoring bounds, but auction extension is longer than horizon of the 2nd trigger, hence it gets deactivated and auction concludes immediately. (0032-PRIM-009)
   315      Given the parties deposit on asset's general account the following amount:
   316        | party  | asset | amount       |
   317        | party1 | ETH   | 10000000000  |
   318        | party2 | ETH   | 10000000000  |
   319        | aux    | ETH   | 100000000000 |
   320        | aux2   | ETH   | 100000000000 |
   321        | lpprov | ETH   | 100000000000 |
   322  
   323      When the parties submit the following liquidity provision:
   324        | id  | party  | market id | commitment amount | fee | lp type    |
   325        | lp1 | lpprov | ETH/DEC21 | 90000000          | 0.1 | submission |
   326        | lp1 | lpprov | ETH/DEC21 | 90000000          | 0.1 | submission |
   327      And the parties place the following pegged iceberg orders:
   328        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   329        | lpprov | ETH/DEC21 | 2         | 1                    | buy  | BID              | 50         | 100    |
   330        | lpprov | ETH/DEC21 | 2         | 1                    | sell | ASK              | 50         | 100    |
   331   
   332      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   333      When the parties place the following orders:
   334        | party | market id | side | volume | price  | resulting trades | type       | tif     |
   335        | aux   | ETH/DEC21 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
   336        | aux   | ETH/DEC21 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
   337        | aux2  | ETH/DEC21 | buy  | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   338        | aux   | ETH/DEC21 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC |
   339      Then the opening auction period ends for market "ETH/DEC21"
   340      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21"
   341      And the mark price should be "110000" for the market "ETH/DEC21"
   342  
   343      #T0 + 2 min (end of auction)
   344      When time is updated to "2020-10-16T00:02:00Z"
   345  
   346      Then the parties place the following orders:
   347        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   348        | party1 | ETH/DEC21 | sell | 1      | 110000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   349        | party2 | ETH/DEC21 | buy  | 1      | 110000 | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   350  
   351      And the market data for the market "ETH/DEC21" should be:
   352        | trading mode            | auction trigger             | extension trigger           | mark price | indicative price | indicative volume |
   353        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 110000     | 0                | 0                 |
   354  
   355      #T1 = T0 + 10s
   356      When time is updated to "2020-10-16T00:02:10Z"
   357  
   358      Then the parties place the following orders:
   359        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   360        | party1 | ETH/DEC21 | sell | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   361        | party2 | ETH/DEC21 | buy  | 1      | 111000 | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   362  
   363      And the market data for the market "ETH/DEC21" should be:
   364        | trading mode                    | auction trigger       | extension trigger           | mark price | indicative price | indicative volume | auction end |
   365        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 110000     | 111000           | 1                 | 240         |
   366  
   367      #T1 + 04min00s (last second of the auction)
   368      When time is updated to "2020-10-16T00:03:10Z"
   369  
   370      Then the parties place the following orders:
   371        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   372        | party1 | ETH/DEC21 | sell | 2      | 133000 | 0                | TYPE_LIMIT | TIF_GFA | ref-1     |
   373        | party2 | ETH/DEC21 | buy  | 2      | 133000 | 0                | TYPE_LIMIT | TIF_GFA | ref-2     |
   374  
   375      And the market data for the market "ETH/DEC21" should be:
   376        | trading mode                    | auction trigger       | extension trigger           | mark price | indicative price | indicative volume | auction end | horizon | ref price | min bound | max bound |
   377        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 110000     | 133000           | 2                 | 240         | 120     | 110000    | 108900    | 111109    |
   378  
   379      #T1 + 04min01s (auction gets extended as we've removed trigger staleness functionality)
   380      When time is updated to "2020-10-16T00:06:11Z"
   381  
   382      And the market data for the market "ETH/DEC21" should be:
   383        | trading mode                    | auction trigger       | extension trigger     | mark price | indicative price | indicative volume | auction end |
   384        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_PRICE | 110000     | 133000           | 2                 | 600         |
   385  
   386      #T1 + 10min01s 
   387      When time is updated to "2020-10-16T00:12:11Z"
   388      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21"
   389  
   390      And the mark price should be "133000" for the market "ETH/DEC21"
   391  
   392      And the market data for the market "ETH/DEC21" should be:
   393        | horizon | ref price | min bound | max bound |
   394        |  60     | 133000    | 132283    | 133720    |
   395        | 120     | 133000    | 131670    | 134341    |
   396  
   397      Scenario: Non-persistent order results in no trades. Persistent order which results in an n-th trade breaching the trigger and causing auction - all previous n-1 trades get executed.
   398      Given the parties deposit on asset's general account the following amount:
   399        | party  | asset | amount       |
   400        | party1 | ETH   | 10000000000  |
   401        | party2 | ETH   | 10000000000  |
   402        | aux    | ETH   | 100000000000 |
   403        | aux2   | ETH   | 100000000000 |
   404  
   405      And the parties place the following orders:
   406        | party | market id | side | volume | price  | resulting trades | type       | tif     |
   407        | aux   | ETH/DEC21 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |
   408        | aux   | ETH/DEC21 | sell | 1      | 200000 | 0                | TYPE_LIMIT | TIF_GTC |
   409        | aux2  | ETH/DEC21 | buy  | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |
   410        | aux   | ETH/DEC21 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |
   411      And the opening auction period ends for market "ETH/DEC21"
   412      Then the market data for the market "ETH/DEC21" should be:
   413        | mark price | trading mode            | horizon | min bound | max bound |
   414        | 100000     | TRADING_MODE_CONTINUOUS | 60      | 99461     | 100541    |
   415        | 100000     | TRADING_MODE_CONTINUOUS | 120     | 99000     | 101008    |
   416     
   417      When the parties place the following orders with ticks:
   418        | party    | market id | side | volume | price  | resulting trades | type       | tif     | error                                                       |
   419        | aux      | ETH/DEC21 | sell | 3      | 100540 | 0                | TYPE_LIMIT | TIF_GTC |                                                             |
   420        | aux2     | ETH/DEC21 | sell | 2      | 100541 | 0                | TYPE_LIMIT | TIF_GTC |                                                             |
   421        | party1   | ETH/DEC21 | sell | 1      | 100542 | 0                | TYPE_LIMIT | TIF_GTC |                                                             |
   422        | party2   | ETH/DEC21 | buy  | 10     | 100543 | 0                | TYPE_LIMIT | TIF_IOC | OrderError: non-persistent order trades out of price bounds |
   423      Then the market data for the market "ETH/DEC21" should be:
   424        | mark price | trading mode            | horizon | min bound | max bound |
   425        | 100000     | TRADING_MODE_CONTINUOUS | 60      | 99461     | 100541    |
   426        | 100000     | TRADING_MODE_CONTINUOUS | 120     | 99000     | 101008    |
   427  
   428      When the parties place the following orders with ticks:
   429        | party    | market id | side | volume | price  | resulting trades | type       | tif     |
   430        | party2   | ETH/DEC21 | buy  | 10     | 100543 | 0                | TYPE_LIMIT | TIF_GTC |
   431      Then the market data for the market "ETH/DEC21" should be:
   432        | mark price | trading mode                    | auction trigger       | horizon | min bound | max bound |
   433        | 100000     | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 120     | 99000     | 101008    |
   434      And the parties should have the following profit and loss:
   435        | party  | volume | unrealised pnl | realised pnl |
   436        | party2 | 0      | 0              | 0            |