code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-105.feature (about) 1 Feature: switch to isolated margin with position during auction 2 Background: 3 # switch between cross margin and isolated margin mode during auction 4 Given the following network parameters are set: 5 | name | value | 6 | network.markPriceUpdateMaximumFrequency | 0s | 7 And the price monitoring named "my-price-monitoring": 8 | horizon | probability | auction extension | 9 | 5 | 0.95 | 6 | 10 | 10 | 0.99 | 8 | 11 And the liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 0.00 | 24h | 1e-9 | 14 And the simple risk model named "simple-risk-model": 15 | long | short | max move up | min move down | probability of trading | 16 | 0.1 | 0.1 | 100 | -100 | 0.2 | 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 | my-price-monitoring | default-eth-for-future | 0.25 | 0 | default-futures | 20 21 And the following network parameters are set: 22 | name | value | 23 | market.auction.minimumDuration | 1 | 24 Given the average block duration is "1" 25 26 Scenario: 001 switch to isolated margin during auction 27 Given the parties deposit on asset's general account the following amount: 28 | party | asset | amount | 29 | buySideProvider | USD | 100000000000 | 30 | sellSideProvider | USD | 100000000000 | 31 | party1 | USD | 14110 | 32 33 When the parties submit the following liquidity provision: 34 | id | party | market id | commitment amount | fee | lp type | 35 | lp1 | party1 | ETH/FEB23 | 1000 | 0.1 | submission | 36 37 And the parties place the following orders: 38 | party | market id | side | volume | price | resulting trades | type | tif | reference | 39 | buySideProvider | ETH/FEB23 | buy | 10 | 14900 | 0 | TYPE_LIMIT | TIF_GTC | | 40 | buySideProvider | ETH/FEB23 | buy | 3 | 15600 | 0 | TYPE_LIMIT | TIF_GTC | | 41 | buySideProvider | ETH/FEB23 | buy | 1 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 42 | party1 | ETH/FEB23 | sell | 1 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | p1-sell | 43 | sellSideProvider | ETH/FEB23 | sell | 1 | 200000 | 0 | TYPE_LIMIT | TIF_GTC | | 44 | sellSideProvider | ETH/FEB23 | sell | 10 | 200100 | 0 | TYPE_LIMIT | TIF_GTC | | 45 46 When the network moves ahead "2" blocks 47 And the market data for the market "ETH/FEB23" should be: 48 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 49 | 15800 | TRADING_MODE_CONTINUOUS | 5 | 15701 | 15899 | 0 | 1000 | 1 | 50 51 Then the parties should have the following account balances: 52 | party | asset | market id | margin | general | bond | 53 | party1 | USD | ETH/FEB23 | 6636 | 6474 | 1000 | 54 55 And the parties should have the following margin levels: 56 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 57 | party1 | ETH/FEB23 | 5530 | 6083 | 6636 | 7742 | cross margin | 0 | 0 | 58 59 #AC0019-MCAL-104: switch to isolated margin with position and no orders with margin factor such that position margin is < initial should fail in continuous 60 And the parties submit update margin mode: 61 | party | market | margin_mode | margin_factor | error | 62 | party1 | ETH/FEB23 | isolated margin | 0.1 | margin factor (0.1) must be greater than max(riskFactorLong (0.1), riskFactorShort (0.1)) + linearSlippageFactor (0.25) | 63 64 #AC0019-MCAL-112:switch to isolated margin with position and no orders with margin factor such that there is insufficient balance in the general account in continuous mode 65 And the parties submit update margin mode: 66 | party | market | margin_mode | margin_factor | error | 67 | party1 | ETH/FEB23 | isolated margin | 0.9 | insufficient balance in general account to cover for required order margin | 68 Then the parties should have the following account balances: 69 | party | asset | market id | margin | general | bond | 70 | party1 | USD | ETH/FEB23 | 6636 | 6474 | 1000 | 71 72 And the parties should have the following margin levels: 73 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 74 | party1 | ETH/FEB23 | 5530 | 6083 | 6636 | 7742 | cross margin | 0 | 0 | 75 76 #AC0019-MCAL-120: witch to isolated margin with position and no orders successful in continuous mode 77 And the parties submit update margin mode: 78 | party | market | margin_mode | margin_factor | error | 79 | party1 | ETH/FEB23 | isolated margin | 0.6 | | 80 Then the parties should have the following account balances: 81 | party | asset | market id | margin | general | bond | 82 | party1 | USD | ETH/FEB23 | 9480 | 3630 | 1000 | 83 84 And the parties should have the following margin levels: 85 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 86 | party1 | ETH/FEB23 | 5530 | 0 | 6636 | 0 | isolated margin | 0.6 | 0 | 87 88 And the parties submit update margin mode: 89 | party | market | margin_mode | margin_factor | error | 90 | party1 | ETH/FEB23 | cross margin | | | 91 92 #now trigger price monitoring auction 93 And the parties place the following orders: 94 | party | market id | side | volume | price | resulting trades | type | tif | reference | 95 | sellSideProvider | ETH/FEB23 | sell | 1 | 15600 | 0 | TYPE_LIMIT | TIF_GTC | | 96 And the market data for the market "ETH/FEB23" should be: 97 | mark price | trading mode | 98 | 15800 | TRADING_MODE_MONITORING_AUCTION | 99 100 #AC0019-MCAL-105: switch to isolated margin with position and no orders with margin factor such that position margin is < initial should fail in auction 101 And the parties submit update margin mode: 102 | party | market | margin_mode | margin_factor | error | 103 | party1 | ETH/FEB23 | isolated margin | 0.1 | margin factor (0.1) must be greater than max(riskFactorLong (0.1), riskFactorShort (0.1)) + linearSlippageFactor (0.25) | 104 105 When the network moves ahead "1" blocks 106 #AC0019-MCAL-113:switch to isolated margin with position and no orders with margin factor such that there is insufficient balance in the general account in continuous mode 107 And the parties submit update margin mode: 108 | party | market | margin_mode | margin_factor | error | 109 | party1 | ETH/FEB23 | isolated margin | 0.95 | insufficient balance in general account to cover for required order margin | 110 Then the parties should have the following account balances: 111 | party | asset | market id | margin | general | bond | 112 | party1 | USD | ETH/FEB23 | 9480 | 3630 | 1000 | 113 114 And the parties should have the following margin levels: 115 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 116 | party1 | ETH/FEB23 | 5530 | 6083 | 6636 | 7742 | cross margin | 0 | 0 | 117 118 #AC0019-MCAL-121:switch to isolated margin with position and no orders successful in auction 119 And the parties submit update margin mode: 120 | party | market | margin_mode | margin_factor | error | 121 | party1 | ETH/FEB23 | isolated margin | 0.6 | | 122 Then the parties should have the following account balances: 123 | party | asset | market id | margin | general | bond | 124 | party1 | USD | ETH/FEB23 | 9480 | 3630 | 1000 | 125 126 And the parties should have the following margin levels: 127 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 128 | party1 | ETH/FEB23 | 5530 | 0 | 6636 | 0 | isolated margin | 0.6 | 0 | 129 130 #AC0019-MCAL-128:increase margin factor in isolated margin with position and no orders successful in auction 131 And the parties submit update margin mode: 132 | party | market | margin_mode | margin_factor | error | 133 | party1 | ETH/FEB23 | isolated margin | 0.7 | | 134 Then the parties should have the following account balances: 135 | party | asset | market id | margin | general | bond | 136 | party1 | USD | ETH/FEB23 | 11060 | 2050 | 1000 | 137 138 And the parties should have the following margin levels: 139 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 140 | party1 | ETH/FEB23 | 5530 | 0 | 6636 | 0 | isolated margin | 0.7 | 0 | 141 142 #AC0019-MCAL-040:When increasing the `margin factor` and the party does not have enough asset in the general account to cover the new maintenance margin, then the new margin factor will be rejected 143 And the parties submit update margin mode: 144 | party | market | margin_mode | margin_factor | error | 145 | party1 | ETH/FEB23 | isolated margin | 0.9 | insufficient balance in general account to cover for required order margin | 146 147 #AC0019-MCAL-137:switch to cross margin with position and no orders successful in auction 148 And the parties submit update margin mode: 149 | party | market | margin_mode | margin_factor | error | 150 | party1 | ETH/FEB23 | cross margin | | | 151 Then the parties should have the following account balances: 152 | party | asset | market id | margin | general | bond | 153 | party1 | USD | ETH/FEB23 | 11060 | 2050 | 1000 | 154 155 And the parties should have the following margin levels: 156 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 157 | party1 | ETH/FEB23 | 5530 | 6083 | 6636 | 7742 | cross margin | 0 | 0 | 158 159 And the market data for the market "ETH/FEB23" should be: 160 | mark price | trading mode | 161 | 15800 | TRADING_MODE_MONITORING_AUCTION | 162