code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0016-PFUT-026.feature (about)

     1  Feature: Futures market can be created with a with [hardcoded risk factors](./0018-RSKM-quant_risk_models.ipynb).
     2    Background:
     3      # Set liquidity parameters to allow "zero" target-stake which is needed to construct the order-book defined in the ACs
     4      Given the following network parameters are set:
     5        | name                                    | value |
     6        | network.markPriceUpdateMaximumFrequency | 1s    |
     7      And the liquidity monitoring parameters:
     8        | name       | triggering ratio | time window | scaling factor |
     9        | lqm-params | 0.001            | 24h         | 1e-9           |
    10      And the simple risk model named "simple-risk-model":
    11        | long | short | max move up | min move down | probability of trading |
    12        | 0.1  | 0.2   | 100         | -100          | 0.2                    |
    13      And the log normal risk model named "lognormal-risk-model-1":
    14        | risk aversion | tau  | mu | r   | sigma |
    15        | 0.0002        | 0.01 | 0  | 0.0 | 1.2   |
    16      #rf_long: 0.369668054
    17      #rf_short: 0.5650462
    18      And the markets:
    19        | 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      | max price cap | fully collateralised | binary |
    20        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures | 19000         | false                | false  |
    21    @NoPerp
    22    Scenario: 001 0016-PFUT-026, 0016-PFUT-028
    23      Given the parties deposit on asset's general account the following amount:
    24        | party            | asset | amount  |
    25        | buySideProvider  | USD   | 1000000 |
    26        | sellSideProvider | USD   | 1000000 |
    27        | aux1             | USD   | 1000000 |
    28        | aux2             | USD   | 100000  |
    29        | party            | USD   | 480500  |
    30        | party1           | USD   | 480500  |
    31      And the parties place the following orders:
    32        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    33        | aux1             | ETH/FEB23 | buy  | 10     | 14900 | 0                | TYPE_LIMIT | TIF_GTC |             |
    34        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15000 | 0                | TYPE_LIMIT | TIF_GTC |             |
    35        | buySideProvider  | ETH/FEB23 | buy  | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |             |
    36        | party            | ETH/FEB23 | sell | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC |             |
    37        | party            | ETH/FEB23 | sell | 3      | 15900 | 0                | TYPE_LIMIT | TIF_GTC | party-sell  |
    38        | party1           | ETH/FEB23 | sell | 3      | 16100 | 0                | TYPE_LIMIT | TIF_GTC | party1-sell |
    39        | sellSideProvider | ETH/FEB23 | sell | 1      | 18100 | 0                | TYPE_LIMIT | TIF_GTC |             |
    40        | aux2             | ETH/FEB23 | sell | 10     | 18200 | 0                | TYPE_LIMIT | TIF_GTC |             |
    41  
    42      When the network moves ahead "2" blocks
    43      Then the mark price should be "15900" for the market "ETH/FEB23"
    44  
    45      And the average fill price is:
    46        | market    | volume | side | ref price | mark price | equivalent linear slippage factor |
    47        | ETH/FEB23 | 3      | sell | 15900     | 15900      | 0                                 |
    48  
    49      #party margin:15900*(0.25+0.2)*3 +15900*0.2*3=31005
    50      And the parties should have the following margin levels:
    51        | party | market id | maintenance |
    52        | party | ETH/FEB23 | 31005       |
    53        | aux1  | ETH/FEB23 | 15900       |
    54        | aux2  | ETH/FEB23 | 31800       |
    55  
    56      Then the parties should have the following account balances:
    57        | party | asset | market id | margin | general |
    58        | party | USD   | ETH/FEB23 | 37206  | 443294  |
    59        | aux1  | USD   | ETH/FEB23 | 17880  | 982120  |
    60        | aux2  | USD   | ETH/FEB23 | 43680  | 56320   |
    61  
    62      #0016-PFUT-028: Updating a risk model on a futures market with [hardcoded risk factors]
    63      And the markets are updated:
    64        | id        | risk model             |
    65        | ETH/FEB23 | lognormal-risk-model-1 |
    66  
    67      And the parties place the following orders:
    68        | party           | market id | side | volume | price | resulting trades | type       | tif     | reference |
    69        | buySideProvider | ETH/FEB23 | buy  | 1      | 15900 | 1                | TYPE_LIMIT | TIF_GTC |           |
    70      And the network moves ahead "3" blocks
    71  
    72      Then the parties should have the following account balances:
    73        | party | asset | market id | margin | general |
    74        | party | USD   | ETH/FEB23 | 83767  | 396733  |
    75        | aux1  | USD   | ETH/FEB23 | 70533  | 929467  |
    76        | aux2  | USD   | ETH/FEB23 | 100000 | 0       |
    77  
    78      #party margin:15900*(0.25+0.5650462)*4 +15900*0.5650462*2=69806
    79      And the parties should have the following margin levels:
    80        | party | market id | maintenance |
    81        | party | ETH/FEB23 | 69806       |
    82        | aux1  | ETH/FEB23 | 58778       |
    83        | aux2  | ETH/FEB23 | 89843       |
    84  
    85      #0016-PFUT-027: Updating a risk model on a futures market with regular risk model to with [hardcoded risk factors]
    86      And the markets are updated:
    87        | id        | risk model        |
    88        | ETH/FEB23 | simple-risk-model |
    89  
    90      And the parties place the following orders:
    91        | party           | market id | side | volume | price | resulting trades | type       | tif     | reference |
    92        | buySideProvider | ETH/FEB23 | buy  | 1      | 15900 | 1                | TYPE_LIMIT | TIF_GTC |           |
    93      And the network moves ahead "3" blocks
    94  
    95      Then the parties should have the following account balances:
    96        | party | asset | market id | margin | general |
    97        | party | USD   | ETH/FEB23 | 46746  | 433754  |
    98        | aux1  | USD   | ETH/FEB23 | 19080  | 980920  |
    99        | aux2  | USD   | ETH/FEB23 | 38160  | 61840   |
   100  
   101      #party margin:15900*(0.25+0.2)*5 +15900*0.2*1=69806=38955
   102      And the parties should have the following margin levels:
   103        | party | market id | maintenance |
   104        | party | ETH/FEB23 | 38955       |
   105        | aux1  | ETH/FEB23 | 15900       |
   106        | aux2  | ETH/FEB23 | 31800       |