code.vegaprotocol.io/vega@v0.79.0/core/integration/features/target_stake/3135-target-stake-decimals.feature (about) 1 Feature: Target stake 2 3 # Market risk parameters and assets don't really matter. 4 # We need to track open interest i.e. sum of all long positions across the parties and how they change over time 5 6 Background: 7 Given the following network parameters are set: 8 | name | value | 9 | network.markPriceUpdateMaximumFrequency | 0s | 10 | limits.markets.maxPeggedOrders | 2 | 11 Given the liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 1.0 | 168h | 1.5 | 14 15 And the following assets are registered: 16 | id | decimal places | 17 | BTC | 5 | 18 And the simple risk model named "simple-risk-model-1": 19 | long | short | max move up | min move down | probability of trading | 20 | 0.1 | 0.1 | 10 | -10 | 0.1 | 21 And the log normal risk model named "log-normal-risk-model-1": 22 | risk aversion | tau | mu | r | sigma | 23 | 0.000001 | 0.00011407711613050422 | -1 | -1 | -1 | 24 And the fees configuration named "fees-config-1": 25 | maker fee | infrastructure fee | 26 | 0.00025 | 0.0005 | 27 And the margin calculator named "margin-calculator-1": 28 | search factor | initial factor | release factor | 29 | 1.1 | 1.2 | 1.4 | 30 And the markets: 31 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | decimal places | linear slippage factor | quadratic slippage factor | sla params | 32 | ETH/DEC21 | BTC | BTC | lqm-params | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | default-none | default-eth-for-future | 2 | 0.25 | 0 | default-futures | 33 34 # Above, it says mark price but really I don't mind if we start 35 # with an opening auction as long as at start of the scenario 36 # no-one has any open positions in the market. 37 # So if we want to start with an auction, trade volume 1, then close out the position. 38 39 # T0 + 8 days so whatever open interest was there after the auction 40 # this is now out of the time window. 41 And time is updated to "2021-03-08T00:00:00Z" 42 43 Scenario: Max open interest changes over time 44 # setup accounts 45 Given the parties deposit on asset's general account the following amount: 46 | party | asset | amount | 47 | tt_0 | BTC | 100000000000 | 48 | tt_1 | BTC | 100000000000 | 49 | tt_2 | BTC | 100000000000 | 50 | tt_3 | BTC | 100000000000 | 51 52 # put some volume on the book so that others can increase their 53 # positions and close out if needed too 54 When the parties place the following orders: 55 | party | market id | side | volume | price | resulting trades | type | tif | reference | 56 | tt_0 | ETH/DEC21 | buy | 1000 | 90 | 0 | TYPE_LIMIT | TIF_GTC | tt_0_0 | 57 | tt_0 | ETH/DEC21 | sell | 1000 | 110 | 0 | TYPE_LIMIT | TIF_GTC | tt_0_1 | 58 59 # nothing should have traded, we have mark price set apriori or 60 # due to auction closing. 61 Then the mark price should be "0" for the market "ETH/DEC21" 62 63 # Traders 1, 2, 3 go long 64 When the parties place the following orders: 65 | party | market id | side | volume | price | resulting trades | type | tif | reference | 66 | tt_1 | ETH/DEC21 | buy | 10 | 110 | 0 | TYPE_LIMIT | TIF_GTC | tt_1_0 | 67 | tt_2 | ETH/DEC21 | buy | 20 | 110 | 0 | TYPE_LIMIT | TIF_GTC | tt_2_0 | 68 | tt_3 | ETH/DEC21 | buy | 30 | 110 | 0 | TYPE_LIMIT | TIF_GTC | tt_2_0 | 69 70 Then the parties submit the following liquidity provision: 71 | id | party | market id | commitment amount | fee | lp type | 72 | lp1 | tt_0 | ETH/DEC21 | 990000 | 0.001 | submission | 73 | lp1 | tt_0 | ETH/DEC21 | 990000 | 0.001 | amendment | 74 And the parties place the following pegged iceberg orders: 75 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 76 | tt_0 | ETH/DEC21 | 2 | 1 | buy | BID | 1 | 10 | 77 | tt_0 | ETH/DEC21 | 2 | 1 | sell | ASK | 1 | 10 | 78 79 Then the opening auction period ends for market "ETH/DEC21" 80 81 # So now parties 1,2,3 are long 10+20+30 = 60. 82 Then the market data for the market "ETH/DEC21" should be: 83 | mark price | open interest | trading mode | auction trigger | extension trigger | target stake | supplied stake | 84 | 110 | 60 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 990000 | 990000 | 85 86 # Target stake is mark_price x max_oi x target_stake_scaling_factor x rf_short 87 # rf_short should have been set above to 0.1 88 # target_stake = 110 x 60 x 1.5 x 0.1 89 And the target stake should be "990000" for the market "ETH/DEC21" 90 91 # T0 + 8 days + 1 hour 92 When time is updated to "2021-03-08T01:00:00Z" 93 94 # Trader 3 closes out 20 95 When the parties place the following orders with ticks: 96 | party | market id | side | volume | price | resulting trades | type | tif | reference | 97 | tt_3 | ETH/DEC21 | sell | 20 | 90 | 1 | TYPE_LIMIT | TIF_GTC | tt_2_1 | 98 99 Then the mark price should be "90" for the market "ETH/DEC21" 100 101 # the maximum oi over the last 7 days is still unchanged 102 # target_stake = 90 x 60 x 1.5 x 0.1 103 And the target stake should be "810000" for the market "ETH/DEC21" 104 105 # T0 + 15 days + 2 hour 106 # so now the peak of 60 should have passed from window 107 When time is updated to "2021-03-15T02:00:00Z" 108 109 Then the mark price should be "90" for the market "ETH/DEC21" 110 111 # target_stake = 90 x 40 x 1.5 x 0.1 112 And the target stake should be "540000" for the market "ETH/DEC21"