code.vegaprotocol.io/vega@v0.79.0/core/integration/features/auctions/opening-auction-price.feature (about) 1 Feature: Set up a market, create indiciative price different to actual opening auction uncross price 2 3 Background: 4 Given the simple risk model named "my-simple-risk-model": 5 | long | short | max move up | min move down | probability of trading | 6 | 0.1 | 0.1 | 2 | -3 | 0.2 | 7 Given the markets: 8 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 9 | ETH/DEC19 | BTC | BTC | my-simple-risk-model | default-margin-calculator | 5 | default-none | default-basic | default-eth-for-future | 0.25 | 0 | default-futures | 10 And the following network parameters are set: 11 | name | value | 12 | market.auction.minimumDuration | 5 | 13 | network.floatingPointUpdates.delay | 10s | 14 | network.markPriceUpdateMaximumFrequency | 0s | 15 | limits.markets.maxPeggedOrders | 2 | 16 17 @OpenIP 18 Scenario: Simple test with different indicative price before auction uncross 19 # setup accounts 20 Given the parties deposit on asset's general account the following amount: 21 | party | asset | amount | 22 | party1 | BTC | 100000000 | 23 | party2 | BTC | 100000000 | 24 | party3 | BTC | 100000000 | 25 | party4 | BTC | 100000000 | 26 | party5 | BTC | 100000000 | 27 | party6 | BTC | 100000000 | 28 | party7 | BTC | 100000000 | 29 | lpprov | BTC | 100000000 | 30 31 # Start market with some dead time 32 When the network moves ahead "2" blocks 33 Then the market data for the market "ETH/DEC19" should be: 34 | trading mode | 35 | TRADING_MODE_OPENING_AUCTION | 36 # Ensure an indicative price/volume of 10, although we will not uncross at this price point 37 And the parties place the following orders: 38 | party | market id | side | volume | price | resulting trades | type | tif | reference | 39 | party6 | ETH/DEC19 | buy | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t6-b-1 | 40 When the network moves ahead "1" blocks 41 Then the market data for the market "ETH/DEC19" should be: 42 | trading mode | 43 | TRADING_MODE_OPENING_AUCTION | 44 And the parties place the following orders: 45 | party | market id | side | volume | price | resulting trades | type | tif | reference | 46 | party5 | ETH/DEC19 | sell | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t5-s-1 | 47 # place orders to set the actual price point at which we'll uncross to be 10000 48 When the network moves ahead "1" blocks 49 Then the market data for the market "ETH/DEC19" should be: 50 | trading mode | 51 | TRADING_MODE_OPENING_AUCTION | 52 And the parties submit the following liquidity provision: 53 | id | party | market id | commitment amount | fee | lp type | 54 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 55 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 56 And the parties place the following pegged iceberg orders: 57 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 58 | lpprov | ETH/DEC19 | 16 | 1 | buy | MID | 50 | 100 | 59 | lpprov | ETH/DEC19 | 15 | 1 | sell | MID | 50 | 100 | 60 And the parties place the following orders: 61 | party | market id | side | volume | price | resulting trades | type | tif | reference | 62 | party3 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 63 | party4 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 64 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 65 | party2 | ETH/DEC19 | sell | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-1 | 66 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-2 | 67 | party2 | ETH/DEC19 | sell | 5 | 10001 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-2 | 68 | party1 | ETH/DEC19 | buy | 4 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-3 | 69 | party2 | ETH/DEC19 | sell | 3 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-3 | 70 | party7 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GFA | t7-s-1 | 71 And the parties should have the following margin levels: 72 | party | market id | maintenance | 73 | party1 | ETH/DEC19 | 14000 | 74 | party2 | ETH/DEC19 | 13000 | 75 And the parties should have the following account balances: 76 | party | asset | market id | margin | general | 77 | party1 | BTC | ETH/DEC19 | 16800 | 99983200 | 78 | party2 | BTC | ETH/DEC19 | 15600 | 99984400 | 79 When the opening auction period ends for market "ETH/DEC19" 80 Then the following trades should be executed: 81 | buyer | price | size | seller | 82 | party1 | 10000 | 1 | party5 | 83 | party1 | 10000 | 3 | party2 | 84 | party1 | 10000 | 1 | party2 | 85 | party1 | 10000 | 4 | party2 | 86 And the mark price should be "10000" for the market "ETH/DEC19" 87 And the orders should have the following status: 88 | party | reference | status | 89 | party1 | t1-b-1 | STATUS_FILLED | 90 | party2 | t2-s-1 | STATUS_FILLED | 91 | party1 | t1-b-2 | STATUS_CANCELLED | 92 | party2 | t2-s-2 | STATUS_CANCELLED | 93 | party1 | t1-b-3 | STATUS_CANCELLED | 94 | party2 | t2-s-3 | STATUS_FILLED | 95 | party5 | t5-s-1 | STATUS_FILLED | 96 | party6 | t6-b-1 | STATUS_CANCELLED | 97 And the parties should have the following profit and loss: 98 | party | volume | unrealised pnl | realised pnl | 99 | party2 | -8 | 0 | 0 | 100 And the order book should have the following volumes for market "ETH/DEC19": 101 | side | price | volume | 102 | sell | 11000 | 1 | 103 | sell | 6100 | 15 | 104 | buy | 5900 | 16 | 105 | buy | 1000 | 1 | 106 107 # party2_maintenance:= 8*10000*(0.1+0.25) = 28000 108 And the parties should have the following margin levels: 109 | party | market id | maintenance | 110 | party2 | ETH/DEC19 | 28000 | 111 | party1 | ETH/DEC19 | 31500 | 112 And the market data for the market "ETH/DEC19" should be: 113 | mark price | trading mode | horizon | min bound | max bound | ref price | 114 | 10000 | TRADING_MODE_CONTINUOUS | 5 | 9997 | 10002 | 10000 | 115 116 @OpenIP 117 Scenario: Same test as above, but without the initial indicative price/volume 118 # setup accounts 119 Given the parties deposit on asset's general account the following amount: 120 | party | asset | amount | 121 | party1 | BTC | 100000000 | 122 | party2 | BTC | 100000000 | 123 | party3 | BTC | 100000000 | 124 | party4 | BTC | 100000000 | 125 | lpprov | BTC | 100000000 | 126 127 # Start opening auction with some dead time... 128 When the network moves ahead "1" blocks 129 # place orders to set the actual price point at which we'll uncross to be 10000 130 When the parties place the following orders: 131 | party | market id | side | volume | price | resulting trades | type | tif | reference | 132 | party3 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 133 | party4 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 134 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 135 | party2 | ETH/DEC19 | sell | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-1 | 136 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-2 | 137 | party2 | ETH/DEC19 | sell | 5 | 10001 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-2 | 138 | party1 | ETH/DEC19 | buy | 4 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-3 | 139 | party2 | ETH/DEC19 | sell | 3 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-3 | 140 And the parties submit the following liquidity provision: 141 | id | party | market id | commitment amount | fee | lp type | 142 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 143 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 144 And the parties place the following pegged iceberg orders: 145 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 146 | lpprov | ETH/DEC19 | 2 | 1 | buy | MID | 50 | 100 | 147 | lpprov | ETH/DEC19 | 2 | 1 | sell | MID | 50 | 100 | 148 Then the parties should have the following margin levels: 149 | party | market id | maintenance | 150 | party1 | ETH/DEC19 | 14000 | 151 | party2 | ETH/DEC19 | 13000 | 152 And the parties should have the following account balances: 153 | party | asset | market id | margin | general | 154 | party1 | BTC | ETH/DEC19 | 16800 | 99983200 | 155 | party2 | BTC | ETH/DEC19 | 15600 | 99984400 | 156 # moves forwards several blocks 157 When the opening auction period ends for market "ETH/DEC19" 158 ## We're seeing these events twice for some reason 159 Then the following trades should be executed: 160 | buyer | price | size | seller | 161 | party1 | 10000 | 3 | party2 | 162 | party1 | 10000 | 2 | party2 | 163 | party1 | 10000 | 3 | party2 | 164 And the mark price should be "10000" for the market "ETH/DEC19" 165 ## Network for distressed party1 -> cancelled, nothing on the book is remaining 166 And the orders should have the following status: 167 | party | reference | status | 168 | party1 | t1-b-1 | STATUS_FILLED | 169 | party2 | t2-s-1 | STATUS_FILLED | 170 | party1 | t1-b-2 | STATUS_CANCELLED | 171 | party2 | t2-s-2 | STATUS_CANCELLED | 172 | party1 | t1-b-3 | STATUS_CANCELLED | 173 | party2 | t2-s-3 | STATUS_FILLED | 174 175 When the network moves ahead "1" blocks 176 Then the parties should have the following margin levels: 177 | party | market id | maintenance | 178 | party2 | ETH/DEC19 | 28000 | 179 180 And the market data for the market "ETH/DEC19" should be: 181 | mark price | trading mode | horizon | min bound | max bound | ref price | 182 | 10000 | TRADING_MODE_CONTINUOUS | 5 | 9997 | 10002 | 10000 | 183 184 @OpenIPT 185 Scenario: Simple test with different indicative price before auction uncross 186 # setup accounts 187 Given the parties deposit on asset's general account the following amount: 188 | party | asset | amount | 189 | party1 | BTC | 100000000 | 190 | party2 | BTC | 100000000 | 191 | party3 | BTC | 100000000 | 192 | party4 | BTC | 100000000 | 193 | party5 | BTC | 100000000 | 194 | party6 | BTC | 100000000 | 195 | lpprov | BTC | 100000000 | 196 197 # Start market with some dead time 198 When the network moves ahead "3" blocks 199 Then the market data for the market "ETH/DEC19" should be: 200 | trading mode | 201 | TRADING_MODE_OPENING_AUCTION | 202 # Ensure an indicative price/volume of 10, although we will not uncross at this price point 203 And the parties place the following orders: 204 | party | market id | side | volume | price | resulting trades | type | tif | reference | 205 | party5 | ETH/DEC19 | sell | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t5-s-1 | 206 | party6 | ETH/DEC19 | buy | 1 | 10 | 0 | TYPE_LIMIT | TIF_GFA | t6-b-1 | 207 When the network moves ahead "1" blocks 208 Then the market data for the market "ETH/DEC19" should be: 209 | trading mode | 210 | TRADING_MODE_OPENING_AUCTION | 211 And the parties submit the following liquidity provision: 212 | id | party | market id | commitment amount | fee | lp type | 213 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 214 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 215 And the parties place the following pegged iceberg orders: 216 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 217 | lpprov | ETH/DEC19 | 2 | 1 | buy | MID | 50 | 100 | 218 | lpprov | ETH/DEC19 | 2 | 1 | sell | MID | 50 | 100 | 219 And the parties place the following orders: 220 | party | market id | side | volume | price | resulting trades | type | tif | reference | 221 | party3 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 222 | party4 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 223 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 224 | party2 | ETH/DEC19 | sell | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-1 | 225 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-2 | 226 | party2 | ETH/DEC19 | sell | 5 | 10001 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-2 | 227 | party1 | ETH/DEC19 | buy | 4 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-3 | 228 | party2 | ETH/DEC19 | sell | 3 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-3 | 229 And the parties should have the following margin levels: 230 | party | market id | maintenance | 231 | party1 | ETH/DEC19 | 14000 | 232 | party2 | ETH/DEC19 | 13000 | 233 And the parties should have the following account balances: 234 | party | asset | market id | margin | general | 235 | party1 | BTC | ETH/DEC19 | 16800 | 99983200 | 236 | party2 | BTC | ETH/DEC19 | 15600 | 99984400 | 237 When the opening auction period ends for market "ETH/DEC19" 238 ## We're seeing these events twice for some reason 239 Then the following trades should be executed: 240 | buyer | price | size | seller | 241 | party1 | 10000 | 1 | party5 | 242 | party1 | 10000 | 3 | party2 | 243 | party1 | 10000 | 1 | party2 | 244 | party1 | 10000 | 4 | party2 | 245 And the mark price should be "10000" for the market "ETH/DEC19" 246 And the orders should have the following status: 247 | party | reference | status | 248 | party1 | t1-b-1 | STATUS_FILLED | 249 | party2 | t2-s-1 | STATUS_FILLED | 250 | party1 | t1-b-2 | STATUS_CANCELLED | 251 | party2 | t2-s-2 | STATUS_CANCELLED | 252 | party1 | t1-b-3 | STATUS_CANCELLED | 253 | party2 | t2-s-3 | STATUS_FILLED | 254 | party5 | t5-s-1 | STATUS_FILLED | 255 | party6 | t6-b-1 | STATUS_CANCELLED | 256 257 When the network moves ahead "1" blocks 258 Then the parties should have the following margin levels: 259 | party | market id | maintenance | 260 | party2 | ETH/DEC19 | 28000 | 261 | party1 | ETH/DEC19 | 31500 | 262 Then the parties should have the following profit and loss: 263 | party | volume | unrealised pnl | realised pnl | 264 | party2 | -8 | 0 | 0 | 265 | party1 | 9 | 0 | 0 | 266 And the market data for the market "ETH/DEC19" should be: 267 | mark price | trading mode | horizon | min bound | max bound | ref price | 268 | 10000 | TRADING_MODE_CONTINUOUS | 5 | 9997 | 10002 | 10000 | 269 270 @OpenIPO 271 Scenario: Same again, but higher indicative price 272 # setup accounts 273 Given the parties deposit on asset's general account the following amount: 274 | party | asset | amount | 275 | party1 | BTC | 100000000 | 276 | party2 | BTC | 100000000 | 277 | party3 | BTC | 100000000 | 278 | party4 | BTC | 100000000 | 279 | party5 | BTC | 100000000 | 280 | party6 | BTC | 100000000 | 281 | lpprov | BTC | 100000000 | 282 283 # Start market with some dead time 284 When the network moves ahead "3" blocks 285 Then the market data for the market "ETH/DEC19" should be: 286 | trading mode | 287 | TRADING_MODE_OPENING_AUCTION | 288 # Ensure an indicative price/volume of 10, although we will not uncross at this price point 289 And the parties place the following orders: 290 | party | market id | side | volume | price | resulting trades | type | tif | reference | 291 | party5 | ETH/DEC19 | sell | 1 | 10900 | 0 | TYPE_LIMIT | TIF_GFA | t5-s-1 | 292 | party6 | ETH/DEC19 | buy | 1 | 10900 | 0 | TYPE_LIMIT | TIF_GFA | t6-b-1 | 293 When the network moves ahead "1" blocks 294 Then the market data for the market "ETH/DEC19" should be: 295 | trading mode | 296 | TRADING_MODE_OPENING_AUCTION | 297 And the parties cancel the following orders: 298 | party | reference | 299 | party5 | t5-s-1 | 300 And the parties submit the following liquidity provision: 301 | id | party | market id | commitment amount | fee | lp type | 302 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 303 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 304 And the parties place the following pegged iceberg orders: 305 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 306 | lpprov | ETH/DEC19 | 2 | 1 | buy | MID | 50 | 100 | 307 | lpprov | ETH/DEC19 | 2 | 1 | sell | MID | 50 | 100 | 308 And the parties place the following orders: 309 | party | market id | side | volume | price | resulting trades | type | tif | reference | 310 | party3 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 311 | party4 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 312 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 313 | party2 | ETH/DEC19 | sell | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-1 | 314 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-2 | 315 | party2 | ETH/DEC19 | sell | 5 | 10001 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-2 | 316 | party1 | ETH/DEC19 | buy | 4 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-3 | 317 | party2 | ETH/DEC19 | sell | 3 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t2-s-3 | 318 And the parties should have the following margin levels: 319 | party | market id | maintenance | 320 | party2 | ETH/DEC19 | 13000 | 321 And the parties should have the following account balances: 322 | party | asset | market id | margin | general | 323 | party1 | BTC | ETH/DEC19 | 16800 | 99983200 | 324 | party2 | BTC | ETH/DEC19 | 15600 | 99984400 | 325 # values before uint 326 #| party1 | BTC | ETH/DEC19 | 30241 | 99969759 | 327 When the opening auction period ends for market "ETH/DEC19" 328 Then the market data for the market "ETH/DEC19" should be: 329 | trading mode | 330 | TRADING_MODE_CONTINUOUS | 331 332 ## We're seeing these events twice for some reason 333 Then the following trades should be executed: 334 | buyer | price | size | seller | 335 | party1 | 10000 | 3 | party2 | 336 | party1 | 10000 | 2 | party2 | 337 | party1 | 10000 | 2 | party2 | 338 And the mark price should be "10000" for the market "ETH/DEC19" 339 ## Network for distressed party1 -> cancelled, nothing on the book is remaining 340 And the orders should have the following status: 341 | party | reference | status | 342 | party1 | t1-b-1 | STATUS_FILLED | 343 | party2 | t2-s-1 | STATUS_FILLED | 344 | party1 | t1-b-2 | STATUS_CANCELLED | 345 | party2 | t2-s-2 | STATUS_CANCELLED | 346 | party1 | t1-b-3 | STATUS_CANCELLED | 347 | party2 | t2-s-3 | STATUS_FILLED | 348 | party5 | t5-s-1 | STATUS_CANCELLED | 349 | party6 | t6-b-1 | STATUS_FILLED | 350 351 When the network moves ahead "1" blocks 352 Then the parties should have the following account balances: 353 | party | asset | market id | margin | general | 354 | party2 | BTC | ETH/DEC19 | 33600 | 99966400 | 355 | party1 | BTC | ETH/DEC19 | 29400 | 99970600 | 356 And the market data for the market "ETH/DEC19" should be: 357 | mark price | trading mode | horizon | min bound | max bound | ref price | 358 | 10000 | TRADING_MODE_CONTINUOUS | 5 | 9997 | 10002 | 10000 | 359 360 Scenario: checking auction price 361 # setup accounts 362 Given the parties deposit on asset's general account the following amount: 363 | party | asset | amount | 364 | party1 | BTC | 100000000 | 365 | party2 | BTC | 100000000 | 366 | party3 | BTC | 100000000 | 367 | party4 | BTC | 100000000 | 368 369 Then the market data for the market "ETH/DEC19" should be: 370 | trading mode | 371 | TRADING_MODE_OPENING_AUCTION | 372 # Ensure an indicative price/volume of 10, although we will not uncross at this price point 373 And the parties place the following orders: 374 | party | market id | side | volume | price | resulting trades | type | tif | reference | 375 | party3 | ETH/DEC19 | buy | 20 | 90000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 376 | party2 | ETH/DEC19 | buy | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | t2-b-1 | 377 | party3 | ETH/DEC19 | buy | 9 | 107000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 378 | party1 | ETH/DEC19 | sell | 10 | 95000 | 0 | TYPE_LIMIT | TIF_GTC | t1-s-1 | 379 | party4 | ETH/DEC19 | sell | 20 | 200000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 380 When the network moves ahead "6" blocks 381 Then the market data for the market "ETH/DEC19" should be: 382 | trading mode | 383 | TRADING_MODE_CONTINUOUS | 384 385 And the following trades should be executed: 386 | buyer | price | size | seller | 387 | party3 | 97500 | 9 | party1 | 388 | party2 | 97500 | 1 | party1 | 389 390 And the mark price should be "97500" for the market "ETH/DEC19" 391