code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-107.feature (about) 1 Feature: switch to isolated margin without position and with orders in 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 liquidity monitoring parameters: 8 | name | triggering ratio | time window | scaling factor | 9 | lqm-params | 0.00 | 24h | 1e-9 | 10 And the simple risk model named "simple-risk-model": 11 | long | short | max move up | min move down | probability of trading | 12 | 0.1 | 0.1 | 100 | -100 | 0.2 | 13 And the markets: 14 | 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 | 15 | ETH/FEB23 | ETH | USD | lqm-params | simple-risk-model | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.25 | 0 | default-futures | 16 17 And the following network parameters are set: 18 | name | value | 19 | market.auction.minimumDuration | 8 | 20 Given the average block duration is "1" 21 22 Scenario: 001 switch to isolated margin during auction 23 Given the parties deposit on asset's general account the following amount: 24 | party | asset | amount | 25 | buySideProvider | USD | 100000000000 | 26 | sellSideProvider | USD | 100000000000 | 27 | party1 | USD | 273500 | 28 29 When the parties submit the following liquidity provision: 30 | id | party | market id | commitment amount | fee | lp type | 31 | lp1 | party1 | ETH/FEB23 | 1000 | 0.1 | submission | 32 33 And the parties place the following orders: 34 | party | market id | side | volume | price | resulting trades | type | tif | reference | 35 | buySideProvider | ETH/FEB23 | buy | 10 | 14900 | 0 | TYPE_LIMIT | TIF_GTC | | 36 | buySideProvider | ETH/FEB23 | buy | 6 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 37 | party1 | ETH/FEB23 | sell | 1 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | p1-sell | 38 | sellSideProvider | ETH/FEB23 | sell | 1 | 200000 | 0 | TYPE_LIMIT | TIF_GTC | | 39 | sellSideProvider | ETH/FEB23 | sell | 10 | 200100 | 0 | TYPE_LIMIT | TIF_GTC | | 40 41 When the network moves ahead "2" blocks 42 And the order book should have the following volumes for market "ETH/FEB23": 43 | side | price | volume | 44 | buy | 14900 | 10 | 45 | buy | 15800 | 6 | 46 | sell | 15800 | 1 | 47 | sell | 15900 | 0 | 48 | sell | 200000 | 1 | 49 And the parties should have the following margin levels: 50 | party | market id | maintenance | 51 | buySideProvider | ETH/FEB23 | 24380 | 52 53 Then the parties should have the following account balances: 54 | party | asset | market id | margin | general | bond | 55 | party1 | USD | ETH/FEB23 | 1896 | 270604 | 1000 | 56 57 And the market data for the market "ETH/FEB23" should be: 58 | mark price | trading mode | 59 | 0 | TRADING_MODE_OPENING_AUCTION | 60 61 #AC0019-MCAL-107: switch to isolated margin without position and with orders with margin factor such that position margin is < initial should fail in auction 62 And the parties submit update margin mode: 63 | party | market | margin_mode | margin_factor | error | 64 | 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) | 65 66 And the parties should have the following margin levels: 67 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 68 | party1 | ETH/FEB23 | 1580 | 1738 | 1896 | 2212 | cross margin | 0 | 0 | 69 70 #AC0019-MCAL-123:switch to isolated margin without position and with orders successful in auction 71 And the parties submit update margin mode: 72 | party | market | margin_mode | margin_factor | error | 73 | party1 | ETH/FEB23 | isolated margin | 0.6 | | 74 75 # @jiajia 76 # the party has no position so position initial/maintenance is 0... 77 And the parties should have the following margin levels: 78 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 79 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.6 | 9480 | 80 81 #AC0019-MCAL-131:increase margin factor in isolated margin without position and with orders successful in auction 82 And the parties submit update margin mode: 83 | party | market | margin_mode | margin_factor | error | 84 | party1 | ETH/FEB23 | isolated margin | 0.7 | | 85 86 # same, the don't have position so their maintenance margin (which doesn't consider orders) is 0 87 And the parties should have the following margin levels: 88 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 89 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.7 | 11060 | 90 91 And the orders should have the following status: 92 | party | reference | status | 93 | party1 | p1-sell | STATUS_ACTIVE | 94 95 When the parties cancel the following orders: 96 | party | reference | 97 | party1 | p1-sell | 98 99 And the orders should have the following status: 100 | party | reference | status | 101 | party1 | p1-sell | STATUS_CANCELLED | 102 103 And the market data for the market "ETH/FEB23" should be: 104 | mark price | trading mode | 105 | 0 | TRADING_MODE_OPENING_AUCTION | 106 107 #AC0019-MCAL-135:switch to cross margin without position and no orders successful in auction 108 And the parties submit update margin mode: 109 | party | market | margin_mode | margin_factor | error | 110 | party1 | ETH/FEB23 | cross margin | | no market observable price | 111 112 And the parties should have the following margin levels: 113 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 114 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | isolated margin | 0.7 | 0 | 115 116 And the parties place the following orders: 117 | party | market id | side | volume | price | resulting trades | type | tif | reference | 118 | sellSideProvider | ETH/FEB23 | sell | 1 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 119 120 #AC0019-MCAL-103:switch back to cross margin with no position and no order in continuous mode in auction 121 And the parties submit update margin mode: 122 | party | market | margin_mode | 123 | party1 | ETH/FEB23 | cross margin | 124 125 And the parties should have the following margin levels: 126 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 127 | party1 | ETH/FEB23 | 0 | 0 | 0 | 0 | cross margin | 0 | 0 | 128 129