code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/price-monitoring-for-system-test.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: [99845,100156], [99711,100290]) 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 | 5 | 0.95 | 6 | 8 | 15 | 0.99 | 8 | 9 And the log normal risk model named "my-log-normal-risk-model": 10 | risk aversion | tau | mu | r | sigma | 11 | 0.000001 | 0.00011407711613050422 | 0 | 0.016 | 2.0 | 12 And the markets: 13 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 14 | ETH/DEC20 | ETH | ETH | my-log-normal-risk-model | default-margin-calculator | 6 | default-none | my-price-monitoring | default-eth-for-future | 1e-4 | 1e-4 | default-futures | 15 And the following network parameters are set: 16 | name | value | 17 | market.auction.minimumDuration | 6 | 18 | limits.markets.maxPeggedOrders | 2 | 19 And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" 20 21 Scenario: Scenario for the system test with opening auction 22 Given the parties deposit on asset's general account the following amount: 23 | party | asset | amount | 24 | party1 | ETH | 100000000000 | 25 | party2 | ETH | 100000000000 | 26 | party3 | ETH | 100000000000 | 27 | party4 | ETH | 100000000000 | 28 | aux | ETH | 100000000000 | 29 | lpprov | ETH | 100000000000 | 30 31 When the parties submit the following liquidity provision: 32 | id | party | market id | commitment amount | fee | lp type | 33 | lp1 | lpprov | ETH/DEC20 | 90000000 | 0.1 | submission | 34 | lp1 | lpprov | ETH/DEC20 | 90000000 | 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/DEC20 | 2 | 1 | buy | BID | 50 | 100 | 38 | lpprov | ETH/DEC20 | 2 | 1 | sell | ASK | 50 | 100 | 39 40 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 41 When the parties place the following orders: 42 | party | market id | side | volume | price | resulting trades | type | tif | 43 | aux | ETH/DEC20 | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 44 | aux | ETH/DEC20 | sell | 1 | 110000 | 0 | TYPE_LIMIT | TIF_GTC | 45 46 And the parties place the following orders: 47 | party | market id | side | volume | price | resulting trades | type | tif | reference | 48 | party1 | ETH/DEC20 | sell | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 49 | party2 | ETH/DEC20 | buy | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 50 | party3 | ETH/DEC20 | buy | 1 | 80000 | 0 | TYPE_LIMIT | TIF_GTC | party3_buy_1 | 51 | party4 | ETH/DEC20 | sell | 1 | 105000 | 0 | TYPE_LIMIT | TIF_GTC | party4_sell_1 | 52 53 Then the mark price should be "0" for the market "ETH/DEC20" 54 And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" 55 56 # T + 5s 57 When time is updated to "2020-10-16T00:00:06Z" 58 Then the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" 59 60 # T + 1s 61 When time is updated to "2020-10-16T00:00:07Z" 62 Then the mark price should be "100000" for the market "ETH/DEC20" 63 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" 64 And the market data for the market "ETH/DEC20" should be: 65 | mark price | trading mode | horizon | min bound | max bound | 66 | 100000 | TRADING_MODE_CONTINUOUS | 5 | 99845 | 100156 | 67 | 100000 | TRADING_MODE_CONTINUOUS | 15 | 99646 | 100355 | 68 69 # We've left opening auction, cancel the orders we had to place on the book to allow for this to happen 70 And the parties cancel the following orders: 71 | party | reference | 72 | party3 | party3_buy_1 | 73 | party4 | party4_sell_1 | 74 75 # 1st trigger breached with non-persistent order -> auction with initial duration of 6s starts 76 When the parties place the following orders: 77 | party | market id | side | volume | price | resulting trades | type | tif | reference | 78 | party1 | ETH/DEC20 | sell | 1 | 99843 | 0 | TYPE_LIMIT | TIF_GTC | party1_sell_1 | 79 | party2 | ETH/DEC20 | buy | 1 | 99843 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 80 81 Then the mark price should be "100000" for the market "ETH/DEC20" 82 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20" 83 And the parties cancel the following orders: 84 | party | reference | 85 | party1 | party1_sell_1 | 86 | party2 | ref-3 | 87 88 # T + 4s 89 When time is updated to "2020-10-16T00:00:10Z" 90 91 # 2nd trigger breached with persistent order -> auction extended by 8s (total auction time no 14s). 92 Then the parties place the following orders: 93 | party | market id | side | volume | price | resulting trades | type | tif | reference | 94 | party1 | ETH/DEC20 | sell | 1 | 100356 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 95 | party2 | ETH/DEC20 | buy | 1 | 100356 | 0 | TYPE_LIMIT | TIF_GTC | ref-5 | 96 97 # T + 10s (last second of the auciton) 98 Then time is updated to "2020-10-16T00:00:20Z" 99 100 And the mark price should be "100000" for the market "ETH/DEC20" 101 102 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20" 103 104 # T + 1s (auction ended) 105 Then time is updated to "2020-10-16T00:00:22Z" 106 107 And the mark price should be "100356" for the market "ETH/DEC20" 108 109 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" 110 111 # 100291 is the new reference price, we get the following valid price ranges for the 2 triggers: [100135, 100447] & [100001, 100582] 112 When the parties place the following orders: 113 | party | market id | side | volume | price | resulting trades | type | tif | reference | 114 | party1 | ETH/DEC20 | sell | 1 | 100447 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 115 | party2 | ETH/DEC20 | buy | 1 | 100447 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 116 117 Then the market data for the market "ETH/DEC20" should be: 118 | mark price | last traded price | trading mode | 119 | 100356 | 100447 | TRADING_MODE_CONTINUOUS | 120 121 122 # Now we should be after update and the bounds should change 123 # T + 5s 124 Then time is updated to "2020-10-16T00:00:26Z" 125 126 When the parties place the following orders: 127 | party | market id | side | volume | price | resulting trades | type | tif | reference | 128 | party1 | ETH/DEC20 | sell | 1 | 100448 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 129 | party2 | ETH/DEC20 | buy | 1 | 100448 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 130 131 Then the market data for the market "ETH/DEC20" should be: 132 | mark price | last traded price | trading mode | 133 | 100356 | 100448 | TRADING_MODE_CONTINUOUS | 134 135 136 # Now, we have the following valid price ranges for the 2 triggers: [100213, 100525] & [100079, 100660] 137 When the parties place the following orders: 138 | party | market id | side | volume | price | resulting trades | type | tif | reference | 139 | party2 | ETH/DEC20 | buy | 2 | 100213 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 140 | party2 | ETH/DEC20 | buy | 1 | 100050 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 141 142 Then the market data for the market "ETH/DEC20" should be: 143 | mark price | last traded price | trading mode | 144 | 100356 | 100448 | TRADING_MODE_CONTINUOUS | 145 146 147 # T + 2s 148 When time is updated to "2020-10-16T00:00:28Z" 149 150 # Both triggers breached with market order -> 14s auction 151 Then the parties place the following orders: 152 | party | market id | side | volume | price | resulting trades | type | tif | reference | 153 | party1 | ETH/DEC20 | sell | 3 | 1 | 0 | TYPE_LIMIT | TIF_GTC | ref-6 | 154 155 156 And the mark price should be "100448" for the market "ETH/DEC20" 157 158 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20" 159 160 # T + 3s 161 When time is updated to "2020-10-16T00:00:33Z" 162 163 Then the mark price should be "100448" for the market "ETH/DEC20" 164 165 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20" 166 167 And the parties cancel the following orders: 168 | party | reference | 169 | party1 | ref-6 | 170 # T + 8s 171 When time is updated to "2020-10-16T00:00:43Z" 172 173 Then the mark price should be "100448" for the market "ETH/DEC20" 174 175 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" 176 177 # 100213 is the new reference price, we get the following valid price ranges for the 2 triggers: [100057, 100369] & [99923, 100503] 178 179 When the parties place the following orders: 180 | party | market id | side | volume | price | resulting trades | type | tif | reference | 181 | party1 | ETH/DEC20 | sell | 1 | 100292 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 182 | party2 | ETH/DEC20 | buy | 1 | 100292 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 183 184 185 Then the market data for the market "ETH/DEC20" should be: 186 | mark price | last traded price | trading mode | 187 | 100448 | 100292 | TRADING_MODE_CONTINUOUS | 188 # T1 = T + 12s 189 When time is updated to "2020-10-16T00:00:55Z" 190 191 # Both triggers breached with persistent order -> auction with duration of 14s starts 192 Then the parties place the following orders: 193 | party | market id | side | volume | price | resulting trades | type | tif | reference | 194 | party1 | ETH/DEC20 | sell | 1 | 100650 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 195 | party2 | ETH/DEC20 | buy | 1 | 100650 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 196 197 Then the market data for the market "ETH/DEC20" should be: 198 | mark price | trading mode | auction trigger | extension trigger | auction end | horizon | ref price | min bound | max bound | 199 | 100292 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 6 | 15 | 100448 | 100092 | 100805 | 200 201 202 # T1 + 6s 203 When time is updated to "2020-10-16T00:01:01Z" 204 205 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC20" 206 Then the market data for the market "ETH/DEC20" should be: 207 | mark price | trading mode | auction trigger | extension trigger | auction end | horizon | ref price | min bound | max bound | 208 | 100292 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_UNSPECIFIED | 6 | 15 | 100292 | 99937 | 100648 | 209 # T1 + 7s 210 When time is updated to "2020-10-16T00:01:02Z" 211 212 Then the market data for the market "ETH/DEC20" should be: 213 | mark price | trading mode | auction trigger | extension trigger | auction end | 214 | 100292 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | AUCTION_TRIGGER_PRICE | 14 | 215 216 # T1 + 16s 217 When time is updated to "2020-10-16T00:01:11Z" 218 Then the mark price should be "100650" for the market "ETH/DEC20" 219 220 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20"