code.vegaprotocol.io/vega@v0.79.0/core/integration/features/position_tracking/verified-positions-resolution-5-lognormal_pdp.feature (about) 1 Feature: Position resolution case 5 lognormal risk model 2 3 Background: 4 Given the log normal risk model named "lognormal-risk-model-fish": 5 | risk aversion | tau | mu | r | sigma | 6 | 0.001 | 0.01 | 0 | 0.0 | 1.2 | 7 #calculated risk factor long: 0.336895684; risk factor short: 0.4878731 8 9 And the price monitoring named "price-monitoring-1": 10 | horizon | probability | auction extension | 11 | 1 | 0.99999999 | 300 | 12 13 And the margin calculator named "margin-calculator-1": 14 | search factor | initial factor | release factor | 15 | 1.2 | 1.5 | 2 | 16 17 And the markets: 18 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | position decimal places | linear slippage factor | quadratic slippage factor | sla params | 19 | ETH/DEC19 | ETH | USD | lognormal-risk-model-fish | margin-calculator-1 | 1 | default-none | default-none | default-eth-for-future | 2 | 1e-3 | 1e-3 | default-futures | 20 21 And the following network parameters are set: 22 | name | value | 23 | market.auction.minimumDuration | 1 | 24 | network.markPriceUpdateMaximumFrequency | 0s | 25 | limits.markets.maxPeggedOrders | 2 | 26 27 @Liquidation 28 Scenario: using lognormal risk model, set "designatedLoser " closeout while the position of "designatedLoser " is not fully covered by orders on the order book 29 # setup accounts 30 Given the parties deposit on asset's general account the following amount: 31 | party | asset | amount | 32 | sellSideProvider | USD | 1000000000000 | 33 | buySideProvider | USD | 1000000000000 | 34 | designatedLoser | USD | 32000 | 35 | aux | USD | 1000000000000 | 36 | aux2 | USD | 1000000000000 | 37 | lpprov | USD | 1000000000000 | 38 39 When the parties submit the following liquidity provision: 40 | id | party | market id | commitment amount | fee | lp type | 41 | lp1 | lpprov | ETH/DEC19 | 9000 | 0.1 | submission | 42 | lp1 | lpprov | ETH/DEC19 | 9000 | 0.1 | submission | 43 And the parties place the following pegged iceberg orders: 44 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 45 | lpprov | ETH/DEC19 | 22500 | 1800 | buy | BID | 22500 | 100 | 46 | lpprov | ETH/DEC19 | 3600 | 1800 | sell | ASK | 3600 | 100 | 47 48 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 49 Then the parties place the following orders: 50 | party | market id | side | volume | price | resulting trades | type | tif | 51 | aux | ETH/DEC19 | buy | 1000 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 52 | aux | ETH/DEC19 | sell | 1000 | 2000 | 0 | TYPE_LIMIT | TIF_GTC | 53 | aux | ETH/DEC19 | buy | 100 | 150 | 0 | TYPE_LIMIT | TIF_GTC | 54 | aux2 | ETH/DEC19 | sell | 100 | 150 | 0 | TYPE_LIMIT | TIF_GTC | 55 Then the opening auction period ends for market "ETH/DEC19" 56 And the mark price should be "150" for the market "ETH/DEC19" 57 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 58 59 # insurance pool generation - setup orderbook 60 When the parties place the following orders with ticks: 61 | party | market id | side | volume | price | resulting trades | type | tif | reference | 62 | sellSideProvider | ETH/DEC19 | sell | 29000 | 150 | 0 | TYPE_LIMIT | TIF_GTC | sell-provider-1 | 63 | buySideProvider | ETH/DEC19 | buy | 100 | 140 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-1 | 64 65 Then the order book should have the following volumes for market "ETH/DEC19": 66 | side | price | volume | 67 | sell | 2000 | 1000 | 68 | sell | 250 | 3600 | 69 | sell | 150 | 29000 | 70 | buy | 140 | 100 | 71 | buy | 40 | 22500 | 72 | buy | 1 | 1000 | 73 74 # insurance pool generation - trade 75 When the parties place the following orders with ticks: 76 | party | market id | side | volume | price | resulting trades | type | tif | reference | 77 | designatedLoser | ETH/DEC19 | buy | 29000 | 150 | 1 | TYPE_LIMIT | TIF_GTC | ref-1 | 78 79 Then the parties should have the following account balances: 80 | party | asset | market id | margin | general | 81 | designatedLoser | USD | ETH/DEC19 | 27650 | 0 | 82 83 Then the parties should have the following profit and loss: 84 | party | volume | unrealised pnl | realised pnl | 85 | designatedLoser | 29000 | 0 | 0 | 86 87 Then the order book should have the following volumes for market "ETH/DEC19": 88 | side | price | volume | 89 | sell | 2100 | 3600 | 90 | sell | 2000 | 1000 | 91 | buy | 140 | 100 | 92 | buy | 40 | 22500 | 93 | buy | 1 | 1000 | 94 95 Then the parties cancel the following orders: 96 | party | reference | 97 | buySideProvider | buy-provider-1 | 98 99 When the parties place the following orders: 100 | party | market id | side | volume | price | resulting trades | type | tif | 101 | lpprov | ETH/DEC19 | buy | 100000 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 102 103 When the parties place the following orders with ticks: 104 | party | market id | side | volume | price | resulting trades | type | tif | reference | 105 | sellSideProvider | ETH/DEC19 | sell | 1 | 140 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 106 | buySideProvider | ETH/DEC19 | buy | 1 | 140 | 1 | TYPE_LIMIT | TIF_GTC | ref-4 | 107 108 And the mark price should be "140" for the market "ETH/DEC19" 109 110 Then the parties should have the following account balances: 111 | party | asset | market id | margin | general | 112 | designatedLoser | USD | ETH/DEC19 | 0 | 0 | 113 114 Then the parties should have the following profit and loss: 115 | party | volume | unrealised pnl | realised pnl | 116 | designatedLoser | 0 | 0 | -27650 | 117 118 When the network moves ahead "1" blocks 119 #Then debug transfers 120 # then we make sure the insurance pool collected the funds (however they get later spent on MTM payment to closeout-facilitating party) 121 Then the following transfers should happen: 122 | from | to | from account | to account | market id | amount | asset | 123 | market | market | ACCOUNT_TYPE_INSURANCE | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC19 | 0 | USD | 124 | market | | ACCOUNT_TYPE_INSURANCE | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | ETH/DEC19 | 0 | USD | 125 | designatedLoser | market | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_INSURANCE | ETH/DEC19 | 24750 | USD | 126 | buySideProvider | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC19 | 0 | USD | 127 | buySideProvider | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC19 | 1 | USD | 128 | buySideProvider | buySideProvider | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_MARGIN | ETH/DEC19 | 76 | USD | 129 | market | lpprov | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | ETH/DEC19 | 0 | USD | 130 | market | market | ACCOUNT_TYPE_INSURANCE | ACCOUNT_TYPE_SETTLEMENT | ETH/DEC19 | 24721 | USD | 131 | market | lpprov | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | ETH/DEC19 | 23869 | USD | 132 133 And the insurance pool balance should be "0" for the market "ETH/DEC19"