code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0032-PRIM-038.feature (about) 1 Feature: Spot market 2 3 Background: 4 Given time is updated to "2024-01-01T00:00:00Z" 5 6 Given the following network parameters are set: 7 | name | value | 8 | network.markPriceUpdateMaximumFrequency | 0s | 9 | market.value.windowLength | 1h | 10 11 Given the following assets are registered: 12 | id | decimal places | 13 | ETH | 2 | 14 | BTC | 2 | 15 16 Given the fees configuration named "fees-config-1": 17 | maker fee | infrastructure fee | 18 | 0.01 | 0.03 | 19 Given the log normal risk model named "lognormal-risk-model-1": 20 | risk aversion | tau | mu | r | sigma | 21 | 0.001 | 0.01 | 0 | 0.0 | 1.2 | 22 And the price monitoring named "price-monitoring-1": 23 | horizon | probability | auction extension | 24 | 30 | 0.999 | 10 | 25 | 60 | 0.999 | 10 | 26 27 And the spot markets: 28 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 29 | BTC/ETH | BTC/ETH | BTC | ETH | lognormal-risk-model-1 | 1 | fees-config-1 | price-monitoring-1 | 2 | 2 | default-basic | 30 31 # setup accounts 32 Given the parties deposit on asset's general account the following amount: 33 | party | asset | amount | 34 | party1 | ETH | 10000 | 35 | party1 | BTC | 1000 | 36 | party2 | ETH | 10000 | 37 | party4 | BTC | 1000 | 38 | party5 | BTC | 1000 | 39 And the average block duration is "1" 40 41 # Place some orders to get out of auction 42 And the parties place the following orders: 43 | party | market id | side | volume | price | resulting trades | type | tif | 44 | party1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GFA | 45 | party5 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 46 47 And the opening auction period ends for market "BTC/ETH" 48 When the network moves ahead "1" blocks 49 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 50 And the mark price should be "1000" for the market "BTC/ETH" 51 52 Scenario: Same as PRIM-038, but more matching orders get placed during the auction extension. The volume of the trades generated 53 by the later orders is larger than that of the original pair which triggered the auction. Hence the auction concludes 54 generating the trades from the later orders. The overall auction duration is equal to the sum of the extension periods 55 of the two triggers. (0032-PRIM-038) 56 57 # Check that the market price bounds are set 58 And the market data for the market "BTC/ETH" should be: 59 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 60 | 1000 | TRADING_MODE_CONTINUOUS | 30 | 997 | 1003 | 0 | 0 | 0 | 61 | 1000 | TRADING_MODE_CONTINUOUS | 60 | 995 | 1005 | 0 | 0 | 0 | 62 63 # Place 2 persistent orders that are outside both price bounds 64 And the parties place the following orders: 65 | party | market id | side | volume | price | resulting trades | type | tif | reference | 66 | party1 | BTC/ETH | buy | 1 | 1006 | 0 | TYPE_LIMIT | TIF_GTC | buy1 | 67 | party5 | BTC/ETH | sell | 1 | 1006 | 0 | TYPE_LIMIT | TIF_GTC | sell1 | 68 When the network moves ahead "1" blocks 69 70 Then "party1" should have holding account balance of "11" for asset "ETH" 71 Then "party5" should have holding account balance of "1" for asset "BTC" 72 73 # Check we have been placed in auction 74 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH" 75 76 # If we move forward 10 blocks we should still be in auction due to the second extension 77 When the network moves ahead "10" blocks 78 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH" 79 80 # Now place some larger orders while in the auction extension 81 And the parties place the following orders: 82 | party | market id | side | volume | price | resulting trades | type | tif | reference | 83 | party2 | BTC/ETH | buy | 5 | 1007 | 0 | TYPE_LIMIT | TIF_GTC | buy2 | 84 | party4 | BTC/ETH | sell | 5 | 1007 | 0 | TYPE_LIMIT | TIF_GTC | sell2 | 85 86 # DEBUGGING 87 Then "party2" should have holding account balance of "51" for asset "ETH" 88 Then "party4" should have holding account balance of "5" for asset "BTC" 89 90 # If we move forward 10 more blocks we should leave the auction 91 When the network moves ahead "10" blocks 92 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 93 94 # The mark price should show the orders have traded 95 And the mark price should be "1007" for the market "BTC/ETH" 96 97 And the orders should have the following states: 98 | party | market id | reference | side | volume | remaining | price | status | 99 | party1 | BTC/ETH | buy1 | buy | 1 | 1 | 1006 | STATUS_ACTIVE | 100 | party5 | BTC/ETH | sell1 | sell | 1 | 0 | 1006 | STATUS_FILLED | 101 | party2 | BTC/ETH | buy2 | buy | 5 | 0 | 1007 | STATUS_FILLED | 102 | party4 | BTC/ETH | sell2 | sell | 5 | 1 | 1007 | STATUS_ACTIVE | 103