code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/margin-for-parked-orders.feature (about) 1 Feature: Test for parked/unparked pegged orders 2 Background: Background name: 3 Given the following network parameters are set: 4 | name | value | 5 | network.markPriceUpdateMaximumFrequency | 0s | 6 | limits.markets.maxPeggedOrders | 6 | 7 And the average block duration is "1" 8 And the liquidity monitoring parameters: 9 | name | triggering ratio | time window | scaling factor | 10 | lqm-params | 0.00 | 24h | 1e-9 | 11 And the simple risk model named "simple-risk-model": 12 | long | short | max move up | min move down | probability of trading | 13 | 0.1 | 0.1 | 100 | -100 | 0.2 | 14 And the price monitoring named "price-monitoring": 15 | horizon | probability | auction extension | 16 | 3600 | 0.95 | 3 | 17 And the markets: 18 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 19 | ETH/FEB23 | ETH | USD | lqm-params | simple-risk-model | default-margin-calculator | 1 | default-none | price-monitoring | default-eth-for-future | 0.25 | 0 | default-futures | 20 And the parties deposit on asset's general account the following amount: 21 | party | asset | amount | 22 | lpprov | USD | 100000000000 | 23 | aux_buys | USD | 100000000000 | 24 | aux_sells | USD | 100000000000 | 25 | test_party | USD | 100000 | 26 27 When the parties place the following orders: 28 | party | market id | side | volume | price | resulting trades | type | tif | reference | 29 | aux_buys | ETH/FEB23 | buy | 10 | 995 | 0 | TYPE_LIMIT | TIF_GTC | buy-1 | 30 | aux_buys | ETH/FEB23 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | buy-trade-1 | 31 | aux_sells | ETH/FEB23 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | sell-trade-1 | 32 | aux_sells | ETH/FEB23 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | sell-1 | 33 | aux_sells | ETH/FEB23 | sell | 10 | 1505 | 0 | TYPE_LIMIT | TIF_GTC | sell-2 | 34 | lpprov | ETH/FEB23 | buy | 10 | 100 | 0 | TYPE_LIMIT | TIF_GTC | lp-buy-1 | 35 | lpprov | ETH/FEB23 | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | lp-sell-1 | 36 And the parties submit the following liquidity provision: 37 | id | party | market id | commitment amount | fee | lp type | 38 | lp1 | lpprov | ETH/FEB23 | 900000 | 0.1 | submission | 39 | lp1 | lpprov | ETH/FEB23 | 900000 | 0.1 | submission | 40 41 Then the opening auction period ends for market "ETH/FEB23" 42 And the mark price should be "1000" for the market "ETH/FEB23" 43 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 44 And the network moves ahead "1" blocks 45 46 Scenario: In cross margin mode, party park pegged order, switch to isolated margin and the pegged order is cancelled 0019-MCAL-143 47 # enter pegged order here 48 Given the parties submit update margin mode: 49 | party | market | margin_mode | margin_factor | error | 50 | test_party | ETH/FEB23 | cross margin | | | 51 When the parties place the following pegged orders: 52 | party | market id | side | volume | pegged reference | offset | reference | 53 | test_party | ETH/FEB23 | buy | 5 | MID | 1 | buy_peg | 54 Then the parties should have the following margin levels: 55 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 56 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 57 And the parties should have the following account balances: 58 | party | asset | market id | margin | general | 59 | test_party | USD | ETH/FEB23 | 600 | 99400 | 60 61 Given the orders should have the following status: 62 | party | reference | status | 63 | test_party | buy_peg | STATUS_ACTIVE | 64 When the parties place the following orders: 65 | party | market id | side | volume | price | resulting trades | type | tif | reference | 66 | aux_buys | ETH/FEB23 | buy | 1000 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | auction-trigger-1 | 67 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 68 And the orders should have the following status: 69 | party | reference | status | 70 | test_party | buy_peg | STATUS_PARKED | 71 And the parties should have the following margin levels: 72 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 73 | test_party | ETH/FEB23 | 0 | 0 | 0 | 0 | cross margin | | 0 | 74 And the parties should have the following account balances: 75 | party | asset | market id | margin | general | 76 | test_party | USD | ETH/FEB23 | 0 | 100000 | 77 78 Given the parties cancel the following orders: 79 | party | reference | 80 | aux_buys | auction-trigger-1 | 81 When the parties submit update margin mode: 82 | party | market | margin_mode | margin_factor | error | 83 | test_party | ETH/FEB23 | isolated margin | 0.50 | | 84 Then the orders should have the following status: 85 | party | reference | status | 86 | test_party | buy_peg | STATUS_CANCELLED | 87 88 Given the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 89 When the network moves ahead "4" blocks 90 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 91 And the parties should have the following margin levels: 92 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 93 | test_party | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.50 | 0 | 94 And the parties should have the following account balances: 95 | party | asset | market id | margin | general | order margin | 96 | test_party | USD | ETH/FEB23 | 0 | 100000 | 0 | 97 98 Scenario: In cross margin mode, party park pegged order, switch to isolated margin and the pegged order is cancelled 0019-MCAL-144 99 # enter pegged iceberg order here 100 Given the parties submit update margin mode: 101 | party | market | margin_mode | margin_factor | error | 102 | test_party | ETH/FEB23 | cross margin | | | 103 When the parties place the following pegged iceberg orders: 104 | party | market id | peak size | minimum visible size | side | reference | pegged reference | volume | offset | 105 | test_party | ETH/FEB23 | 5 | 2 | buy | buy_ice_peg | MID | 5 | 1 | 106 # (1000 - 1) * 5 * 0.5 = 2492 107 Then the parties should have the following margin levels: 108 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 109 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 110 And the parties should have the following account balances: 111 | party | asset | market id | margin | general | 112 | test_party | USD | ETH/FEB23 | 600 | 99400 | 113 114 Given the orders should have the following status: 115 | party | reference | status | 116 | test_party | buy_ice_peg | STATUS_ACTIVE | 117 When the parties place the following orders: 118 | party | market id | side | volume | price | resulting trades | type | tif | reference | 119 | aux_buys | ETH/FEB23 | buy | 1000 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | auction-trigger-1 | 120 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 121 And the orders should have the following status: 122 | party | reference | status | 123 | test_party | buy_ice_peg | STATUS_PARKED | 124 And the parties should have the following margin levels: 125 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 126 | test_party | ETH/FEB23 | 0 | 0 | 0 | 0 | cross margin | | 0 | 127 And the parties should have the following account balances: 128 | party | asset | market id | margin | general | 129 | test_party | USD | ETH/FEB23 | 0 | 100000 | 130 131 Given the parties cancel the following orders: 132 | party | reference | 133 | aux_buys | auction-trigger-1 | 134 When the parties submit update margin mode: 135 | party | market | margin_mode | margin_factor | error | 136 | test_party | ETH/FEB23 | isolated margin | 0.50 | | 137 Then the orders should have the following status: 138 | party | reference | status | 139 | test_party | buy_ice_peg | STATUS_CANCELLED | 140 141 Given the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 142 When the network moves ahead "4" blocks 143 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 144 And the parties should have the following margin levels: 145 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 146 | test_party | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.50 | 0 | 147 And the parties should have the following account balances: 148 | party | asset | market id | margin | general | order margin | 149 | test_party | USD | ETH/FEB23 | 0 | 100000 | 0 | 150 151 Scenario: In cross margin mode, partially fill pegged order, park then switch to isolated margin. Pegged order is cancelled 0019-MCAL-147 152 # enter pegged order here 153 Given the parties submit update margin mode: 154 | party | market | margin_mode | margin_factor | error | 155 | test_party | ETH/FEB23 | cross margin | | | 156 And the parties place the following pegged orders: 157 | party | market id | side | volume | pegged reference | offset | reference | 158 | test_party | ETH/FEB23 | buy | 5 | MID | 1 | buy_peg | 159 And the parties place the following orders: 160 | party | market id | side | volume | price | resulting trades | type | tif | reference | 161 | aux_sells | ETH/FEB23 | sell | 2 | 995 | 1 | TYPE_LIMIT | TIF_GTC | pfill_test_order | 162 And the following trades should be executed: 163 | buyer | price | size | seller | 164 | test_party | 997 | 2 | aux_sells | 165 Then the parties should have the following margin levels: 166 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 167 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 168 And the parties should have the following account balances: 169 | party | asset | market id | margin | general | 170 | test_party | USD | ETH/FEB23 | 600 | 99400 | 171 Given the orders should have the following status: 172 | party | reference | status | 173 | test_party | buy_peg | STATUS_ACTIVE | 174 When the parties place the following orders: 175 | party | market id | side | volume | price | resulting trades | type | tif | reference | 176 | aux_buys | ETH/FEB23 | buy | 1000 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | auction-trigger-1 | 177 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 178 And the orders should have the following status: 179 | party | reference | status | 180 | test_party | buy_peg | STATUS_PARKED | 181 And the parties should have the following margin levels: 182 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 183 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 184 And the parties should have the following account balances: 185 | party | asset | market id | margin | general | 186 | test_party | USD | ETH/FEB23 | 600 | 99400 | 187 188 Given the parties cancel the following orders: 189 | party | reference | 190 | aux_buys | auction-trigger-1 | 191 When the parties submit update margin mode: 192 | party | market | margin_mode | margin_factor | error | 193 | test_party | ETH/FEB23 | isolated margin | 0.50 | | 194 Then the orders should have the following status: 195 | party | reference | status | 196 | test_party | buy_peg | STATUS_CANCELLED | 197 198 Given the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 199 When the network moves ahead "4" blocks 200 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 201 And the parties should have the following margin levels: 202 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 203 | test_party | ETH/FEB23 | 698 | 0 | 837 | 0 | isolated margin | 0.50 | 0 | 204 And the parties should have the following account balances: 205 | party | asset | market id | margin | general | order margin | 206 | test_party | USD | ETH/FEB23 | 997 | 99003 | 0 | 207 208 Scenario: In cross margin mode, partially fill pegged order, park then switch to isolated margin. Pegged order is cancelled 0019-MCAL-148 209 # enter pegged iceberg order here 210 Given the parties submit update margin mode: 211 | party | market | margin_mode | margin_factor | error | 212 | test_party | ETH/FEB23 | cross margin | | | 213 When the parties place the following pegged iceberg orders: 214 | party | market id | peak size | minimum visible size | side | reference | pegged reference | volume | offset | 215 | test_party | ETH/FEB23 | 5 | 2 | buy | buy_ice_peg | MID | 5 | 1 | 216 And the parties place the following orders: 217 | party | market id | side | volume | price | resulting trades | type | tif | reference | 218 | aux_sells | ETH/FEB23 | sell | 2 | 995 | 1 | TYPE_LIMIT | TIF_GTC | pfill_test_order | 219 And the following trades should be executed: 220 | buyer | price | size | seller | 221 | test_party | 997 | 2 | aux_sells | 222 Then the parties should have the following margin levels: 223 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 224 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 225 And the parties should have the following account balances: 226 | party | asset | market id | margin | general | 227 | test_party | USD | ETH/FEB23 | 600 | 99400 | 228 Given the orders should have the following status: 229 | party | reference | status | 230 | test_party | buy_ice_peg | STATUS_ACTIVE | 231 When the parties place the following orders: 232 | party | market id | side | volume | price | resulting trades | type | tif | reference | 233 | aux_buys | ETH/FEB23 | buy | 1000 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | auction-trigger-1 | 234 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 235 And the orders should have the following status: 236 | party | reference | status | 237 | test_party | buy_ice_peg | STATUS_PARKED | 238 And the parties should have the following margin levels: 239 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 240 | test_party | ETH/FEB23 | 500 | 550 | 600 | 700 | cross margin | | 0 | 241 And the parties should have the following account balances: 242 | party | asset | market id | margin | general | 243 | test_party | USD | ETH/FEB23 | 600 | 99400 | 244 245 Given the parties cancel the following orders: 246 | party | reference | 247 | aux_buys | auction-trigger-1 | 248 When the parties submit update margin mode: 249 | party | market | margin_mode | margin_factor | error | 250 | test_party | ETH/FEB23 | isolated margin | 0.50 | | 251 Then the orders should have the following status: 252 | party | reference | status | 253 | test_party | buy_ice_peg | STATUS_CANCELLED | 254 255 Given the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 256 When the network moves ahead "4" blocks 257 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 258 And the parties should have the following margin levels: 259 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 260 | test_party | ETH/FEB23 | 698 | 0 | 837 | 0 | isolated margin | 0.50 | 0 | 261 And the parties should have the following account balances: 262 | party | asset | market id | margin | general | order margin | 263 | test_party | USD | ETH/FEB23 | 997 | 99003 | 0 | 264 265 Scenario: In auction a party in isolated margin mode enter pegged order that is rejected 0019-MCAL-049 266 Given the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/FEB23" 267 When the parties place the following orders: 268 | party | market id | side | volume | price | resulting trades | type | tif | reference | 269 | aux_buys | ETH/FEB23 | buy | 1000 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | auction-trigger-1 | 270 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/FEB23" 271 272 Given the parties submit update margin mode: 273 | party | market | margin_mode | margin_factor | error | 274 | test_party | ETH/FEB23 | isolated margin | 0.5 | | 275 When the parties place the following pegged orders: 276 | party | market id | side | volume | pegged reference | offset | reference | error | 277 | test_party | ETH/FEB23 | buy | 5 | MID | 1 | buy_peg | OrderError: pegged orders not allowed in isolated margin mode | 278 And the parties place the following pegged iceberg orders: 279 | party | market id | peak size | minimum visible size | side | reference | pegged reference | volume | offset | error | 280 | test_party | ETH/FEB23 | 5 | 2 | buy | buy_ice_peg | MID | 5 | 1 | OrderError: pegged orders not allowed in isolated margin mode | 281 Then the parties should have the following margin levels: 282 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 283 | test_party | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | | 0 |