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

     1  Feature: Price monitoring test for issue 2668
     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        | 43200   | 0.9999999   | 300               |
     8      And the log normal risk model named "my-log-normal-risk-model":
     9        | risk aversion | tau                    | mu | r     | sigma |
    10        | 0.000001      | 0.00011407711613050422 | 0  | 0.016 | 0.8   |
    11      And the markets:
    12        | id        | quote name | asset | risk model               | margin calculator         | auction duration | fees         | price monitoring    | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    13        | ETH/DEC20 | ETH        | ETH   | my-log-normal-risk-model | default-margin-calculator | 1                | default-none | my-price-monitoring | default-eth-for-future | 1e-4                   | 1e-4                      | default-futures |
    14      And the following network parameters are set:
    15        | name                                    | value |
    16        | market.auction.minimumDuration          | 300   |
    17        | network.markPriceUpdateMaximumFrequency | 0s    |
    18        | limits.markets.maxPeggedOrders          | 2     |
    19  
    20    Scenario: Upper bound breached
    21      Given the parties deposit on asset's general account the following amount:
    22        | party     | asset | amount       |
    23        | party1    | ETH   | 10000000000  |
    24        | party2    | ETH   | 10000000000  |
    25        | auxiliary | ETH   | 100000000000 |
    26        | aux2      | ETH   | 100000000000 |
    27        | lpprov    | ETH   | 100000000000 |
    28  
    29      When the parties submit the following liquidity provision:
    30        | id  | party  | market id | commitment amount | fee | lp type    |
    31        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    32        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
    33      And the parties place the following pegged iceberg orders:
    34        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    35        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
    36        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
    37      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    38      Then the parties place the following orders:
    39        | party     | market id | side | volume | price    | resulting trades | type       | tif     |
    40        | auxiliary | ETH/DEC20 | buy  | 1      | 1        | 0                | TYPE_LIMIT | TIF_GTC |
    41        | auxiliary | ETH/DEC20 | sell | 1      | 10000000 | 0                | TYPE_LIMIT | TIF_GTC |
    42        | auxiliary | ETH/DEC20 | sell | 1      | 5670000  | 0                | TYPE_LIMIT | TIF_GTC |
    43        | aux2      | ETH/DEC20 | buy  | 1      | 5670000  | 0                | TYPE_LIMIT | TIF_GTC |
    44      Then the opening auction period ends for market "ETH/DEC20"
    45      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    46  
    47      When the parties place the following orders with ticks:
    48        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
    49        | party1 | ETH/DEC20 | sell | 1      | 5670000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    50        | party2 | ETH/DEC20 | buy  | 1      | 5670000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
    51  
    52      And the mark price should be "5670000" for the market "ETH/DEC20"
    53  
    54      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    55  
    56      When the parties place the following orders with ticks:
    57        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
    58        | party1 | ETH/DEC20 | sell | 1      | 4850000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    59        | party2 | ETH/DEC20 | buy  | 1      | 4850000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
    60  
    61      And the mark price should be "4850000" for the market "ETH/DEC20"
    62  
    63      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    64  
    65      When the parties place the following orders with ticks:
    66        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
    67        | party1 | ETH/DEC20 | sell | 1      | 6630000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    68        | party2 | ETH/DEC20 | buy  | 1      | 6630000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
    69  
    70      And the mark price should be "6630000" for the market "ETH/DEC20"
    71  
    72      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
    73  
    74      When the parties place the following orders with ticks:
    75        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
    76        | party1 | ETH/DEC20 | sell | 1      | 6640000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    77        | party2 | ETH/DEC20 | buy  | 1      | 6640000 | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    78  
    79      # enter price monitoring auction
    80      Then the market state should be "STATE_SUSPENDED" for the market "ETH/DEC20"
    81      And the mark price should be "6630000" for the market "ETH/DEC20"
    82  
    83      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    84  
    85      # T0 + 10min (5 min opening auction + 5 min price monitoring)
    86      Then time is updated to "2020-10-16T00:10:00Z"
    87  
    88      And the mark price should be "6630000" for the market "ETH/DEC20"
    89  
    90      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
    91  
    92      # T0 + 15min01s (opening auction, price monitoring + extension due to time update + another period)
    93      When time is updated to "2020-10-16T00:15:01Z"
    94      # leave auction
    95      Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC20"
    96  
    97      # the order was GTC, so after the auction this trade can now happen
    98      And the mark price should be "6640000" for the market "ETH/DEC20"
    99  
   100      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   101  
   102    Scenario: Lower bound breached
   103      Given the parties deposit on asset's general account the following amount:
   104        | party     | asset | amount       |
   105        | party1    | ETH   | 10000000000  |
   106        | party2    | ETH   | 10000000000  |
   107        | auxiliary | ETH   | 100000000000 |
   108        | aux2      | ETH   | 100000000000 |
   109        | lpprov    | ETH   | 100000000000 |
   110  
   111      When the parties submit the following liquidity provision:
   112        | id  | party  | market id | commitment amount | fee | lp type    |
   113        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   114        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   115      And the parties place the following pegged iceberg orders:
   116        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   117        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   118        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   119  
   120      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   121      Then the parties place the following orders:
   122        | party     | market id | side | volume | price    | resulting trades | type       | tif     |
   123        | auxiliary | ETH/DEC20 | buy  | 1      | 1        | 0                | TYPE_LIMIT | TIF_GTC |
   124        | auxiliary | ETH/DEC20 | sell | 1      | 10000000 | 0                | TYPE_LIMIT | TIF_GTC |
   125        | auxiliary | ETH/DEC20 | sell | 1      | 5670000  | 0                | TYPE_LIMIT | TIF_GTC |
   126        | aux2      | ETH/DEC20 | buy  | 1      | 5670000  | 0                | TYPE_LIMIT | TIF_GTC |
   127      Then the opening auction period ends for market "ETH/DEC20"
   128      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   129  
   130      When the parties place the following orders with ticks:
   131        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
   132        | party1 | ETH/DEC20 | sell | 1      | 5670000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   133        | party2 | ETH/DEC20 | buy  | 1      | 5670000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   134  
   135      And the mark price should be "5670000" for the market "ETH/DEC20"
   136  
   137      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   138  
   139      When the parties place the following orders with ticks:
   140        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
   141        | party1 | ETH/DEC20 | sell | 1      | 4850000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   142        | party2 | ETH/DEC20 | buy  | 1      | 4850000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   143  
   144      And the mark price should be "4850000" for the market "ETH/DEC20"
   145  
   146      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   147  
   148      When the parties place the following orders with ticks:
   149        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
   150        | party1 | ETH/DEC20 | sell | 1      | 6630000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   151        | party2 | ETH/DEC20 | buy  | 1      | 6630000 | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   152  
   153      And the mark price should be "6630000" for the market "ETH/DEC20"
   154  
   155      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   156  
   157      When the parties place the following orders with ticks:
   158        | party  | market id | side | volume | price   | resulting trades | type       | tif     | reference |
   159        | party1 | ETH/DEC20 | sell | 1      | 4840000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   160        | party2 | ETH/DEC20 | buy  | 1      | 4840000 | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   161  
   162      #price monitoring auction started
   163      Then the market state should be "STATE_SUSPENDED" for the market "ETH/DEC20"
   164      And the mark price should be "6630000" for the market "ETH/DEC20"
   165      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   166  
   167      # T0 + 10min
   168      Then time is updated to "2020-10-16T00:10:00Z"
   169  
   170      And the mark price should be "6630000" for the market "ETH/DEC20"
   171  
   172      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   173  
   174      # T0 + 15min01s
   175      When time is updated to "2020-10-16T00:15:01Z"
   176      # leave auction
   177      Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC20"
   178      And the mark price should be "4840000" for the market "ETH/DEC20"
   179      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   180  
   181    Scenario: Upper bound breached (scale prices down by 10000)
   182      Given the parties deposit on asset's general account the following amount:
   183        | party     | asset | amount       |
   184        | party1    | ETH   | 10000000000  |
   185        | party2    | ETH   | 10000000000  |
   186        | auxiliary | ETH   | 100000000000 |
   187        | aux2      | ETH   | 100000000000 |
   188        | lpprov    | ETH   | 100000000000 |
   189  
   190      When the parties submit the following liquidity provision:
   191        | id  | party  | market id | commitment amount | fee | lp type    |
   192        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   193        | lp1 | lpprov | ETH/DEC20 | 90000000          | 0.1 | submission |
   194      And the parties place the following pegged iceberg orders:
   195        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   196        | lpprov | ETH/DEC20 | 2         | 1                    | buy  | BID              | 50         | 100    |
   197        | lpprov | ETH/DEC20 | 2         | 1                    | sell | ASK              | 50         | 100    |
   198   
   199      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
   200      When the parties place the following orders:
   201        | party     | market id | side | volume | price    | resulting trades | type       | tif     |
   202        | auxiliary | ETH/DEC20 | buy  | 1      | 1        | 0                | TYPE_LIMIT | TIF_GTC |
   203        | auxiliary | ETH/DEC20 | sell | 1      | 10000000 | 0                | TYPE_LIMIT | TIF_GTC |
   204        | auxiliary | ETH/DEC20 | sell | 1      | 567      | 0                | TYPE_LIMIT | TIF_GTC |
   205        | aux2      | ETH/DEC20 | buy  | 1      | 567      | 0                | TYPE_LIMIT | TIF_GTC |
   206      Then the opening auction period ends for market "ETH/DEC20"
   207      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   208  
   209      When the parties place the following orders with ticks:
   210        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   211        | party1 | ETH/DEC20 | sell | 1      | 567   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   212        | party2 | ETH/DEC20 | buy  | 1      | 567   | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   213  
   214      Then the mark price should be "567" for the market "ETH/DEC20"
   215  
   216      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   217  
   218      When the parties place the following orders with ticks:
   219        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   220        | party1 | ETH/DEC20 | sell | 1      | 485   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   221        | party2 | ETH/DEC20 | buy  | 1      | 485   | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   222  
   223      Then the mark price should be "485" for the market "ETH/DEC20"
   224  
   225      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   226  
   227      When the parties place the following orders with ticks:
   228        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   229        | party1 | ETH/DEC20 | sell | 1      | 663   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   230        | party2 | ETH/DEC20 | buy  | 1      | 663   | 1                | TYPE_LIMIT | TIF_FOK | ref-2     |
   231  
   232      Then the mark price should be "663" for the market "ETH/DEC20"
   233  
   234      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"
   235  
   236      When the parties place the following orders with ticks:
   237        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   238        | party1 | ETH/DEC20 | sell | 1      | 665   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   239        | party2 | ETH/DEC20 | buy  | 1      | 665   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   240  
   241      Then the mark price should be "663" for the market "ETH/DEC20"
   242      # enter price monitoring auction
   243      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   244      And the market state should be "STATE_SUSPENDED" for the market "ETH/DEC20"
   245  
   246      # T0 + 10min
   247      Then time is updated to "2020-10-16T00:10:00Z"
   248  
   249      And the mark price should be "663" for the market "ETH/DEC20"
   250  
   251      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20"
   252  
   253      # T0 + 15min01s
   254      When time is updated to "2020-10-16T00:15:01Z"
   255      # leave auction
   256      Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC20"
   257      And the mark price should be "665" for the market "ETH/DEC20"
   258      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"