code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/risk-parameters-sigma-test.feature (about)

     1  Feature: test risk model parameter sigma
     2    Background:
     3  
     4      Given the log normal risk model named "log-normal-risk-model-53":
     5        | risk aversion | tau | mu | r | sigma |
     6        | 0.000001      | 0.1 | 0  | 0 | 50    |
     7      #risk factor short:999999.0000000
     8      #risk factor long:1
     9      Given the log normal risk model named "log-normal-risk-model-54":
    10        | risk aversion | tau | mu | r | sigma |
    11        | 0.000001      | 0.1 | 0  | 0 | 53    |
    12      #risk factor short:999999.0000000
    13      #risk factor long:1
    14      Given the log normal risk model named "log-normal-risk-model-0":
    15        | risk aversion | tau | mu | r | sigma |
    16        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    17      #risk factor short:3.5569036
    18      #risk factor long:0.801225765
    19      And the margin calculator named "margin-calculator-1":
    20        | search factor | initial factor | release factor |
    21        | 1.2           | 1.5            | 1.7            |
    22      And the fees configuration named "fees-config-1":
    23        | maker fee | infrastructure fee |
    24        | 0.004     | 0.001              |
    25      And the price monitoring named "price-monitoring-1":
    26        | horizon | probability | auction extension |
    27        | 43200   | 0.99        | 300               |
    28      And the markets:
    29        | id        | quote name | asset | risk model               | margin calculator   | auction duration | fees          | price monitoring   | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    30        | ETH/MAR53 | ETH        | USD   | log-normal-risk-model-53 | margin-calculator-1 | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
    31        | ETH/MAR54 | ETH        | USD   | log-normal-risk-model-54 | margin-calculator-1 | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
    32        | ETH/MAR0  | ETH        | USD   | log-normal-risk-model-0  | margin-calculator-1 | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
    33      And the parties deposit on asset's general account the following amount:
    34        | party  | asset | amount                      |
    35        | party0 | USD   | 500000000000000000000000000 |
    36        | party1 | USD   | 5000000000                  |
    37        | party2 | USD   | 5000000000                  |
    38        | party3 | USD   | 5000000000                  |
    39      And the following network parameters are set:
    40        | name                                    | value |
    41        | network.markPriceUpdateMaximumFrequency | 0s    |
    42        | limits.markets.maxPeggedOrders          | 2     |
    43  
    44    @Now
    45    Scenario: 001, test market ETH/MAR53(sigma=50),
    46  
    47      Given the liquidity monitoring parameters:
    48        | name               | triggering ratio | time window | scaling factor |
    49        | updated-lqm-params | 0.1              | 24h         | 1              |
    50      When the markets are updated:
    51        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    52        | ETH/MAR53 | updated-lqm-params   | 0.25                   | 0                         |
    53      And the following network parameters are set:
    54        | name                                  | value |
    55        | market.liquidity.bondPenaltyParameter | 0.2   |
    56  
    57      And the average block duration is "1"
    58  
    59      And the parties submit the following liquidity provision:
    60        | id  | party  | market id | commitment amount | fee   | lp type    |
    61        | lp1 | party0 | ETH/MAR53 | 100000000         | 0.001 | submission |
    62        | lp1 | party0 | ETH/MAR53 | 100000000         | 0.001 | amendment  |
    63      When the parties place the following orders:
    64        | party  | market id | side | volume    | price | resulting trades | type       | tif     | reference |
    65        | party0 | ETH/MAR53 | buy  | 100000000 | 1     | 0                | TYPE_LIMIT | TIF_GTC | peg-1     |
    66        | party0 | ETH/MAR53 | sell | 5000000   | 20    | 0                | TYPE_LIMIT | TIF_GTC | peg-2     |
    67  
    68      And the parties place the following orders:
    69        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    70        | party1 | ETH/MAR53 | buy  | 10     | 9     | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
    71        | party1 | ETH/MAR53 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
    72        | party2 | ETH/MAR53 | sell | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
    73        | party2 | ETH/MAR53 | sell | 10     | 11    | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
    74  
    75      When the opening auction period ends for market "ETH/MAR53"
    76      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR53"
    77      # And the network moves ahead "1" blocks
    78  
    79      And the market data for the market "ETH/MAR53" should be:
    80        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    81        | 10         | TRADING_MODE_CONTINUOUS | 43200   | 1         | 211       | 9999990      | 100000000      | 1             |
    82      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 10 x 1 x 1 x 999999.00000000000 =9999990
    83  
    84      Then the order book should have the following volumes for market "ETH/MAR53":
    85        | side | price | volume    |
    86        | sell | 20    | 5000000   |
    87        | sell | 11    | 10        |
    88        | buy  | 9     | 10        |
    89        | buy  | 1     | 100000000 |
    90  
    91      And the parties should have the following account balances:
    92        | party  | asset | market id | margin         | general                     | bond      |
    93        | party0 | USD   | ETH/MAR53 | 74999925000000 | 499999999999924999975000000 | 100000000 |
    94        | party1 | USD   | ETH/MAR53 | 150            | 4999999850                  |           |
    95        | party2 | USD   | ETH/MAR53 | 179999820      | 4820000180                  |           |
    96  
    97      # mentainance margin level for LP: 10*22580646*999999=2.258e14
    98      # initial  margin level for LP: 10*22580646*999999 *1.5=3.38e14
    99  
   100      And the parties should have the following margin levels:
   101        | party  | market id | maintenance    | search         | initial        | release        |
   102        | party0 | ETH/MAR53 | 49999950000000 | 59999940000000 | 74999925000000 | 84999915000000 |
   103  
   104    @Now
   105    Scenario: 002, test market ETH/MAR0 (kind of "normal" risk parameters setting),
   106  
   107      Given the liquidity monitoring parameters:
   108        | name               | triggering ratio | time window | scaling factor |
   109        | updated-lqm-params | 0.1              | 24h         | 1              |
   110      When the markets are updated:
   111        | id       | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   112        | ETH/MAR0 | updated-lqm-params   | 0.25                   | 0                         |
   113      And the following network parameters are set:
   114        | name                                    | value |
   115        | market.liquidity.bondPenaltyParameter | 0.2   |
   116  
   117      And the average block duration is "1"
   118  
   119      And the parties submit the following liquidity provision:
   120        | id  | party  | market id | commitment amount | fee   | lp type    |
   121        | lp1 | party0 | ETH/MAR0  | 10000000          | 0.001 | submission |
   122        | lp1 | party0 | ETH/MAR0  | 10000000          | 0.001 | amendment  |
   123      And the parties place the following pegged iceberg orders:
   124        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   125        | party0 | ETH/MAR0 | 500 | 1 | sell | ASK | 500 | 1 |
   126        | party0 | ETH/MAR0 | 500 | 1 | buy  | BID | 500 | 1 |
   127   
   128      And the parties place the following orders:
   129        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   130        | party1 | ETH/MAR0  | buy  | 10     | 90    | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   131        | party1 | ETH/MAR0  | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   132        | party2 | ETH/MAR0  | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   133        | party2 | ETH/MAR0  | sell | 10     | 110   | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   134  
   135      When the opening auction period ends for market "ETH/MAR0"
   136      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR0"
   137  
   138      And the market data for the market "ETH/MAR0" should be:
   139        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   140        | 100        | TRADING_MODE_CONTINUOUS | 43200   | 91        | 109       | 355          | 10000000       | 1             |
   141      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1 x 100 x 1 x 3.5569036 =355
   142  
   143      Then the order book should have the following volumes for market "ETH/MAR0":
   144        | side | price | volume |
   145        | sell | 110   | 10     |
   146        | sell | 111 | 500 |
   147        | buy  | 89  | 500 |
   148        | buy  | 90  | 10  |
   149  
   150      And the parties should have the following account balances:
   151        | party  | asset | market id | margin   | general                     | bond     |
   152        | party0 | USD | ETH/MAR0 | 266769 | 499999999999999999989733231 | 10000000 |
   153        | party1 | USD   | ETH/MAR0  | 1201     | 4999998799                  |          |
   154        | party2 | USD   | ETH/MAR0  | 6403     | 4999993597                  |          |
   155  
   156      And the parties should have the following margin levels:
   157        | party  | market id | maintenance | search   | initial  | release  |
   158        | party0 | ETH/MAR0 | 177846 | 213415 | 266769 | 302338 |
   159