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

     1  Feature: test risk model parameter ranges
     2    Background:
     3  
     4      Given the margin calculator named "margin-calculator-1":
     5        | search factor | initial factor | release factor |
     6        | 1.2           | 1.5            | 1.7            |
     7      Given the log normal risk model named "log-normal-risk-model-0":
     8        | risk aversion | tau | mu | r | sigma |
     9        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    10      #risk factor short:3.5569036
    11      #risk factor long:0.801225765
    12  
    13      # test risk aversion
    14      Given the log normal risk model named "log-normal-risk-model-11":
    15        | risk aversion | tau | mu | r | sigma |
    16        | 0.00000001    | 0.1 | 0  | 0 | 1.0   |
    17      #risk factor short:4.9256840
    18      #risk factor long:0.847272675
    19      Given the log normal risk model named "log-normal-risk-model-12":
    20        | risk aversion | tau | mu | r | sigma |
    21        | 0.1           | 0.1 | 0  | 0 | 1.0   |
    22      #risk factor short:0.67191327433
    23      #risk factor long:0.44953951995
    24  
    25      # test tau:1e-8<=x<=1
    26      Given the log normal risk model named "log-normal-risk-model-21":
    27        | risk aversion | tau        | mu | r | sigma |
    28        | 0.000001      | 0.00000001 | 0  | 0 | 1.0   |
    29      #risk factor short:0.0004950
    30      #risk factor long:0.000494716
    31      Given the log normal risk model named "log-normal-risk-model-22":
    32        | risk aversion | tau | mu | r | sigma |
    33        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    34      #risk factor short:3.5569036
    35      #risk factor long:0.801225765
    36      Given the log normal risk model named "log-normal-risk-model-23":
    37        | risk aversion | tau | mu | r | sigma |
    38        | 0.000001      | 1   | 0  | 0 | 1.0   |
    39      #risk factor short:86.2176101 (it can not end the auction so this is tested separately in scenario 002)
    40      #risk factor long:0.996594553
    41  
    42      # test mu:-1e-6<=x<=1e-6
    43      Given the log normal risk model named "log-normal-risk-model-31":
    44        | risk aversion | tau | mu        | r | sigma |
    45        | 0.000001      | 0.1 | -0.000001 | 0 | 1.0   |
    46      #risk factor short:3.55690313589
    47      #risk factor long:0.80072822791
    48      # actual mu = -0.0000001
    49      Given the log normal risk model named "log-normal-risk-model-32":
    50        | risk aversion | tau | mu       | r | sigma |
    51        | 0.000001      | 0.1 | 0.000001 | 0 | 1.0   |
    52      #risk factor short:3.55690313589
    53      #risk factor long:0.80072822791
    54      # actual mu = 0.0000001
    55  
    56      # test r:-1<=x<=1
    57      Given the log normal risk model named "log-normal-risk-model-41":
    58        | risk aversion | tau | mu | r  | sigma |
    59        | 0.000001      | 0.1 | 0  | -1 | 1.0   |
    60      #risk factor short:3.5569036
    61      #risk factor long:0.801225765
    62      Given the log normal risk model named "log-normal-risk-model-42":
    63        | risk aversion | tau | mu | r   | sigma |
    64        | 0.000001      | 0.1 | 0  | 0.5 | 1.0   |
    65      #risk factor short:3.5569036
    66      #risk factor long:0.801225765
    67      Given the log normal risk model named "log-normal-risk-model-43":
    68        | risk aversion | tau | mu | r | sigma |
    69        | 0.000001      | 0.1 | 0  | 1 | 1.0   |
    70      #risk factor short:3.5569036
    71      #risk factor long:0.801225765
    72  
    73      # test sigma: 1e-3<=x<=100
    74      Given the log normal risk model named "log-normal-risk-model-51":
    75        | risk aversion | tau | mu | r | sigma |
    76        | 0.000001      | 0.1 | 0  | 0 | 0.001 |
    77      #risk factor short:0.00156597682
    78      #risk factor long:0.00156362469
    79  
    80      Given the log normal risk model named "log-normal-risk-model-52":
    81        | risk aversion | tau | mu | r | sigma |
    82        | 0.000001      | 0.1 | 0  | 0 | 10    |
    83      #risk factor short:55787.28815617000
    84      #risk factor long:0.99999999877
    85      # tested in scenario 003
    86      Given the log normal risk model named "log-normal-risk-model-53":
    87        | risk aversion | tau | mu | r | sigma |
    88        | 0.000001      | 0.1 | 0  | 0 | 100   |
    89      #risk factor short:999999.00000000000
    90      #risk factor long:1.00000000000
    91      # tested in scenario 004
    92  
    93      And the fees configuration named "fees-config-1":
    94        | maker fee | infrastructure fee |
    95        | 0.004     | 0.001              |
    96      And the price monitoring named "price-monitoring-1":
    97        | horizon | probability | auction extension |
    98        | 43200   | 0.99        | 300               |
    99  
   100      And the markets:
   101        | id        | quote name | asset | risk model               | margin calculator         | auction duration | fees          | price monitoring   | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
   102        | ETH/MAR0  | ETH        | USD   | log-normal-risk-model-0  | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   103        | ETH/MAR11 | ETH        | USD   | log-normal-risk-model-11 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   104        | ETH/MAR12 | ETH        | USD   | log-normal-risk-model-12 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   105        | ETH/MAR21 | ETH        | USD   | log-normal-risk-model-21 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   106        | ETH/MAR22 | ETH        | USD   | log-normal-risk-model-22 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   107        | ETH/MAR23 | ETH        | USD   | log-normal-risk-model-23 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   108        | ETH/MAR31 | ETH        | USD   | log-normal-risk-model-31 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   109        | ETH/MAR32 | ETH        | USD   | log-normal-risk-model-32 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   110        | ETH/MAR41 | ETH        | USD   | log-normal-risk-model-41 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   111        | ETH/MAR42 | ETH        | USD   | log-normal-risk-model-42 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   112        | ETH/MAR43 | ETH        | USD   | log-normal-risk-model-43 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   113        | ETH/MAR51 | ETH        | USD   | log-normal-risk-model-51 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   114        | ETH/MAR52 | ETH        | USD   | log-normal-risk-model-52 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   115        | ETH/MAR53 | ETH        | USD   | log-normal-risk-model-53 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
   116      And the parties deposit on asset's general account the following amount:
   117        | party  | asset | amount         |
   118        | party0 | USD   | 50000000000000 |
   119        | party1 | USD   | 50000000000000 |
   120        | party2 | USD   | 50000000000000 |
   121        | party3 | USD   | 50000000000000 |
   122      And the following network parameters are set:
   123        | name                                    | value |
   124        | network.markPriceUpdateMaximumFrequency | 0s    |
   125        | limits.markets.maxPeggedOrders          | 22    |
   126  
   127    @Now @SLABug
   128    Scenario: 001, test different value of risk parameters within defined ranges in different market, AC: 0018-RSKM-001
   129  
   130      Given the liquidity monitoring parameters:
   131        | name               | triggering ratio | time window | scaling factor |
   132        | updated-lqm-params | 0.1              | 24h         | 1              |
   133      When the markets are updated:
   134        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   135        | ETH/MAR0  | updated-lqm-params   | 0.25                   | 0                         |
   136        | ETH/MAR11 | updated-lqm-params   | 0.25                   | 0                         |
   137        | ETH/MAR12 | updated-lqm-params   | 0.25                   | 0                         |
   138        | ETH/MAR21 | updated-lqm-params   | 0.25                   | 0                         |
   139        | ETH/MAR22 | updated-lqm-params   | 0.25                   | 0                         |
   140        | ETH/MAR23 | updated-lqm-params   | 0.25                   | 0                         |
   141        | ETH/MAR31 | updated-lqm-params   | 0.25                   | 0                         |
   142        | ETH/MAR32 | updated-lqm-params   | 0.25                   | 0                         |
   143        | ETH/MAR41 | updated-lqm-params   | 0.25                   | 0                         |
   144        | ETH/MAR42 | updated-lqm-params   | 0.25                   | 0                         |
   145        | ETH/MAR43 | updated-lqm-params   | 0.25                   | 0                         |
   146        | ETH/MAR51 | updated-lqm-params   | 0.25                   | 0                         |
   147        | ETH/MAR52 | updated-lqm-params   | 0.25                   | 0                         |
   148        | ETH/MAR53 | updated-lqm-params   | 0.25                   | 0                         |
   149  
   150      And the following network parameters are set:
   151        | name                                  | value |
   152        | market.liquidity.bondPenaltyParameter | 0.2   |
   153  
   154      And the average block duration is "1"
   155  
   156      And the parties submit the following liquidity provision:
   157        | id   | party  | market id | commitment amount | fee   | lp type    |
   158        | lp1  | party0 | ETH/MAR0  | 50000             | 0.001 | submission |
   159        | lp1  | party0 | ETH/MAR0  | 50000             | 0.001 | amendment  |
   160        | lp2  | party0 | ETH/MAR11 | 50000             | 0.001 | submission |
   161        | lp2  | party0 | ETH/MAR11 | 50000             | 0.001 | amendment  |
   162        | lp3  | party0 | ETH/MAR12 | 50000             | 0.001 | submission |
   163        | lp3  | party0 | ETH/MAR12 | 50000             | 0.001 | amendment  |
   164        | lp4  | party0 | ETH/MAR21 | 50000             | 0.001 | submission |
   165        | lp4  | party0 | ETH/MAR21 | 50000             | 0.001 | amendment  |
   166        | lp5  | party0 | ETH/MAR22 | 50000             | 0.001 | submission |
   167        | lp5  | party0 | ETH/MAR22 | 50000             | 0.001 | amendment  |
   168        | lp6  | party0 | ETH/MAR31 | 50000             | 0.001 | submission |
   169        | lp6  | party0 | ETH/MAR31 | 50000             | 0.001 | amendment  |
   170        | lp7  | party0 | ETH/MAR32 | 50000             | 0.001 | submission |
   171        | lp7  | party0 | ETH/MAR32 | 50000             | 0.001 | amendment  |
   172        | lp9  | party0 | ETH/MAR41 | 50000             | 0.001 | submission |
   173        | lp9  | party0 | ETH/MAR41 | 50000             | 0.001 | amendment  |
   174        | lp10 | party0 | ETH/MAR42 | 50000             | 0.001 | submission |
   175        | lp10 | party0 | ETH/MAR42 | 50000             | 0.001 | amendment  |
   176        | lp11 | party0 | ETH/MAR43 | 50000             | 0.001 | submission |
   177        | lp11 | party0 | ETH/MAR43 | 50000             | 0.001 | amendment  |
   178        | lp12 | party0 | ETH/MAR51 | 50000             | 0.001 | submission |
   179        | lp12 | party0 | ETH/MAR51 | 50000             | 0.001 | amendment  |
   180      And the parties place the following pegged iceberg orders:
   181        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   182        | party0 | ETH/MAR0  | 45 | 1 | sell | ASK | 45 | 20 |
   183        | party0 | ETH/MAR0  | 57 | 1 | buy  | BID | 57 | 20 |
   184        | party0 | ETH/MAR11 | 45 | 1 | sell | ASK | 45 | 20 |
   185        | party0 | ETH/MAR11 | 57 | 1 | buy  | BID | 57 | 20 |
   186        | party0 | ETH/MAR12 | 45 | 1 | sell | ASK | 45 | 20 |
   187        | party0 | ETH/MAR12 | 57 | 1 | buy  | BID | 57 | 20 |
   188        | party0 | ETH/MAR21 | 45 | 1 | sell | ASK | 45 | 20 |
   189        | party0 | ETH/MAR21 | 57 | 1 | buy  | BID | 57 | 20 |
   190        | party0 | ETH/MAR22 | 45 | 1 | sell | ASK | 45 | 20 |
   191        | party0 | ETH/MAR22 | 57 | 1 | buy  | BID | 57 | 20 |
   192        | party0 | ETH/MAR31 | 45 | 1 | sell | ASK | 45 | 20 |
   193        | party0 | ETH/MAR31 | 57 | 1 | buy  | BID | 57 | 20 |
   194        | party0 | ETH/MAR32 | 45 | 1 | sell | ASK | 45 | 20 |
   195        | party0 | ETH/MAR32 | 57 | 1 | buy  | BID | 57 | 20 |
   196        | party0 | ETH/MAR41 | 45 | 1 | sell | ASK | 45 | 20 |
   197        | party0 | ETH/MAR41 | 57 | 1 | buy  | BID | 57 | 20 |
   198        | party0 | ETH/MAR42 | 45 | 1 | sell | ASK | 45 | 20 |
   199        | party0 | ETH/MAR42 | 57 | 1 | buy  | BID | 57 | 20 |
   200        | party0 | ETH/MAR43 | 45 | 1 | sell | ASK | 45 | 20 |
   201        | party0 | ETH/MAR43 | 57 | 1 | buy  | BID | 57 | 20 |
   202        | party0 | ETH/MAR51 | 45 | 1 | sell | ASK | 45 | 20 |
   203        | party0 | ETH/MAR51 | 57 | 1 | buy  | BID | 57 | 20 |
   204  
   205      And the parties place the following orders:
   206        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   207        | party1 | ETH/MAR0  | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   208        | party1 | ETH/MAR0  | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   209        | party2 | ETH/MAR0  | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   210        | party2 | ETH/MAR0  | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   211        | party1 | ETH/MAR11 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-21  |
   212        | party1 | ETH/MAR11 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-22  |
   213        | party2 | ETH/MAR11 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-23 |
   214        | party2 | ETH/MAR11 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-24 |
   215        | party1 | ETH/MAR12 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-31  |
   216        | party1 | ETH/MAR12 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-32  |
   217        | party2 | ETH/MAR12 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-33 |
   218        | party2 | ETH/MAR12 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-34 |
   219        | party1 | ETH/MAR21 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-41  |
   220        | party1 | ETH/MAR21 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-42  |
   221        | party2 | ETH/MAR21 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-43 |
   222        | party2 | ETH/MAR21 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-44 |
   223  
   224      And the parties place the following orders:
   225        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   226        | party1 | ETH/MAR22 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   227        | party1 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   228        | party2 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   229        | party2 | ETH/MAR22 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   230        | party1 | ETH/MAR31 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-21  |
   231        | party1 | ETH/MAR31 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-22  |
   232        | party2 | ETH/MAR31 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-23 |
   233        | party2 | ETH/MAR31 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-24 |
   234        | party1 | ETH/MAR32 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-31  |
   235        | party1 | ETH/MAR32 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-32  |
   236        | party2 | ETH/MAR32 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-33 |
   237        | party2 | ETH/MAR32 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-34 |
   238  
   239      And the parties place the following orders:
   240        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   241        | party1 | ETH/MAR41 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   242        | party1 | ETH/MAR41 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   243        | party2 | ETH/MAR41 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   244        | party2 | ETH/MAR41 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   245        | party1 | ETH/MAR42 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-21  |
   246        | party1 | ETH/MAR42 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-22  |
   247        | party2 | ETH/MAR42 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-23 |
   248        | party2 | ETH/MAR42 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-24 |
   249        | party1 | ETH/MAR43 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-31  |
   250        | party1 | ETH/MAR43 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-32  |
   251        | party2 | ETH/MAR43 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-33 |
   252        | party2 | ETH/MAR43 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-34 |
   253        | party1 | ETH/MAR51 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-41  |
   254        | party1 | ETH/MAR51 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-42  |
   255        | party2 | ETH/MAR51 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-43 |
   256        | party2 | ETH/MAR51 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-44 |
   257  
   258      When the network moves ahead "2" blocks
   259      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR0"
   260      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR11"
   261      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR12"
   262      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR21"
   263      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22"
   264      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR31"
   265      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR32"
   266  
   267      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR41"
   268      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR42"
   269      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR43"
   270  
   271      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR51"
   272  
   273      And the market data for the market "ETH/MAR0" should be:
   274        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   275        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   276      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 3.5569036 =35569
   277      And the market data for the market "ETH/MAR11" should be:
   278        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   279        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 49256        | 50000          | 10            |
   280      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 4.9256840 = 49256
   281      And the market data for the market "ETH/MAR12" should be:
   282        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   283        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 6719         | 50000          | 10            |
   284      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.67191327433 = 6719
   285      And the market data for the market "ETH/MAR21" should be:
   286        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   287        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 4            | 50000          | 10            |
   288      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.0004950 = 4
   289      And the market data for the market "ETH/MAR22" should be:
   290        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   291        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   292      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 3.5569036 =35569
   293      And the market data for the market "ETH/MAR31" should be:
   294        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   295        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   296      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 3.55690313589 = 35569
   297      And the market data for the market "ETH/MAR32" should be:
   298        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   299        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   300      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 3.55690313589 = 35569
   301  
   302      And the market data for the market "ETH/MAR41" should be:
   303        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   304        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   305      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.16882368861315200 =1689
   306      And the market data for the market "ETH/MAR42" should be:
   307        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   308        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   309      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.36483236867768200 = 3648
   310      And the market data for the market "ETH/MAR43" should be:
   311        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   312        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 35569        | 50000          | 10            |
   313      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.13281340025639400 = 1328
   314      And the market data for the market "ETH/MAR51" should be:
   315        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   316        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 1000      | 1000      | 15           | 50000          | 10            |
   317      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 0.00156597682 = 15
   318  
   319      Then the order book should have the following volumes for market "ETH/MAR0":
   320        | side | price | volume |
   321        | sell | 1100  | 1      |
   322        | sell | 1120  | 45     |
   323        | buy  | 900   | 1      |
   324        | buy  | 880   | 57     |
   325      Then the order book should have the following volumes for market "ETH/MAR11":
   326        | side | price | volume |
   327        | sell | 1100  | 1      |
   328        | sell | 1120  | 45     |
   329        | buy  | 900   | 1      |
   330        | buy  | 880   | 57     |
   331      Then the order book should have the following volumes for market "ETH/MAR12":
   332        | side | price | volume |
   333        | sell | 1100  | 1      |
   334        | sell | 1120  | 45     |
   335        | buy  | 900   | 1      |
   336        | buy  | 880   | 57     |
   337      Then the order book should have the following volumes for market "ETH/MAR21":
   338        | side | price | volume |
   339        | sell | 1100  | 1      |
   340        | sell | 1120  | 45     |
   341        | buy  | 900   | 1      |
   342        | buy  | 880   | 57     |
   343      Then the order book should have the following volumes for market "ETH/MAR22":
   344        | side | price | volume |
   345        | sell | 1100  | 1      |
   346        | sell | 1120  | 45     |
   347        | buy  | 900   | 1      |
   348        | buy  | 880   | 57     |
   349      Then the order book should have the following volumes for market "ETH/MAR31":
   350        | side | price | volume |
   351        | sell | 1100  | 1      |
   352        | sell | 1120  | 45     |
   353        | buy  | 900   | 1      |
   354        | buy  | 880   | 57     |
   355      Then the order book should have the following volumes for market "ETH/MAR32":
   356        | side | price | volume |
   357        | sell | 1100  | 1      |
   358        | sell | 1120  | 45     |
   359        | buy  | 900   | 1      |
   360        | buy  | 880   | 57     |
   361      Then the order book should have the following volumes for market "ETH/MAR41":
   362        | side | price | volume |
   363        | sell | 1100  | 1      |
   364        | sell | 1120  | 45     |
   365        | buy  | 900   | 1      |
   366        | buy  | 880   | 57     |
   367      Then the order book should have the following volumes for market "ETH/MAR42":
   368        | side | price | volume |
   369        | sell | 1100  | 1      |
   370        | sell | 1120  | 45     |
   371        | buy  | 900   | 1      |
   372        | buy  | 880   | 57     |
   373      Then the order book should have the following volumes for market "ETH/MAR43":
   374        | side | price | volume |
   375        | sell | 1100  | 1      |
   376        | sell | 1120  | 45     |
   377        | buy  | 900   | 1      |
   378        | buy  | 880   | 57     |
   379  
   380      Then the order book should have the following volumes for market "ETH/MAR51":
   381        | side | price | volume |
   382        | sell | 1100  | 1      |
   383        | sell | 1120  | 45     |
   384        | buy  | 900   | 1      |
   385        | buy  | 880   | 57     |
   386  
   387      And the parties should have the following account balances:
   388        | party  | asset | market id | margin | general        | bond  |
   389        | party0 | USD   | ETH/MAR0  | 192073 | 49999997803076 | 50000 |
   390        | party1 | USD   | ETH/MAR0  | 13570  | 49999999875869 |       |
   391        | party2 | USD   | ETH/MAR0  | 47378  | 49999999584845 |       |
   392      # intial margin level for LP = 92*1000*1.2*3.5569036=392682
   393  
   394      And the parties should have the following account balances:
   395        | party  | asset | market id | margin | general        | bond  |
   396        | party0 | USD   | ETH/MAR11 | 265987 | 49999997803076 | 50000 |
   397        | party1 | USD   | ETH/MAR11 | 14179  | 49999999875869 |       |
   398        | party2 | USD   | ETH/MAR11 | 65611  | 49999999584845 |       |
   399      # intial margin level for LP = 92*1000*1.2*4.9256840 =543796
   400  
   401      And the parties should have the following account balances:
   402        | party  | asset | market id | margin | general        | bond  |
   403        | party0 | USD   | ETH/MAR12 | 36284  | 49999997803076 | 50000 |
   404        | party1 | USD   | ETH/MAR12 | 8934   | 49999999875869 |       |
   405        | party2 | USD   | ETH/MAR12 | 11870  | 49999999584845 |       |
   406  
   407      And the parties should have the following account balances:
   408        | party  | asset | market id | margin | general        | bond  |
   409        | party0 | USD   | ETH/MAR21 | 34     | 49999997803076 | 50000 |
   410        | party1 | USD   | ETH/MAR21 | 3007   | 49999999875869 |       |
   411        | party2 | USD   | ETH/MAR21 | 3007   | 49999999584845 |       |
   412  
   413      And the parties should have the following account balances:
   414        | party  | asset | market id | margin | general        | bond  |
   415        | party0 | USD   | ETH/MAR22 | 192073 | 49999997803076 | 50000 |
   416        | party1 | USD   | ETH/MAR22 | 13570  | 49999999875869 |       |
   417        | party2 | USD   | ETH/MAR22 | 47378  | 49999999584845 |       |
   418  
   419      And the parties should have the following account balances:
   420        | party  | asset | market id | margin | general        | bond  |
   421        | party0 | USD   | ETH/MAR31 | 192073 | 49999997803076 | 50000 |
   422        | party1 | USD   | ETH/MAR31 | 13570  | 49999999875869 |       |
   423        | party2 | USD   | ETH/MAR31 | 47378  | 49999999584845 |       |
   424  
   425      And the parties should have the following account balances:
   426        | party  | asset | market id | margin | general        | bond  |
   427        | party0 | USD   | ETH/MAR32 | 192073 | 49999997803076 | 50000 |
   428        | party1 | USD   | ETH/MAR32 | 13570  | 49999999875869 |       |
   429        | party2 | USD   | ETH/MAR32 | 47378  | 49999999584845 |       |
   430  
   431      And the parties should have the following account balances:
   432        | party  | asset | market id | margin | general        | bond  |
   433        | party0 | USD   | ETH/MAR41 | 192073 | 49999997803076 | 50000 |
   434        | party1 | USD   | ETH/MAR41 | 13570  | 49999999875869 |       |
   435        | party2 | USD   | ETH/MAR41 | 47378  | 49999999584845 |       |
   436  
   437      And the parties should have the following account balances:
   438        | party  | asset | market id | margin | general        | bond  |
   439        | party0 | USD   | ETH/MAR42 | 192073 | 49999997803076 | 50000 |
   440        | party1 | USD   | ETH/MAR42 | 13570  | 49999999875869 |       |
   441        | party2 | USD   | ETH/MAR42 | 47378  | 49999999584845 |       |
   442  
   443      And the parties should have the following account balances:
   444        | party  | asset | market id | margin | general        | bond  |
   445        | party0 | USD   | ETH/MAR43 | 192073 | 49999997803076 | 50000 |
   446        | party1 | USD   | ETH/MAR43 | 13570  | 49999999875869 |       |
   447        | party2 | USD   | ETH/MAR43 | 47378  | 49999999584845 |       |
   448  
   449      And the parties should have the following account balances:
   450        | party  | asset | market id | margin | general        | bond  |
   451        | party0 | USD   | ETH/MAR51 | 108    | 49999997803076 | 50000 |
   452        | party1 | USD   | ETH/MAR51 | 3021   | 49999999875869 |       |
   453        | party2 | USD   | ETH/MAR51 | 3021   | 49999999584845 |       |
   454  
   455    @Now
   456    Scenario: 002, test market ETH/MAR23 (tau=1)
   457  
   458      Given the liquidity monitoring parameters:
   459        | name               | triggering ratio | time window | scaling factor |
   460        | updated-lqm-params | 0.1              | 24h         | 1              |
   461      When the markets are updated:
   462        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   463        | ETH/MAR0  | updated-lqm-params   | 0.25                   | 0                         |
   464        | ETH/MAR11 | updated-lqm-params   | 0.25                   | 0                         |
   465        | ETH/MAR12 | updated-lqm-params   | 0.25                   | 0                         |
   466        | ETH/MAR21 | updated-lqm-params   | 0.25                   | 0                         |
   467        | ETH/MAR22 | updated-lqm-params   | 0.25                   | 0                         |
   468        | ETH/MAR23 | updated-lqm-params   | 0.25                   | 0                         |
   469        | ETH/MAR32 | updated-lqm-params   | 0.25                   | 0                         |
   470        | ETH/MAR31 | updated-lqm-params   | 0.25                   | 0                         |
   471        | ETH/MAR41 | updated-lqm-params   | 0.25                   | 0                         |
   472        | ETH/MAR42 | updated-lqm-params   | 0.25                   | 0                         |
   473        | ETH/MAR43 | updated-lqm-params   | 0.25                   | 0                         |
   474        | ETH/MAR51 | updated-lqm-params   | 0.25                   | 0                         |
   475        | ETH/MAR52 | updated-lqm-params   | 0.25                   | 0                         |
   476        | ETH/MAR53 | updated-lqm-params   | 0.25                   | 0                         |
   477  
   478      And the following network parameters are set:
   479        | name                                  | value |
   480        | market.liquidity.bondPenaltyParameter | 0.2   |
   481  
   482      And the average block duration is "1"
   483  
   484      And the parties submit the following liquidity provision:
   485        | id  | party  | market id | commitment amount | fee   | lp type    |
   486        | lp1 | party0 | ETH/MAR23 | 5000000           | 0.001 | submission |
   487        | lp1 | party0 | ETH/MAR23 | 5000000           | 0.001 | amendment  |
   488      And the parties place the following pegged iceberg orders:
   489        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   490        | party0 | ETH/MAR23 | 4465 | 1 | sell | ASK | 4465 | 20 |
   491        | party0 | ETH/MAR23 | 5682 | 1 | buy  | BID | 5682 | 20 |
   492  
   493      And the parties place the following orders:
   494        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   495        | party1 | ETH/MAR23 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   496        | party1 | ETH/MAR23 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   497        | party2 | ETH/MAR23 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   498        | party2 | ETH/MAR23 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   499  
   500      When the opening auction period ends for market "ETH/MAR23"
   501      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR23"
   502  
   503      And the market data for the market "ETH/MAR23" should be:
   504        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   505        | 1000       | TRADING_MODE_CONTINUOUS | 43200   | 909       | 1099      | 862176       | 5000000        | 10            |
   506      #target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1000 x 10 x 1 x 86.2176101 =862176
   507  
   508      Then the order book should have the following volumes for market "ETH/MAR23":
   509        | side | price | volume |
   510        | sell | 1100  | 1      |
   511        | sell | 1120  | 4465   |
   512        | buy  | 900   | 1      |
   513        | buy  | 880   | 5682   |
   514      And the parties should have the following account balances:
   515        | party  | asset | market id | margin    | general        | bond    |
   516        | party0 | USD   | ETH/MAR23 | 461953956 | 49999533046044 | 5000000 |
   517        | party1 | USD   | ETH/MAR23 | 16142     | 49999999983858 |         |
   518        | party2 | USD   | ETH/MAR23 | 1148419   | 49999998851581 |         |
   519  
   520    # initial margin level for LP = 1000*9092*86.2176101*1.2=9.4e8
   521  
   522    @Now
   523    Scenario: 003, test market ETH/MAR52(sigma=10),
   524  
   525      Given the liquidity monitoring parameters:
   526        | name               | triggering ratio | time window | scaling factor |
   527        | updated-lqm-params | 0.1              | 24h         | 1              |
   528      When the markets are updated:
   529        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   530        | ETH/MAR0  | updated-lqm-params   | 0.25                   | 0                         |
   531        | ETH/MAR11 | updated-lqm-params   | 0.25                   | 0                         |
   532        | ETH/MAR12 | updated-lqm-params   | 0.25                   | 0                         |
   533        | ETH/MAR21 | updated-lqm-params   | 0.25                   | 0                         |
   534        | ETH/MAR22 | updated-lqm-params   | 0.25                   | 0                         |
   535        | ETH/MAR23 | updated-lqm-params   | 0.25                   | 0                         |
   536        | ETH/MAR31 | updated-lqm-params   | 0.25                   | 0                         |
   537        | ETH/MAR32 | updated-lqm-params   | 0.25                   | 0                         |
   538        | ETH/MAR41 | updated-lqm-params   | 0.25                   | 0                         |
   539        | ETH/MAR42 | updated-lqm-params   | 0.25                   | 0                         |
   540        | ETH/MAR43 | updated-lqm-params   | 0.25                   | 0                         |
   541        | ETH/MAR51 | updated-lqm-params   | 0.25                   | 0                         |
   542        | ETH/MAR52 | updated-lqm-params   | 0.25                   | 0                         |
   543        | ETH/MAR53 | updated-lqm-params   | 0.25                   | 0                         |
   544      And the following network parameters are set:
   545        | name                                  | value |
   546        | market.liquidity.bondPenaltyParameter | 0.2   |
   547  
   548      And the average block duration is "1"
   549  
   550      And the parties submit the following liquidity provision:
   551        | id  | party  | market id | commitment amount | fee   | lp type    |
   552        | lp1 | party0 | ETH/MAR52 | 600000            | 0.001 | submission |
   553        | lp1 | party0 | ETH/MAR52 | 600000            | 0.001 | amendment  |
   554      And the parties place the following pegged iceberg orders:
   555        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   556        | party0 | ETH/MAR52 | 30000  | 1 | sell | ASK | 30000  | 9 |
   557        | party0 | ETH/MAR52 | 600000 | 1 | buy  | BID | 600000 | 8 |
   558   
   559      And the parties place the following orders:
   560        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   561        | party1 | ETH/MAR52 | buy  | 10     | 9     | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-11  |
   562        | party1 | ETH/MAR52 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-12  |
   563        | party2 | ETH/MAR52 | sell | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-13 |
   564        | party2 | ETH/MAR52 | sell | 10     | 11    | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-14 |
   565  
   566      When the opening auction period ends for market "ETH/MAR52"
   567      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR52"
   568      # And the network moves ahead "1" blocks
   569  
   570      And the market data for the market "ETH/MAR52" should be:
   571        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   572        | 10         | TRADING_MODE_CONTINUOUS | 43200   | 4         | 24        | 557872       | 600000         | 1             |
   573      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf_short = 1 x 10 x 1 x 55787.28815617000 =557872
   574  
   575      Then the order book should have the following volumes for market "ETH/MAR52":
   576        | side | price | volume |
   577        | sell | 20    | 30000  |
   578        | sell | 11    | 10     |
   579        | buy  | 9     | 10     |
   580        | buy  | 1     | 600000 |
   581      And the parties should have the following account balances:
   582        | party  | asset | market id | margin      | general        | bond   |
   583        | party0 | USD   | ETH/MAR52 | 20083423736 | 49979915976264 | 600000 |
   584        | party1 | USD   | ETH/MAR52 | 135         | 49999999999865 |        |
   585        | party2 | USD   | ETH/MAR52 | 8033370     | 49999991966630 |        |
   586  
   587  # initial margin level for LP = 10*114559*55787.2881561700*1.2=7.66e10
   588  
   589