code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0068-MATC-061.feature (about) 1 Feature: Spot market order tests. Covers 0068-MATC-061, 0068-MATC-062, 0068-MATC-063, 0068-MATC-064, 0068-MATC-065. 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 | 3600 | 0.999 | 10 | 25 26 And the spot markets: 27 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 28 | BTC/ETH | BTC/ETH | BTC | ETH | lognormal-risk-model-1 | 1 | fees-config-1 | price-monitoring-1 | 2 | 2 | default-basic | 29 30 # setup accounts 31 Given the parties deposit on asset's general account the following amount: 32 | party | asset | amount | 33 | party1 | ETH | 10000 | 34 | party1 | BTC | 1000 | 35 | party2 | ETH | 10000 | 36 | party4 | BTC | 1000 | 37 | party5 | BTC | 1000 | 38 And the average block duration is "1" 39 40 # Place some orders to get out of auction 41 And the parties place the following orders: 42 | party | market id | side | volume | price | resulting trades | type | tif | 43 | party1 | BTC/ETH | buy | 1 | 998 | 0 | TYPE_LIMIT | TIF_GTC | 44 | party1 | BTC/ETH | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 45 | party5 | BTC/ETH | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 46 | party5 | BTC/ETH | sell | 1 | 1050 | 0 | TYPE_LIMIT | TIF_GTC | 47 48 And the opening auction period ends for market "BTC/ETH" 49 When the network moves ahead "1" blocks 50 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 51 And the mark price should be "1000" for the market "BTC/ETH" 52 53 Scenario: 0068-MATC-061: Incoming MARKET orders will be matched against the opposite side of the book. 54 55 # set up the book with some volume the market order will uncross with 56 When the parties place the following orders: 57 | party | market id | side | volume | price | resulting trades | type | tif | reference | 58 | party1 | BTC/ETH | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p1-ioc-pas | 59 And the parties place the following orders: 60 | party | market id | side | volume | price | resulting trades | type | tif | reference | 61 | party5 | BTC/ETH | sell | 2 | 0 | 1 | TYPE_MARKET | TIF_IOC | p5-ioc-agg | 62 Then the following trades should be executed: 63 | buyer | price | size | seller | 64 | party1 | 1000 | 2 | party5 | 65 And the orders should have the following status: 66 | party | reference | status | 67 | party1 | p1-ioc-pas | STATUS_ACTIVE | 68 | party5 | p5-ioc-agg | STATUS_FILLED | 69 70 When the network moves ahead "1" blocks 71 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 72 And the market data for the market "BTC/ETH" should be: 73 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 74 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 959 | 1042 | 0 | 0 | 0 | 75 76 Scenario: 0068-MATC-062: If not enough volume is available to fully fill the order, the remaining will be cancelled. 77 # set up the book with some volume the market order will partially uncross with 78 When the parties place the following orders: 79 | party | market id | side | volume | price | resulting trades | type | tif | reference | 80 | party1 | BTC/ETH | buy | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p1-ioc-pas | 81 And the parties place the following orders: 82 | party | market id | side | volume | price | resulting trades | type | tif | reference | 83 | party5 | BTC/ETH | sell | 5 | 0 | 2 | TYPE_MARKET | TIF_IOC | p5-ioc-agg | 84 Then the following trades should be executed: 85 | buyer | price | size | seller | 86 | party1 | 1000 | 2 | party5 | 87 | party1 | 998 | 1 | party5 | 88 # filled the order of party 1, the remainder of p5's order is marked as partially filled. 89 And the orders should have the following status: 90 | party | reference | status | 91 | party1 | p1-ioc-pas | STATUS_FILLED | 92 | party5 | p5-ioc-agg | STATUS_PARTIALLY_FILLED | 93 94 # To ensure the order is cancelled (meaning in a final state) let's ensure we can't amend the order: 95 When the parties amend the following orders: 96 | party | reference | tif | size delta | error | 97 | party5 | p5-ioc-agg | TIF_IOC | -1 | OrderError: Invalid Order ID | 98 99 When the network moves ahead "1" blocks 100 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 101 And the market data for the market "BTC/ETH" should be: 102 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 103 | 998 | TRADING_MODE_CONTINUOUS | 3600 | 959 | 1042 | 0 | 0 | 0 | 104 105 Scenario: 0068-MATC-064: If there is no match the order will be cancelled. (0068-MATC-063: Incoming LIMIT orders will be matched against the opposite side of the book) 106 # set up the book with some volume the market order will uncross with 107 When the parties place the following orders: 108 | party | market id | side | volume | price | resulting trades | type | tif | reference | 109 | party5 | BTC/ETH | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_IOC | p5-ioc-agg | 110 Then the orders should have the following status: 111 | party | reference | status | 112 | party5 | p5-ioc-agg | STATUS_STOPPED | 113 114 When the network moves ahead "1" blocks 115 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 116 And the market data for the market "BTC/ETH" should be: 117 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 118 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 959 | 1042 | 0 | 0 | 0 | 119 120 Scenario: 0068-MATC-065: If there is a partial match then the remaining will be cancelled. (0068-MATC-063: Incoming LIMIT orders will be matched against the opposite side of the book) 121 # set up the book with some volume the limit order will partially uncross with 122 When the parties place the following orders: 123 | party | market id | side | volume | price | resulting trades | type | tif | reference | 124 | party1 | BTC/ETH | buy | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p1-ioc-pas | 125 And the parties place the following orders: 126 | party | market id | side | volume | price | resulting trades | type | tif | reference | 127 | party5 | BTC/ETH | sell | 5 | 1000 | 1 | TYPE_LIMIT | TIF_IOC | p5-ioc-agg | 128 Then the following trades should be executed: 129 | buyer | price | size | seller | 130 | party1 | 1000 | 2 | party5 | 131 # filled the order of party 1, the remainder of p5's order is marked as partially filled. 132 And the orders should have the following status: 133 | party | reference | status | 134 | party1 | p1-ioc-pas | STATUS_FILLED | 135 | party5 | p5-ioc-agg | STATUS_PARTIALLY_FILLED | 136 137 # To ensure the order is cancelled (meaning in a final state) let's ensure we can't amend the order: 138 When the parties amend the following orders: 139 | party | reference | tif | size delta | error | 140 | party5 | p5-ioc-agg | TIF_IOC | -1 | OrderError: Invalid Order ID | 141 142 When the network moves ahead "1" blocks 143 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 144 And the market data for the market "BTC/ETH" should be: 145 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 146 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 959 | 1042 | 0 | 0 | 0 |