code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/volume-near-price-mon-bounds.feature (about) 1 # Test volume and margin when LP volume is pushed inside price monitoring bounds 2 # and the price monitoring bounds happen to be best bid/ask 3 Feature: Test margin for lp near price monitoring boundaries 4 5 Background: 6 Given the following network parameters are set: 7 | name | value | 8 | market.value.windowLength | 1h | 9 | network.markPriceUpdateMaximumFrequency | 0s | 10 | limits.markets.maxPeggedOrders | 2 | 11 And the liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 0.00 | 24h | 1 | 14 And the average block duration is "1" 15 And the liquidity sla params named "SLA": 16 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 17 | 1.0 | 0.5 | 1 | 1.0 | 18 19 20 Scenario: first scenario for volume at near price monitoring bounds and simple-risk-model 21 22 Given the simple risk model named "simple-risk-model-1": 23 | long | short | max move up | min move down | probability of trading | 24 | 0.1 | 0.1 | 100 | -100 | 0.2 | 25 And the fees configuration named "fees-config-1": 26 | maker fee | infrastructure fee | 27 | 0.004 | 0.001 | 28 And the price monitoring named "price-monitoring-1": 29 | horizon | probability | auction extension | 30 | 1 | 0.99 | 300 | 31 And the markets: 32 | 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 | 33 | ETH/DEC21 | ETH | ETH | lqm-params | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25 | 0 | SLA | 34 And the following network parameters are set: 35 | name | value | 36 | market.liquidity.providersFeeCalculationTimeStep | 600s | 37 And the parties deposit on asset's general account the following amount: 38 | party | asset | amount | 39 | lp1 | ETH | 100000000 | 40 | party1 | ETH | 10000000 | 41 | party2 | ETH | 10000000 | 42 43 Given the parties submit the following liquidity provision: 44 | id | party | market id | commitment amount | fee | lp type | 45 | commitment1 | lp1 | ETH/DEC21 | 78000000 | 0.001 | submission | 46 | commitment1 | lp1 | ETH/DEC21 | 78000000 | 0.001 | amendment | 47 And the parties place the following pegged iceberg orders: 48 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 49 | lp1 | ETH/DEC21 | 2 | 1 | buy | BID | 97500 | 100 | 50 | lp1 | ETH/DEC21 | 2 | 1 | sell | ASK | 97500 | 100 | 51 And the parties place the following orders: 52 | party | market id | side | volume | price | resulting trades | type | tif | 53 | party1 | ETH/DEC21 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 54 | party1 | ETH/DEC21 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 55 | party2 | ETH/DEC21 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 56 | party2 | ETH/DEC21 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 57 58 When the opening auction period ends for market "ETH/DEC21" 59 Then the auction ends with a traded volume of "10" at a price of "1000" 60 61 And the parties should have the following profit and loss: 62 | party | volume | unrealised pnl | realised pnl | 63 | party1 | 10 | 0 | 0 | 64 | party2 | -10 | 0 | 0 | 65 66 And the market data for the market "ETH/DEC21" should be: 67 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 68 | 1000 | TRADING_MODE_CONTINUOUS | 1 | 900 | 1100 | 1000 | 78000000 | 10 | 69 70 And the parties should have the following margin levels: 71 | party | market id | maintenance | search | initial | release | 72 | lp1 | ETH/DEC21 | 9750000 | 10725000 | 11700000 | 13650000 | 73 74 And the parties should have the following account balances: 75 | party | asset | market id | margin | general | bond | 76 | lp1 | ETH | ETH/DEC21 | 11700000 | 10300000 | 78000000 | 77 78 79 Then the parties place the following orders: 80 | party | market id | side | volume | price | resulting trades | type | tif | 81 | party1 | ETH/DEC21 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 82 83 And the parties should have the following margin levels: 84 | party | market id | maintenance | search | initial | release | 85 | lp1 | ETH/DEC21 | 9750000 | 10725000 | 11700000 | 13650000 | 86 87 # now we place an order which makes the best bid 901. 88 Then the parties place the following orders: 89 | party | market id | side | volume | price | resulting trades | type | tif | 90 | party1 | ETH/DEC21 | buy | 1 | 901 | 0 | TYPE_LIMIT | TIF_GTC | 91 92 # margin unaffected as requirement is driven by sell side anyway 93 And the parties should have the following margin levels: 94 | party | market id | maintenance | search | initial | release | 95 | lp1 | ETH/DEC21 | 9750000 | 10725000 | 11700000 | 13650000 | 96 97 Scenario: second scenario for volume at near price monitoring bounds with log-normal 98 99 Given the log normal risk model named "log-normal-risk-model-1": 100 | risk aversion | tau | mu | r | sigma | 101 | 0.000001 | 0.00273 | 0 | 0 | 1.2 | 102 #rf_short = 0.3611932 103 #rf_long = 0.268130582 104 And the fees configuration named "fees-config-1": 105 | maker fee | infrastructure fee | 106 | 0.004 | 0.001 | 107 And the price monitoring named "price-monitoring-2": 108 | horizon | probability | auction extension | 109 | 43200 | 0.982 | 300 | 110 And the markets: 111 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 112 | ETH2/MAR22 | ETH2 | ETH2 | log-normal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-2 | default-eth-for-future | 0.25 | 0 | SLA | 113 And the following network parameters are set: 114 | name | value | 115 | market.liquidity.providersFeeCalculationTimeStep | 600s | 116 And the parties deposit on asset's general account the following amount: 117 | party | asset | amount | 118 | lp1 | ETH2 | 100000000 | 119 | party1 | ETH2 | 10000000 | 120 | party2 | ETH2 | 10000000 | 121 122 And the parties submit the following liquidity provision: 123 | id | party | market id | commitment amount | fee | lp type | 124 | commitment1 | lp1 | ETH2/MAR22 | 50000000 | 0.001 | submission | 125 | commitment1 | lp1 | ETH2/MAR22 | 50000000 | 0.001 | amendment | 126 And the parties place the following pegged iceberg orders: 127 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 128 | lp1 | ETH2/MAR22 | 62500 | 1 | buy | BID | 62500 | 100 | ice-buy | 129 | lp1 | ETH2/MAR22 | 41357 | 1 | sell | ASK | 41357 | 100 | ice-sell | 130 And the parties place the following orders: 131 | party | market id | side | volume | price | resulting trades | type | tif | 132 | party1 | ETH2/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 133 | party1 | ETH2/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 134 | party2 | ETH2/MAR22 | sell | 1 | 1109 | 0 | TYPE_LIMIT | TIF_GTC | 135 | party2 | ETH2/MAR22 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 136 137 When the opening auction period ends for market "ETH2/MAR22" 138 Then the auction ends with a traded volume of "10" at a price of "1000" 139 140 And the parties should have the following profit and loss: 141 | party | volume | unrealised pnl | realised pnl | 142 | party1 | 10 | 0 | 0 | 143 | party2 | -10 | 0 | 0 | 144 145 And the market data for the market "ETH2/MAR22" should be: 146 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 147 | 1000 | TRADING_MODE_CONTINUOUS | 43200 | 900 | 1109 | 36119 | 50000000 | 10 | 148 149 And the order book should have the following volumes for market "ETH2/MAR22": 150 | side | price | volume | 151 | sell | 1209 | 41357 | 152 | sell | 1109 | 1 | 153 | buy | 901 | 0 | 154 | buy | 900 | 1 | 155 | buy | 800 | 62500 | 156 # LP_vol: 50000000/1209=41357 157 # LP_vol: 50000000/800=62500 158 159 And the parties should have the following margin levels: 160 | party | market id | maintenance | search | initial | release | 161 | lp1 | ETH2/MAR22 | 16758162 | 18433978 | 20109794 | 23461426 | 162 163 # Maitenance_margin: 41457*1000*0.3611932+62500*1000*0.268130582=31732147.87 164 And the parties should have the following account balances: 165 | party | asset | market id | margin | general | bond | 166 | lp1 | ETH2 | ETH2/MAR22 | 20109794 | 29890206 | 50000000 | 167 168 Then the parties place the following orders: 169 | party | market id | side | volume | price | resulting trades | type | tif | reference | 170 | party1 | ETH2/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | buy-ref-3 | 171 172 And the market data for the market "ETH2/MAR22" should be: 173 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 174 | 1000 | TRADING_MODE_CONTINUOUS | 43200 | 900 | 1109 | 36119 | 50000000 | 10 | 175 And the order book should have the following volumes for market "ETH2/MAR22": 176 | side | price | volume | 177 | sell | 1209 | 41357 | 178 | sell | 1109 | 1 | 179 | buy | 901 | 0 | 180 | buy | 900 | 2 | 181 | buy | 800 | 62500 | 182 183 And the parties should have the following margin levels: 184 | party | market id | maintenance | search | initial | release | 185 | lp1 | ETH2/MAR22 | 16758162 | 18433978 | 20109794 | 23461426 | 186 187 # now we place an order which makes the best bid 901. 188 Then the parties place the following orders: 189 | party | market id | side | volume | price | resulting trades | type | tif | reference | 190 | party1 | ETH2/MAR22 | buy | 1 | 901 | 0 | TYPE_LIMIT | TIF_GTC | buy-ref-4 | 191 192 And the market data for the market "ETH2/MAR22" should be: 193 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 194 | 1000 | TRADING_MODE_CONTINUOUS | 43200 | 900 | 1109 | 36119 | 50000000 | 10 | 195 196 And the parties amend the following pegged iceberg orders: 197 | party | reference | size delta | 198 | lp1 | ice-buy | -78 | 199 200 Then the order book should have the following volumes for market "ETH2/MAR22": 201 | side | price | volume | 202 | sell | 1209 | 41357 | 203 | sell | 1109 | 1 | 204 | buy | 901 | 1 | 205 | buy | 900 | 2 | 206 | buy | 801 | 62422 | 207 208 And the parties should have the following margin levels: 209 | party | market id | maintenance | search | initial | release | 210 | lp1 | ETH2/MAR22 | 16737248 | 18410972 | 20084697 | 23432147 | 211