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

     1  Feature: Price monitoring test using simple risk model
     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 simple risk model named "my-simple-risk-model":
    10        | long | short | max move up | min move down | probability of trading |
    11        | 0.11 | 0.1   | 10          | 11            | 0.1                    |
    12      And the markets:
    13        | id        | quote name | asset | auction duration | risk model           | margin calculator         | fees         | price monitoring    | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    14        | ETH/DEC20 | ETH        | ETH   | 240              | my-simple-risk-model | default-margin-calculator | default-none | my-price-monitoring | default-eth-for-future | 0.01                   | 0                         | default-futures |
    15      And the following network parameters are set:
    16        | name                                    | value |
    17        | market.auction.minimumDuration          | 240   |
    18        | network.markPriceUpdateMaximumFrequency | 0s    |
    19        | limits.markets.maxPeggedOrders          | 2     |
    20  
    21    Scenario: Persistent order results in an auction (both triggers breached), no orders placed during auction, auction terminates with a trade from order that originally triggered the auction.
    22      Given the parties deposit on asset's general account the following amount:
    23        | party  | asset | amount       |
    24        | party1 | ETH   | 10000        |
    25        | party2 | ETH   | 10000        |
    26        | aux    | ETH   | 100000000000 |
    27        | aux2   | ETH   | 100000000000 |
    28        | lpprov | ETH   | 100000000000 |
    29  
    30      When the parties submit the following liquidity provision:
    31        | id  | party  | market id | commitment amount | fee | lp type    |
    32        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    33        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    34      And the parties place the following pegged iceberg orders:
    35        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    36        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    37        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    38  
    39      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    40      Then the parties place the following orders:
    41        | party | market id | side | volume | price | resulting trades | type       | tif     |
    42        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
    43        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
    44        | aux2  | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
    45        | aux   | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
    46      Then the opening auction period ends for market "ETH/DEC20"
    47      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    48      And the mark price should be "100" for the market "ETH/DEC20"
    49      And time is updated to "2020-10-16T00:10:00Z"
    50  
    51      When the parties place the following orders:
    52        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    53        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    54        | party2 | ETH/DEC20 | buy  | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    55  
    56      And the mark price should be "100" for the market "ETH/DEC20"
    57  
    58      When the parties place the following orders:
    59        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    60        | party1 | ETH/DEC20 | sell | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    61        | party2 | ETH/DEC20 | buy  | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    62  
    63      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    64  
    65      And the mark price should be "100" for the market "ETH/DEC20"
    66  
    67      #T0 + 10min
    68      Then time is updated to "2020-10-16T00:20:00Z"
    69  
    70      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    71  
    72      #T0 + 10min01s
    73      Then time is updated to "2020-10-16T00:20:01Z"
    74  
    75      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    76  
    77      And the mark price should be "111" for the market "ETH/DEC20"
    78  
    79    Scenario: GFN orders don't result in auction
    80      Given the parties deposit on asset's general account the following amount:
    81        | party  | asset | amount       |
    82        | party1 | ETH   | 10000        |
    83        | party2 | ETH   | 10000        |
    84        | aux    | ETH   | 100000000000 |
    85        | aux2   | ETH   | 100000000000 |
    86        | lpprov | ETH   | 100000000000 |
    87  
    88      When the parties submit the following liquidity provision:
    89        | id  | party  | market id | commitment amount | fee | lp type    |
    90        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    91        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    92      And the parties place the following pegged iceberg orders:
    93        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    94        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    95        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    96  
    97      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    98      Then the parties place the following orders:
    99        | party | market id | side | volume | price | resulting trades | type       | tif     |
   100        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   101        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   102        | aux2  | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   103        | aux   | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   104      Then the opening auction period ends for market "ETH/DEC20"
   105      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   106      And the mark price should be "100" for the market "ETH/DEC20"
   107  
   108      When the parties place the following orders:
   109        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   110        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   111        | party2 | ETH/DEC20 | buy  | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   112  
   113      And the mark price should be "100" for the market "ETH/DEC20"
   114  
   115      When the parties place the following orders:
   116        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   117        | party1 | ETH/DEC20 | sell | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   118  
   119      When the parties place the following orders:
   120        | party  | market id | side | volume | price | type       | tif     | reference | error                                                       |
   121        | party2 | ETH/DEC20 | buy  | 1      | 111   | TYPE_LIMIT | TIF_GFN | ref-1     | OrderError: non-persistent order trades out of price bounds |
   122      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   123  
   124    Scenario: Non-persistent order results in an auction (both triggers breached), orders placed during auction result in a trade with indicative price within the price monitoring bounds, hence auction concludes.
   125  
   126      Given the parties deposit on asset's general account the following amount:
   127        | party  | asset | amount       |
   128        | party1 | ETH   | 10000        |
   129        | party2 | ETH   | 10000        |
   130        | aux    | ETH   | 100000000000 |
   131        | aux2   | ETH   | 100000000000 |
   132        | lpprov | ETH   | 100000000000 |
   133  
   134      When the parties submit the following liquidity provision:
   135        | id  | party  | market id | commitment amount | fee | lp type    |
   136        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   137        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   138      And the parties place the following pegged iceberg orders:
   139        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   140        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   141        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   142  
   143      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   144      Then the parties place the following orders:
   145        | party | market id | side | volume | price | resulting trades | type       | tif     |
   146        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   147        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   148        | aux2  | ETH/DEC20 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   149        | aux   | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   150      Then the opening auction period ends for market "ETH/DEC20"
   151      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   152      And the mark price should be "100" for the market "ETH/DEC20"
   153      Then time is updated to "2020-10-16T00:10:00Z"
   154  
   155      When the parties place the following orders:
   156        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   157        | party1 | ETH/DEC20 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   158        | party2 | ETH/DEC20 | buy  | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   159  
   160      And the mark price should be "100" for the market "ETH/DEC20"
   161  
   162      When the parties place the following orders:
   163        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   164        | party1 | ETH/DEC20 | sell | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   165        | party2 | ETH/DEC20 | buy  | 1      | 111   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   166  
   167      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   168  
   169      And the mark price should be "100" for the market "ETH/DEC20"
   170  
   171      When the parties place the following orders:
   172        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   173        | party2 | ETH/DEC20 | buy  | 1      | 112   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   174  
   175      #T0 + 10min
   176      Then time is updated to "2020-10-16T00:20:00Z"
   177  
   178      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   179  
   180      And the mark price should be "100" for the market "ETH/DEC20"
   181  
   182      #T0 + 10min01s
   183      Then time is updated to "2020-10-16T00:20:01Z"
   184  
   185      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   186  
   187      And the mark price should be "111" for the market "ETH/DEC20"
   188  
   189    Scenario: Persistent order results in an auction (one trigger breached), no orders placed during auction, auction gets extended due to 2nd trigger and eventually terminates with a trade from order that originally triggered the auction.
   190  
   191      Given the parties deposit on asset's general account the following amount:
   192        | party  | asset | amount       |
   193        | party1 | ETH   | 10000        |
   194        | party2 | ETH   | 10000        |
   195        | aux    | ETH   | 100000000000 |
   196        | aux2   | ETH   | 100000000000 |
   197        | lpprov | ETH   | 100000000000 |
   198  
   199      When the parties submit the following liquidity provision:
   200        | id  | party  | market id | commitment amount | fee | lp type    |
   201        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   202        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   203      And the parties place the following pegged iceberg orders:
   204        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   205        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   206        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   207  
   208      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   209      Then the parties place the following orders:
   210        | party | market id | side | volume | price | resulting trades | type       | tif     |
   211        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   212        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   213        | aux2  | ETH/DEC20 | buy  | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   214        | aux   | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   215      Then the opening auction period ends for market "ETH/DEC20"
   216      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   217      And the mark price should be "110" for the market "ETH/DEC20"
   218  
   219      When the parties place the following orders:
   220        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   221        | party1 | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   222        | party2 | ETH/DEC20 | buy  | 1      | 110   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   223  
   224      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   225  
   226      And the mark price should be "110" for the market "ETH/DEC20"
   227  
   228      #T0 + 10s
   229      Then time is updated to "2020-10-16T00:08:10Z"
   230  
   231      When the parties place the following orders:
   232        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   233        | party1 | ETH/DEC20 | sell | 1      | 115   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   234        | party2 | ETH/DEC20 | buy  | 1      | 115   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   235  
   236      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   237  
   238      Then the market data for the market "ETH/DEC20" should be:
   239        | mark price | last traded price | trading mode            |
   240        | 110        | 115               | TRADING_MODE_CONTINUOUS |
   241  
   242  
   243      #T0 + 01min10s
   244      Then time is updated to "2020-10-16T00:09:10Z"
   245  
   246      When the parties place the following orders:
   247        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   248        | party1 | ETH/DEC20 | sell | 1      | 105   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   249        | party2 | ETH/DEC20 | buy  | 1      | 105   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   250  
   251      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   252  
   253      Then the market data for the market "ETH/DEC20" should be:
   254        | mark price | last traded price | trading mode            |
   255        | 115        | 105               | TRADING_MODE_CONTINUOUS |
   256  
   257      #T1 = T0 + 02min10s (auction start)
   258      Then time is updated to "2020-10-16T00:10:10Z"
   259  
   260      When the parties place the following orders:
   261        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   262        | party1 | ETH/DEC20 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   263        | party2 | ETH/DEC20 | buy  | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   264  
   265      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   266  
   267      And the mark price should be "105" for the market "ETH/DEC20"
   268  
   269      #T1 + 04min00s (last second of the initial auction)
   270      Then time is updated to "2020-10-16T00:14:10Z"
   271  
   272      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   273  
   274      #T1 + 04min01s (auction extended due to 2nd trigger)
   275      Then time is updated to "2020-10-16T00:14:11Z"
   276  
   277      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   278  
   279      And the mark price should be "105" for the market "ETH/DEC20"
   280  
   281      #T1 + 10min00s (last second of the extended auction)
   282      Then time is updated to "2020-10-16T00:20:10Z"
   283  
   284      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   285  
   286      And the mark price should be "105" for the market "ETH/DEC20"
   287  
   288      #T1 + 10min01s (extended auction finished)
   289      Then time is updated to "2020-10-16T00:20:11Z"
   290  
   291      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   292  
   293      And the mark price should be "120" for the market "ETH/DEC20"
   294  
   295    Scenario: Persistent order results in an auction (both triggers breached), no orders placed during auction and auction terminates
   296  
   297      Given the parties deposit on asset's general account the following amount:
   298        | party  | asset | amount       |
   299        | party1 | ETH   | 10000        |
   300        | party2 | ETH   | 10000        |
   301        | aux    | ETH   | 100000000000 |
   302        | aux2   | ETH   | 100000000000 |
   303  
   304      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   305      Then the parties place the following orders:
   306        | party | market id | side | volume | price | resulting trades | type       | tif     |
   307        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   308        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   309        | aux2  | ETH/DEC20 | buy  | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   310        | aux   | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   311  
   312      Then the parties submit the following liquidity provision:
   313        | id  | party | market id | commitment amount | fee   | lp type    |
   314        | lp1 | aux   | ETH/DEC20 | 660               | 0.001 | submission |
   315        | lp1 | aux   | ETH/DEC20 | 660               | 0.001 | amendment  |
   316      And the parties place the following pegged iceberg orders:
   317        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   318        | aux    | ETH/DEC20 | 2         | 1                    | sell | ASK              | 1          | 10     |
   319        | aux    | ETH/DEC20 | 2         | 1                    | buy  | BID              | 1          | 10     |
   320  
   321      Then the opening auction period ends for market "ETH/DEC20"
   322      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   323      And the mark price should be "110" for the market "ETH/DEC20"
   324  
   325      When the parties place the following orders:
   326        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   327        | party1 | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   328        | party2 | ETH/DEC20 | buy  | 1      | 110   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   329  
   330      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   331  
   332      And the mark price should be "110" for the market "ETH/DEC20"
   333  
   334      #T0 + 10s
   335      Then time is updated to "2020-10-16T00:08:10Z"
   336  
   337      When the parties place the following orders:
   338        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   339        | party1 | ETH/DEC20 | sell | 1      | 115   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   340        | party2 | ETH/DEC20 | buy  | 1      | 115   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   341  
   342      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   343  
   344      Then the market data for the market "ETH/DEC20" should be:
   345        | mark price | last traded price | trading mode            |
   346        | 110        | 115               | TRADING_MODE_CONTINUOUS |
   347  
   348      #T0 + 01min10s
   349      Then time is updated to "2020-10-16T00:09:10Z"
   350  
   351      When the parties place the following orders:
   352        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   353        | party1 | ETH/DEC20 | sell | 1      | 105   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   354        | party2 | ETH/DEC20 | buy  | 1      | 105   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   355  
   356      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   357  
   358      And the mark price should be "115" for the market "ETH/DEC20"
   359  
   360      #T1 = T0 + 04min10s (auction start)
   361      Then time is updated to "2020-10-16T00:12:10Z"
   362  
   363      And the market data for the market "ETH/DEC20" should be:
   364        | horizon | min bound | max bound |
   365        | 60      | 104       | 125       |
   366        | 600     | 99        | 119       |
   367  
   368      When the parties place the following orders:
   369        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   370        | party1 | ETH/DEC20 | sell | 1      | 98    | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   371        | party2 | ETH/DEC20 | buy  | 1      | 98    | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   372  
   373      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   374  
   375      Then the market data for the market "ETH/DEC20" should be:
   376        | mark price | trading mode                    | auction trigger       | extension trigger           | target stake | supplied stake | auction end | horizon | min bound | max bound |
   377        | 105        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 431          | 660            | 240         | 600     | 99        | 119       |
   378  
   379      And the mark price should be "105" for the market "ETH/DEC20"
   380  
   381      #T1 + 04min00s (last second of initial auction duration)
   382      When time is updated to "2020-10-16T00:16:10Z"
   383      Then the market data for the market "ETH/DEC20" should be:
   384        | mark price | trading mode                    | auction trigger       | extension trigger           | target stake | supplied stake | auction end | horizon | min bound | max bound |
   385        | 105        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 431          | 660            | 240         | 600     | 99        | 119       |
   386  
   387      #T1 + 04min01s
   388      When time is updated to "2020-10-16T00:16:11Z"
   389      Then the market data for the market "ETH/DEC20" should be:
   390        | mark price | trading mode                    | auction trigger       | extension trigger           | target stake | supplied stake | auction end |
   391        | 105        | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_PRICE       | 431          | 660            | 600         |
   392  
   393      #T1 + 10min00s (last second of the extended auction)
   394      When time is updated to "2020-10-16T00:22:10Z"
   395      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   396      
   397      #T1 + 10min01s
   398      Then time is updated to "2020-10-16T00:22:11Z"
   399      Then the market data for the market "ETH/DEC20" should be:
   400        | mark price | trading mode            | auction trigger             | extension trigger           | target stake | supplied stake |
   401        | 98         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 431          | 660            |
   402  
   403    Scenario: Persistent order results in an auction (one trigger breached), orders placed during auction result in a trade with indicative price outside the price monitoring bounds, hence auction get extended, no further orders placed, auction concludes.
   404  
   405      Given the parties deposit on asset's general account the following amount:
   406        | party  | asset | amount       |
   407        | party1 | ETH   | 10000        |
   408        | party2 | ETH   | 10000        |
   409        | aux    | ETH   | 100000000000 |
   410        | aux2   | ETH   | 100000000000 |
   411        | lpprov | ETH   | 100000000000 |
   412  
   413      When the parties submit the following liquidity provision:
   414        | id  | party  | market id | commitment amount | fee | lp type    |
   415        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   416        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   417      And the parties place the following pegged iceberg orders:
   418        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   419        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   420        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   421  
   422      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   423      Then the parties place the following orders:
   424        | party | market id | side | volume | price | resulting trades | type       | tif     |
   425        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   426        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   427        | aux2  | ETH/DEC20 | buy  | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   428        | aux   | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   429      Then the opening auction period ends for market "ETH/DEC20"
   430      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   431      And the mark price should be "110" for the market "ETH/DEC20"
   432  
   433      When the parties place the following orders:
   434        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   435        | party1 | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   436        | party2 | ETH/DEC20 | buy  | 1      | 110   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   437  
   438      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   439  
   440      And the mark price should be "110" for the market "ETH/DEC20"
   441  
   442      #T0 + 10s
   443      Then time is updated to "2020-10-16T00:08:10Z"
   444  
   445      When the parties place the following orders:
   446        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   447        | party1 | ETH/DEC20 | sell | 1      | 115   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   448        | party2 | ETH/DEC20 | buy  | 1      | 115   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   449  
   450      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   451  
   452      Then the market data for the market "ETH/DEC20" should be:
   453        | mark price | last traded price | trading mode            |
   454        | 110        | 115               | TRADING_MODE_CONTINUOUS |
   455  
   456      #T0 + 01min10s
   457      Then time is updated to "2020-10-16T00:09:10Z"
   458  
   459      When the parties place the following orders:
   460        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   461        | party1 | ETH/DEC20 | sell | 1      | 105   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   462        | party2 | ETH/DEC20 | buy  | 1      | 105   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   463  
   464      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   465  
   466      Then the market data for the market "ETH/DEC20" should be:
   467        | mark price | last traded price | trading mode            |
   468        | 115        | 105               | TRADING_MODE_CONTINUOUS |
   469  
   470      #T1 = T0 + 02min10s (auction start)
   471      Then time is updated to "2020-10-16T00:10:10Z"
   472  
   473      When the parties place the following orders:
   474        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   475        | party1 | ETH/DEC20 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   476        | party2 | ETH/DEC20 | buy  | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   477  
   478      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   479  
   480      And the mark price should be "105" for the market "ETH/DEC20"
   481  
   482      #T1 + 04min00s (last second of the auction)
   483      Then time is updated to "2020-10-16T00:14:10Z"
   484  
   485      When the parties place the following orders:
   486        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   487        | party1 | ETH/DEC20 | sell | 2      | 133   | 0                | TYPE_LIMIT | TIF_GFA | ref-1     |
   488        | party2 | ETH/DEC20 | buy  | 2      | 133   | 0                | TYPE_LIMIT | TIF_GFA | ref-2     |
   489  
   490      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   491  
   492      #T1 + 04min01s (auction extended due to 2nd trigger)
   493      Then time is updated to "2020-10-16T00:14:11Z"
   494  
   495      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   496  
   497      And the mark price should be "105" for the market "ETH/DEC20"
   498  
   499      #T1 + 10min00s (last second of the extended auction)
   500      Then time is updated to "2020-10-16T00:20:10Z"
   501  
   502      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   503  
   504      And the mark price should be "105" for the market "ETH/DEC20"
   505  
   506      #T1 + 10min01s (extended auction finished)
   507      Then time is updated to "2020-10-16T00:20:11Z"
   508  
   509      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   510  
   511      And the mark price should be "133" for the market "ETH/DEC20"
   512  
   513    Scenario: 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.
   514  
   515      Given the parties deposit on asset's general account the following amount:
   516        | party  | asset | amount       |
   517        | party1 | ETH   | 10000        |
   518        | party2 | ETH   | 10000        |
   519        | aux    | ETH   | 100000000000 |
   520        | aux2   | ETH   | 100000000000 |
   521        | lpprov | ETH   | 100000000000 |
   522  
   523      When the parties submit the following liquidity provision:
   524        | id  | party  | market id | commitment amount | fee | lp type    |
   525        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   526        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   527      And the parties place the following pegged iceberg orders:
   528        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   529        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   530        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   531   
   532      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   533      Then the parties place the following orders:
   534        | party | market id | side | volume | price | resulting trades | type       | tif     |
   535        | aux   | ETH/DEC20 | buy  | 1      | 99    | 0                | TYPE_LIMIT | TIF_GTC |
   536        | aux   | ETH/DEC20 | sell | 1      | 134   | 0                | TYPE_LIMIT | TIF_GTC |
   537        | aux2  | ETH/DEC20 | buy  | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   538        | aux   | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC |
   539      Then the opening auction period ends for market "ETH/DEC20"
   540      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   541      And the mark price should be "110" for the market "ETH/DEC20"
   542  
   543      When the parties place the following orders:
   544        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   545        | party1 | ETH/DEC20 | sell | 1      | 110   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   546        | party2 | ETH/DEC20 | buy  | 1      | 110   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   547  
   548      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   549  
   550      And the mark price should be "110" for the market "ETH/DEC20"
   551  
   552      #T0 + 10s
   553      Then time is updated to "2020-10-16T00:08:10Z"
   554  
   555      When the parties place the following orders:
   556        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   557        | party1 | ETH/DEC20 | sell | 1      | 115   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   558        | party2 | ETH/DEC20 | buy  | 1      | 115   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   559  
   560      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   561  
   562      Then the market data for the market "ETH/DEC20" should be:
   563        | mark price | last traded price | trading mode            |
   564        | 110        | 115               | TRADING_MODE_CONTINUOUS |
   565  
   566      #T0 + 01min10s
   567      Then time is updated to "2020-10-16T00:09:10Z"
   568  
   569      When the parties place the following orders:
   570        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   571        | party1 | ETH/DEC20 | sell | 1      | 105   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   572        | party2 | ETH/DEC20 | buy  | 1      | 105   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   573  
   574      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   575  
   576      Then the market data for the market "ETH/DEC20" should be:
   577        | mark price | last traded price | trading mode            |
   578        | 115        | 105               | TRADING_MODE_CONTINUOUS |
   579  
   580      #T1 = T0 + 02min10s (auction start)
   581      Then time is updated to "2020-10-16T00:10:10Z"
   582  
   583      When the parties place the following orders:
   584        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   585        | party1 | ETH/DEC20 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   586        | party2 | ETH/DEC20 | buy  | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   587  
   588      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   589  
   590      And the mark price should be "105" for the market "ETH/DEC20"
   591  
   592      #T1 + 04min00s (last second of the auction)
   593      Then time is updated to "2020-10-16T00:14:10Z"
   594  
   595      When the parties place the following orders:
   596        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   597        | party1 | ETH/DEC20 | sell | 2      | 133   | 0                | TYPE_LIMIT | TIF_GFA | ref-1     |
   598        | party2 | ETH/DEC20 | buy  | 2      | 133   | 0                | TYPE_LIMIT | TIF_GFA | ref-2     |
   599  
   600      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   601  
   602      #T1 + 04min01s (auction extended due to 2nd trigger)
   603      Then time is updated to "2020-10-16T00:14:11Z"
   604  
   605      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   606  
   607      And the mark price should be "105" for the market "ETH/DEC20"
   608  
   609      #T1 + 10min00s (last second of the extended auction)
   610      Then time is updated to "2020-10-16T00:20:10Z"
   611  
   612      When the parties place the following orders:
   613        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   614        | party1 | ETH/DEC20 | sell | 10     | 303   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   615        | party2 | ETH/DEC20 | buy  | 10     | 303   | 0                | TYPE_LIMIT | TIF_GFA | ref-2     |
   616  
   617      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   618  
   619      And the mark price should be "105" for the market "ETH/DEC20"
   620  
   621      #T1 + 10min01s (extended auction finished)
   622      Then time is updated to "2020-10-16T00:20:11Z"
   623  
   624      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   625  
   626      And the mark price should be "303" for the market "ETH/DEC20"