code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-150.feature (about) 1 Feature: pegged order in isoalted margin is not supported 2 Background: 3 Given the following network parameters are set: 4 | name | value | 5 | network.markPriceUpdateMaximumFrequency | 0s | 6 | limits.markets.maxPeggedOrders | 6 | 7 And the price monitoring named "my-price-monitoring-1": 8 | horizon | probability | auction extension | 9 | 5 | 0.99 | 6 | 10 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.2 | 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 | position decimal places | sla params | 19 | ETH/FEB23 | ETH | USD | lqm-params | simple-risk-model | default-margin-calculator | 1 | default-none | my-price-monitoring-1 | default-eth-for-future | 0.000125 | 0 | 2 | 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: When the party has pegged orders and switches from cross margin mode to isolated margin mode, all the pegged orders will be stopped. (0019-MCAL-050,0019-MCAL-090) 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 | 158550 | 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 | 1000 | 14900 | 0 | TYPE_LIMIT | TIF_GTC | | 40 | buySideProvider | ETH/FEB23 | buy | 300 | 15600 | 0 | TYPE_LIMIT | TIF_GTC | | 41 | party1 | ETH/FEB23 | buy | 100 | 15700 | 0 | TYPE_LIMIT | TIF_GTC | p1-buy-1 | 42 | buySideProvider | ETH/FEB23 | buy | 300 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 43 | party1 | ETH/FEB23 | sell | 300 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | p1-sell-1 | 44 | sellSideProvider | ETH/FEB23 | sell | 600 | 15802 | 0 | TYPE_LIMIT | TIF_GTC | sP-sell | 45 | sellSideProvider | ETH/FEB23 | sell | 300 | 200000 | 0 | TYPE_LIMIT | TIF_GTC | | 46 | sellSideProvider | ETH/FEB23 | sell | 1000 | 200100 | 0 | TYPE_LIMIT | TIF_GTC | | 47 48 When the network moves ahead "2" blocks 49 And the market data for the market "ETH/FEB23" should be: 50 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 51 | 15800 | TRADING_MODE_CONTINUOUS | 5 | 15701 | 15899 | 0 | 1000 | 300 | 52 53 #now we try to place short pegged order which does offset the current short position, order margin should be 0 54 When the parties place the following pegged orders: 55 | party | market id | side | volume | pegged reference | offset | reference | 56 | party1 | ETH/FEB23 | buy | 100 | BID | 10 | buy_peg_1 | 57 | party1 | ETH/FEB23 | buy | 200 | BID | 20 | buy_peg_2 | 58 59 Then the parties should have the following margin levels: 60 | party | market id | maintenance | margin mode | margin factor | order | 61 | party1 | ETH/FEB23 | 9486 | cross margin | 0 | 0 | 62 And the parties should have the following account balances: 63 | party | asset | market id | margin | general | bond | 64 | party1 | USD | ETH/FEB23 | 11383 | 146167 | 1000 | 65 66 #switch to isolated margin 67 And the parties submit update margin mode: 68 | party | market | margin_mode | margin_factor | error | 69 | party1 | ETH/FEB23 | isolated margin | 0.1 | margin factor (0.1) must be greater than max(riskFactorLong (0.1), riskFactorShort (0.2)) + linearSlippageFactor (0.000125) | 70 71 And the parties submit update margin mode: 72 | party | market | margin_mode | margin_factor | error | 73 | party1 | ETH/FEB23 | isolated margin | 0.15 | margin factor (0.15) must be greater than max(riskFactorLong (0.1), riskFactorShort (0.2)) + linearSlippageFactor (0.000125) | 74 75 And the parties submit update margin mode: 76 | party | market | margin_mode | margin_factor | error | 77 | party1 | ETH/FEB23 | isolated margin | 0.21 | required position margin must be greater than initial margin | 78 79 And the parties submit update margin mode: 80 | party | market | margin_mode | margin_factor | error | 81 | party1 | ETH/FEB23 | isolated margin | 0.3 | | 82 83 Then the parties should have the following margin levels: 84 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 85 | party1 | ETH/FEB23 | 9486 | 0 | 11383 | 0 | isolated margin | 0.3 | 0 | 86 87 #0019-MCAL-149:A party with a parked pegged order switches from cross margin mode to isolated margin mode, the parked pegged order is cancelled 88 Then the orders should have the following status: 89 | party | reference | status | 90 | party1 | buy_peg_1 | STATUS_CANCELLED | 91 | party1 | buy_peg_2 | STATUS_CANCELLED | 92 | party1 | p1-sell-1 | STATUS_FILLED | 93 | party1 | p1-buy-1 | STATUS_ACTIVE | 94 95 #0019-MCAL-049:When the party submit a pegged order, it should be rejected 96 When the parties place the following pegged orders: 97 | party | market id | side | volume | pegged reference | offset | reference | error | 98 | party1 | ETH/FEB23 | buy | 100 | BID | 10 | buy_peg_3 | OrderError: pegged orders not allowed in isolated margin mode | 99 | party1 | ETH/FEB23 | buy | 200 | BID | 20 | buy_peg_4 | OrderError: pegged orders not allowed in isolated margin mode | 100 101 Then the orders should have the following status: 102 | party | reference | status | 103 | party1 | buy_peg_3 | STATUS_REJECTED | 104 | party1 | buy_peg_4 | STATUS_REJECTED | 105 106 And the parties submit update margin mode: 107 | party | market | margin_mode | margin_factor | error | 108 | party1 | ETH/FEB23 | cross margin | 0 | | 109 Then the parties should have the following margin levels: 110 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 111 | party1 | ETH/FEB23 | 9486 | 10434 | 11383 | 13280 | cross margin | 0 | 0 | 112 113 #0019-MCAL-051:When the party has iceberg pegged orders and switches from cross margin mode to isolated margin mode, all the iceberg pegged orders will be stopped. 114 When the parties place the following pegged orders: 115 | party | market id | side | volume | pegged reference | offset | reference | error | 116 | party1 | ETH/FEB23 | buy | 100 | BID | 10 | buy_peg_5 | | 117 | party1 | ETH/FEB23 | buy | 200 | BID | 20 | buy_peg_6 | | 118 119 Then the orders should have the following status: 120 | party | reference | status | 121 | party1 | buy_peg_5 | STATUS_ACTIVE | 122 | party1 | buy_peg_6 | STATUS_ACTIVE | 123 124 And the parties submit update margin mode: 125 | party | market | margin_mode | margin_factor | error | 126 | party1 | ETH/FEB23 | isolated margin | 0.3 | | 127 128 Then the parties should have the following margin levels: 129 | party | market id | maintenance | search | initial | release | margin mode | margin factor | order | 130 | party1 | ETH/FEB23 | 9486 | 0 | 11383 | 0 | isolated margin | 0.3 | 0 | 131 132 Then the orders should have the following status: 133 | party | reference | status | 134 | party1 | buy_peg_5 | STATUS_CANCELLED | 135 | party1 | buy_peg_6 | STATUS_CANCELLED | 136 137 138