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