code.vegaprotocol.io/vega@v0.79.0/core/integration/features/orders/spot-amend-order.feature (about) 1 Feature: Amend spot orders 2 3 Background: 4 Given the fees configuration named "fees-config-1": 5 | maker fee | infrastructure fee | 6 | 0.005 | 0.002 | 7 And the simple risk model named "my-simple-risk-model": 8 | long | short | max move up | min move down | probability of trading | 9 | 0.08628781058136630000 | 0.09370922348428490000 | -1 | -1 | 0.2 | 10 And the fees configuration named "my-fees-config": 11 | maker fee | infrastructure fee | 12 | 0.004 | 0.001 | 13 And the spot markets: 14 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | sla params | 15 | BTC/ETH | BTC/ETH | BTC | ETH | my-simple-risk-model | 1 | fees-config-1 | default-none | default-basic | 16 Given the parties deposit on asset's general account the following amount: 17 | party | asset | amount | 18 | party1 | ETH | 1000 | 19 | party2 | BTC | 100 | 20 And the following network parameters are set: 21 | name | value | 22 | market.auction.minimumDuration | 1 | 23 | network.markPriceUpdateMaximumFrequency | 0s | 24 25 Scenario: Reduce size with delta success and not losing position in order book (0004-AMND-0032) 26 # setup accounts 27 Given the parties deposit on asset's general account the following amount: 28 | party | asset | amount | 29 | myboi | BTC | 10000 | 30 | myboi | ETH | 10000 | 31 | myboi2 | BTC | 10000 | 32 | myboi2 | ETH | 10000 | 33 | myboi3 | BTC | 10000 | 34 | myboi3 | ETH | 10000 | 35 | aux | BTC | 100000 | 36 | aux | ETH | 100000 | 37 | aux2 | BTC | 100000 | 38 | aux2 | ETH | 100000 | 39 40 When the parties place the following orders: 41 | party | market id | side | volume | price | resulting trades | type | tif | 42 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 43 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 44 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 45 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 46 Then the opening auction period ends for market "BTC/ETH" 47 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 48 49 And the parties place the following orders: 50 | party | market id | side | volume | price | resulting trades | type | tif | reference | 51 | myboi | BTC/ETH | sell | 10 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 52 | myboi2 | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi2-ref-1 | 53 54 # reducing size with delta 55 Then the parties amend the following orders: 56 | party | reference | price | size delta | tif | 57 | myboi | myboi-ref-1 | 0 | -2 | TIF_GTC | 58 59 And the orders should have the following states: 60 | party | market id | reference | side | volume | remaining | price | status | 61 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 8 | 2 | STATUS_ACTIVE | 62 63 # matching the order now 64 # this should match with the size 3 order of myboi 65 When the parties place the following orders: 66 | party | market id | side | volume | price | resulting trades | type | tif | reference | 67 | myboi3 | BTC/ETH | buy | 3 | 2 | 1 | TYPE_LIMIT | TIF_GTC | myboi3-ref-1 | 68 69 Then the following trades should be executed: 70 | buyer | seller | price | size | 71 | myboi3 | myboi | 2 | 3 | 72 73 And the orders should have the following states: 74 | party | market id | reference | side | volume | remaining | price | status | 75 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 5 | 2 | STATUS_ACTIVE | 76 77 # reducing size with target 78 When the parties amend the following orders: 79 | party | reference | price | size | tif | 80 | myboi | myboi-ref-1 | 0 | 6 | TIF_GTC | 81 82 Then the orders should have the following states: 83 | party | market id | reference | side | volume | remaining | price | status | 84 | myboi | BTC/ETH | myboi-ref-1 | sell | 6 | 3 | 2 | STATUS_ACTIVE | 85 86 Scenario: Increase size success and loosing position in order book (0004-AMND-033) 87 Given the parties deposit on asset's general account the following amount: 88 | party | asset | amount | 89 | myboi | BTC | 10000 | 90 | myboi2 | BTC | 10000 | 91 | myboi3 | BTC | 100000000 | 92 | aux | BTC | 100000 | 93 | aux2 | BTC | 100000 | 94 | myboi | ETH | 10000 | 95 | myboi2 | ETH | 10000 | 96 | myboi3 | ETH | 100000000 | 97 | aux | ETH | 100000 | 98 | aux2 | ETH | 100000 | 99 100 When the parties place the following orders: 101 | party | market id | side | volume | price | resulting trades | type | tif | 102 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 103 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 104 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 105 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 106 Then the opening auction period ends for market "BTC/ETH" 107 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 108 109 When the parties place the following orders: 110 | party | market id | side | volume | price | resulting trades | type | tif | reference | 111 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 112 | myboi2 | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-2 | 113 114 And the parties amend the following orders: 115 | party | reference | price | size delta | tif | 116 | myboi | myboi-ref-1 | 0 | 3 | TIF_GTC | 117 118 Then the orders should have the following states: 119 | party | market id | reference | side | volume | remaining | price | status | 120 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 8 | 2 | STATUS_ACTIVE | 121 122 When the parties place the following orders: 123 | party | market id | side | volume | price | resulting trades | type | tif | reference | 124 | myboi3 | BTC/ETH | buy | 3 | 2 | 1 | TYPE_LIMIT | TIF_GTC | myboi-ref-3 | 125 126 Then the following trades should be executed: 127 | buyer | seller | price | size | 128 | myboi3 | myboi2 | 2 | 3 | 129 130 And the orders should have the following states: 131 | party | market id | reference | side | volume | remaining | price | status | 132 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 8 | 2 | STATUS_ACTIVE | 133 | myboi2 | BTC/ETH | myboi-ref-2 | sell | 5 | 2 | 2 | STATUS_ACTIVE | 134 135 When the parties amend the following orders: 136 | party | reference | price | size | tif | 137 | myboi2 | myboi-ref-2 | 0 | 10 | TIF_GTC | 138 139 Then the orders should have the following states: 140 | party | market id | reference | side | volume | remaining | price | status | 141 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 8 | 2 | STATUS_ACTIVE | 142 | myboi2 | BTC/ETH | myboi-ref-2 | sell | 10 | 7 | 2 | STATUS_ACTIVE | 143 144 When the parties place the following orders: 145 | party | market id | side | volume | price | resulting trades | type | tif | reference | 146 | myboi3 | BTC/ETH | buy | 3 | 2 | 1 | TYPE_LIMIT | TIF_GTC | myboi-ref-3 | 147 148 Then the following trades should be executed: 149 | buyer | seller | price | size | 150 | myboi3 | myboi | 2 | 3 | 151 And the orders should have the following states: 152 | party | market id | reference | side | volume | remaining | price | status | 153 | myboi | BTC/ETH | myboi-ref-1 | sell | 8 | 5 | 2 | STATUS_ACTIVE | 154 | myboi2 | BTC/ETH | myboi-ref-2 | sell | 10 | 7 | 2 | STATUS_ACTIVE | 155 156 Scenario: Reduce size success and order cancelled as remaining is less than or equal to 0 (0004-AMND-058) 157 Given the parties deposit on asset's general account the following amount: 158 | party | asset | amount | 159 | myboi | BTC | 10000 | 160 | aux | BTC | 100000 | 161 | aux2 | BTC | 100000 | 162 | myboi | ETH | 10000 | 163 | aux | ETH | 100000 | 164 | aux2 | ETH | 100000 | 165 166 When the parties place the following orders: 167 | party | market id | side | volume | price | resulting trades | type | tif | 168 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 169 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 170 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 171 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 172 Then the opening auction period ends for market "BTC/ETH" 173 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 174 175 When the parties place the following orders: 176 | party | market id | side | volume | price | resulting trades | type | tif | reference | 177 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 178 179 And the parties amend the following orders: 180 | party | reference | price | size delta | tif | 181 | myboi | myboi-ref-1 | 0 | -5 | TIF_GTC | 182 183 Then the orders should have the following status: 184 | party | reference | status | 185 | myboi | myboi-ref-1 | STATUS_CANCELLED | 186 187 When the parties place the following orders: 188 | party | market id | side | volume | price | resulting trades | type | tif | reference | 189 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 190 191 And the parties amend the following orders: 192 | party | reference | price | size | tif | 193 | myboi | myboi-ref-1 | 0 | 0 | TIF_GTC | 194 195 Then the orders should have the following status: 196 | party | reference | status | 197 | myboi | myboi-ref-1 | STATUS_CANCELLED | 198 199 Scenario: Amend to invalid tif is rejected (0004-AMND-034) 200 Given the parties deposit on asset's general account the following amount: 201 | party | asset | amount | 202 | myboi | BTC | 10000 | 203 | aux | BTC | 100000 | 204 | aux2 | BTC | 100000 | 205 | myboi | ETH | 10000 | 206 | aux | ETH | 100000 | 207 | aux2 | ETH | 100000 | 208 209 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 210 When the parties place the following orders: 211 | party | market id | side | volume | price | resulting trades | type | tif | 212 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 213 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 214 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 215 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 216 Then the opening auction period ends for market "BTC/ETH" 217 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 218 219 Then the parties place the following orders: 220 | party | market id | side | volume | price | resulting trades | type | tif | reference | 221 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 222 223 224 # cannot amend TIF to TIF_FOK so this will be rejected 225 Then the parties amend the following orders: 226 | party | reference | price | size delta | tif | error | 227 | myboi | myboi-ref-1 | 0 | 0 | TIF_FOK | OrderError: Cannot amend TIF to FOK or IOC | 228 229 Scenario: TIF_GTC to TIF_GTT rejected without expiry (0004-AMND-034) 230 Given the parties deposit on asset's general account the following amount: 231 | party | asset | amount | 232 | myboi | BTC | 10000 | 233 | aux | BTC | 100000 | 234 | myboi | ETH | 10000 | 235 | aux | ETH | 100000 | 236 237 When the parties place the following orders: 238 | party | market id | side | volume | price | resulting trades | type | tif | 239 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 240 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 241 242 Then the parties place the following orders: 243 | party | market id | side | volume | price | resulting trades | type | tif | reference | 244 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 245 246 # TIF_GTT rejected because of missing expiration date 247 Then the parties amend the following orders: 248 | party | reference | price | size delta | tif | error | 249 | myboi | myboi-ref-1 | 0 | 0 | TIF_GTT | OrderError: Cannot amend order to GTT without an expiryAt field | 250 251 Scenario: TIF_GTC to TIF_GTT with time in the past (0004-AMND-034) 252 Given the parties deposit on asset's general account the following amount: 253 | party | asset | amount | 254 | myboi | BTC | 10000 | 255 | aux | BTC | 100000 | 256 | aux2 | BTC | 100000 | 257 | myboi | ETH | 10000 | 258 | aux | ETH | 100000 | 259 | aux2 | ETH | 100000 | 260 261 When the parties place the following orders: 262 | party | market id | side | volume | price | resulting trades | type | tif | 263 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 264 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 265 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 266 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 267 Then the opening auction period ends for market "BTC/ETH" 268 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 269 270 Then the parties place the following orders: 271 | party | market id | side | volume | price | resulting trades | type | tif | reference | 272 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 273 274 # reducing size, remaining goes from 2 to -1, this will cancel 275 Then the parties amend the following orders: 276 | party | reference | price | expiration date | size delta | tif | 277 | myboi | myboi-ref-1 | 2 | 2030-11-30T00:00:00Z | 0 | TIF_GTT | 278 279 Scenario: Any attempt to amend to or from the TIF values GFA and GFN will result in a rejected amend (0004-AMND-035) 280 Given the parties deposit on asset's general account the following amount: 281 | party | asset | amount | 282 | myboi | BTC | 10000 | 283 | aux | BTC | 100000 | 284 | aux2 | BTC | 100000 | 285 | myboi | ETH | 10000 | 286 | aux | ETH | 100000 | 287 | aux2 | ETH | 100000 | 288 289 When the parties place the following orders: 290 | party | market id | side | volume | price | resulting trades | type | tif | 291 | aux | BTC/ETH | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 292 | aux | BTC/ETH | sell | 1 | 10001 | 0 | TYPE_LIMIT | TIF_GTC | 293 | aux2 | BTC/ETH | buy | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 294 | aux | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GTC | 295 296 Then the opening auction period ends for market "BTC/ETH" 297 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH" 298 299 Then the parties place the following orders: 300 | party | market id | side | volume | price | resulting trades | type | tif | reference | 301 | myboi | BTC/ETH | sell | 5 | 2 | 0 | TYPE_LIMIT | TIF_GTC | myboi-ref-1 | 302 303 Then the parties amend the following orders: 304 | party | reference | price | tif | error | 305 | myboi | myboi-ref-1 | 2 | TIF_GFA | OrderError: Cannot amend TIF to GFA or GFN | 306 | myboi | myboi-ref-1 | 2 | TIF_GFN | OrderError: Cannot amend TIF to GFA or GFN | 307 308 Then the parties place the following orders: 309 | party | market id | side | volume | price | resulting trades | type | tif | reference | 310 | myboi | BTC/ETH | sell | 1 | 2 | 0 | TYPE_LIMIT | TIF_GFN | myboi-ref-2 | 311 312 Then the parties amend the following orders: 313 | party | reference | price | tif | error | 314 | myboi | myboi-ref-2 | 2 | TIF_GTC | OrderError: Cannot amend TIF from GFA or GFN | 315