From f6e7a7d6e0ead1ff0399aff071bf6685b29390b9 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 09:11:55 +0000 Subject: [PATCH 1/6] feat: add more ACs --- protocol/0019-MCAL-margin_calculator.md | 39 +++++++++++++++++-------- protocol/features.json | 10 ++++++- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index 0f5a01847..fcf839697 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -94,29 +94,44 @@ sell 10 @ 100 100 ``` - when switching to isolated-margin mode and the `margin factor short = 0.11`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 57500 x 1 x 0.11 = 6325`, the switching will be rejected. (0019-MCAL-032) + - when switching to isolated-margin mode and the `margin factor short = 0.11`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 57500 x 1 x 0.11 = 6325`, the switching will be rejected. (0019-MCAL-032) - when switching to isolated-margin mode and the `margin factor short = 0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-033) + - when switching to isolated-margin mode and the `margin factor short = 0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-033) - when decreasing the `margin factor short` from `0.9` to `0.7`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.7 = 11130`, and margin account should be updated to `11130`. (0019-MCAL-031) + - when decreasing the `margin factor short` from `0.9` to `0.7`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.7 = 11130`, and margin account should be updated to `11130`. (0019-MCAL-031) - when increasing the `margin factor short` from `0.7` to `0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-059) + - when increasing the `margin factor short` from `0.7` to `0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-059) -- When the party place a new short order of `1` with price `15000`, and the market is in continuous trading. + - Switch to isolated margin mode will be rejected if the party does not have enough asset in the general account(0019-MCAL-066) - The margin account should have additional amount `average entry price x current position x new margin factor = 59524 x 1 x 0.3 = 17857` added if the party has enough asset in the general account(0019-MCAL-034) +- When the party place a new short order of `10` with price `15910` which does not offset the existing position, and the market is in continuous trading. - The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) + - The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transfered into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) -- When the party place a new short order of `1` with price `45000`, and the market is in continuous trading. + - The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) - The margin account should have additional amount `limit price * size * margin factor = 45000 x 1 x 0.3 = 13500` added if the party has enough asset in the general account(0019-MCAL-036) + - The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transfered from "order margin" account into general account (0019-MCAL-060) - The order will be rejected if the party does not have enough asset in the general account(0019-MCAL-037) + - Another trader placed a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) -- When the party place a new long order of `1` with price `145000` and the party has existing short position of `3`, and the market is in continuous trading. The margin account should not change(0019-MCAL-038) + - Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310` (0019-MCAL-065) -- When the party place a new long order of `10` with price `145000` and the party has existing short position of `3`, and the market is in continuous trading. The margin account should have additional amount `limit price * size * margin factor = 145000 x (10-3) x 0.3 = 304500` added if the party has enough asset in the general account(0019-MCAL-039) + - Switch from isolated margin to cross margin mode, the margin account is only updated in the next MTM (0019-MCAL-063) + + - Switch from cross margin to isolated margin mode, check both margin account and order margin are updated (0019-MCAL-064) + + - When the party has no orders, their order margin account should be `0` (0019-MCAL-062) + - Create some MTM, the margin account should be updated while order margin account should not (0019-MCAL-067) + +- When the party place a new long order of `2` with price `15912` which does offset the existing position, and the market is in continuous trading. + + - The margin account should not change as no additional margin is required (0019-MCAL-038) + + - When the party switch to cross margin mode, the margin accounts will not updated till nect MTM(0019-MCAL-036) + + - The order will be rejected if the party does not have enough asset in the general account(0019-MCAL-037) + + - When the party place a new long order of `10` with price `145000` and the party has existing short position of `3`, and the market is in continuous trading. The margin account should have additional amount `limit price * size * margin factor = 145000 x (10-3) x 0.3 = 304500` added if the party has enough asset in the general account(0019-MCAL-039) - Margin levels are correctly calculated in the case of an open position dropping below maintenance margin levels active orders will remain active as these are margined separately and will not be cancelled.(0019-MCAL-040) diff --git a/protocol/features.json b/protocol/features.json index 1c83ac15e..1c42f1fad 100644 --- a/protocol/features.json +++ b/protocol/features.json @@ -110,7 +110,15 @@ "0019-MCAL-056", "0019-MCAL-057", "0019-MCAL-058", - "0019-MCAL-059" + "0019-MCAL-059", + "0019-MCAL-060", + "0019-MCAL-061", + "0019-MCAL-062", + "0019-MCAL-063", + "0019-MCAL-064", + "0019-MCAL-065", + "0019-MCAL-066", + "0019-MCAL-067" ] }, "Quadratic slippage removal": { From 0b9a8af37b9571e2f656b2fcbc9c0cc66190e012 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 09:15:02 +0000 Subject: [PATCH 2/6] chore: markdown --- protocol/0019-MCAL-margin_calculator.md | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index fcf839697..3ded29961 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -94,34 +94,35 @@ sell 10 @ 100 100 ``` - - when switching to isolated-margin mode and the `margin factor short = 0.11`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 57500 x 1 x 0.11 = 6325`, the switching will be rejected. (0019-MCAL-032) + When switching to isolated-margin mode and the `margin factor short = 0.11`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 57500 x 1 x 0.11 = 6325`, the switching will be rejected. (0019-MCAL-032) - - when switching to isolated-margin mode and the `margin factor short = 0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-033) + When switching to isolated-margin mode and the `margin factor short = 0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-033) - - when decreasing the `margin factor short` from `0.9` to `0.7`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.7 = 11130`, and margin account should be updated to `11130`. (0019-MCAL-031) + When decreasing the `margin factor short` from `0.9` to `0.7`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.7 = 11130`, and margin account should be updated to `11130`. (0019-MCAL-031) - - when increasing the `margin factor short` from `0.7` to `0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-059) + When increasing the `margin factor short` from `0.7` to `0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-059) - - Switch to isolated margin mode will be rejected if the party does not have enough asset in the general account(0019-MCAL-066) + Switch to isolated margin mode will be rejected if the party does not have enough asset in the general account(0019-MCAL-066) - When the party place a new short order of `10` with price `15910` which does not offset the existing position, and the market is in continuous trading. - - The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transfered into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) + The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transfered into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) - - The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) + The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) - - The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transfered from "order margin" account into general account (0019-MCAL-060) + The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transfered from "order margin" account into general account (0019-MCAL-060) - - Another trader placed a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) + Another trader placed a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) - - Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310` (0019-MCAL-065) + Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310` (0019-MCAL-065) - - Switch from isolated margin to cross margin mode, the margin account is only updated in the next MTM (0019-MCAL-063) + Switch from isolated margin to cross margin mode, the margin account is only updated in the next MTM (0019-MCAL-063) - - Switch from cross margin to isolated margin mode, check both margin account and order margin are updated (0019-MCAL-064) + Switch from cross margin to isolated margin mode, check both margin account and order margin are updated (0019-MCAL-064) - - When the party has no orders, their order margin account should be `0` (0019-MCAL-062) - - Create some MTM, the margin account should be updated while order margin account should not (0019-MCAL-067) + When the party has no orders, their order margin account should be `0` (0019-MCAL-062) + + Create some MTM, the margin account should be updated while order margin account should not (0019-MCAL-067) - When the party place a new long order of `2` with price `15912` which does offset the existing position, and the market is in continuous trading. From 81840f2169b9d5b03693334de7531879df272017 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 09:16:45 +0000 Subject: [PATCH 3/6] chore: markdown --- protocol/0019-MCAL-margin_calculator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index 3ded29961..79bc4b795 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -121,7 +121,7 @@ Switch from cross margin to isolated margin mode, check both margin account and order margin are updated (0019-MCAL-064) When the party has no orders, their order margin account should be `0` (0019-MCAL-062) - + Create some MTM, the margin account should be updated while order margin account should not (0019-MCAL-067) - When the party place a new long order of `2` with price `15912` which does offset the existing position, and the market is in continuous trading. From f931448bcb42cb6a6fa2dcefbafe27d1a6147454 Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 09:21:33 +0000 Subject: [PATCH 4/6] chore: typo --- protocol/0019-MCAL-margin_calculator.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index 79bc4b795..e814c862c 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -106,11 +106,11 @@ - When the party place a new short order of `10` with price `15910` which does not offset the existing position, and the market is in continuous trading. - The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transfered into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) + The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transferred into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) - The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transfered from "order margin" account into general account (0019-MCAL-060) + The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transferred from "order margin" account into general account (0019-MCAL-060) Another trader placed a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) @@ -128,7 +128,7 @@ - The margin account should not change as no additional margin is required (0019-MCAL-038) - - When the party switch to cross margin mode, the margin accounts will not updated till nect MTM(0019-MCAL-036) + - When the party switch to cross margin mode, the margin accounts will not updated till next MTM(0019-MCAL-036) - The order will be rejected if the party does not have enough asset in the general account(0019-MCAL-037) From 310af14e79c238d7a825fe9a29bdc57deb475d5d Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 10:48:04 +0000 Subject: [PATCH 5/6] feat: address comments --- protocol/0019-MCAL-margin_calculator.md | 20 +++++++++----------- protocol/features.json | 1 - 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index e814c862c..59252b579 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -102,37 +102,35 @@ When increasing the `margin factor short` from `0.7` to `0.9`, the maintenance margin should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310`, and margin account should be updated to `14310`. (0019-MCAL-059) - Switch to isolated margin mode will be rejected if the party does not have enough asset in the general account(0019-MCAL-066) + Switching to isolated margin mode will be rejected if the party does not have enough asset in the general account(0019-MCAL-066) -- When the party place a new short order of `10` with price `15910` which does not offset the existing position, and the market is in continuous trading. +- When the party places a new short order of `10` with price `15910` which does not offset the existing position, and the market is in continuous trading. The margin account should have additional amount `limit price x size x margin factor = 15910 x 10 x 0.9 = 143190` transferred into "order margin" account if the party has enough asset in the general account(0019-MCAL-034) The order will be rejected if the party does not have enough asset in the general account (0019-MCAL-035) - The party amend the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transferred from "order margin" account into general account (0019-MCAL-060) + The party amends the order size to `5`, and the amount `limit price x size x margin factor = 15912 x 5 x 0.9 = 71604` will be transferred from "order margin" account into general account (0019-MCAL-060) - Another trader placed a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) + Another trader places a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) - Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to `average entry price x current position x new margin factor = 15900 x 1 x 0.9 = 14310` (0019-MCAL-065) + Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to intial margin level in cross margin mode(0019-MCAL-065) - Switch from isolated margin to cross margin mode, the margin account is only updated in the next MTM (0019-MCAL-063) - - Switch from cross margin to isolated margin mode, check both margin account and order margin are updated (0019-MCAL-064) + Switch from cross margin to isolated margin mode, both margin account and order margin should be updated (0019-MCAL-064) When the party has no orders, their order margin account should be `0` (0019-MCAL-062) Create some MTM, the margin account should be updated while order margin account should not (0019-MCAL-067) -- When the party place a new long order of `2` with price `15912` which does offset the existing position, and the market is in continuous trading. +- When the party places a new long order of `2` with price `15912` which does offset the existing position, and the market is in continuous trading. - The margin account should not change as no additional margin is required (0019-MCAL-038) - - When the party switch to cross margin mode, the margin accounts will not updated till next MTM(0019-MCAL-036) + - When the party switches to cross margin mode, the margin accounts will not be updated untill the next MTM(0019-MCAL-036) - The order will be rejected if the party does not have enough asset in the general account(0019-MCAL-037) - - When the party place a new long order of `10` with price `145000` and the party has existing short position of `3`, and the market is in continuous trading. The margin account should have additional amount `limit price * size * margin factor = 145000 x (10-3) x 0.3 = 304500` added if the party has enough asset in the general account(0019-MCAL-039) + - When the party place a new long order of `10` with price `145000` and the party has existing short position of `3`, and the market is in continuous trading. The margin account should have additional amount `limit price * size * margin factor = 145000 x (10-3) x 0.9 = 913500` added if the party has enough asset in the general account(0019-MCAL-039) - Margin levels are correctly calculated in the case of an open position dropping below maintenance margin levels active orders will remain active as these are margined separately and will not be cancelled.(0019-MCAL-040) diff --git a/protocol/features.json b/protocol/features.json index 1c42f1fad..482f1a019 100644 --- a/protocol/features.json +++ b/protocol/features.json @@ -114,7 +114,6 @@ "0019-MCAL-060", "0019-MCAL-061", "0019-MCAL-062", - "0019-MCAL-063", "0019-MCAL-064", "0019-MCAL-065", "0019-MCAL-066", From 78c3026ea2843f5e2afe898e5a15d3730b5a71db Mon Sep 17 00:00:00 2001 From: Jiajia-Cui Date: Tue, 28 Nov 2023 11:00:39 +0000 Subject: [PATCH 6/6] chore: typo --- protocol/0019-MCAL-margin_calculator.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/0019-MCAL-margin_calculator.md b/protocol/0019-MCAL-margin_calculator.md index 59252b579..4563a1241 100644 --- a/protocol/0019-MCAL-margin_calculator.md +++ b/protocol/0019-MCAL-margin_calculator.md @@ -114,7 +114,7 @@ Another trader places a buy order of `3` with price `15912`, party's position becomes `4`, party's margin account should be updated to `15912 x 4 x 0.9 =57283` and order margin should be `15912x 2 x 0.9 = 28642` (0019-MCAL-061) - Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to intial margin level in cross margin mode(0019-MCAL-065) + Switch margin mode from isolated margin to cross margin when party holds position only, the margin account should be updated to initial margin level in cross margin mode(0019-MCAL-065) Switch from cross margin to isolated margin mode, both margin account and order margin should be updated (0019-MCAL-064) @@ -126,7 +126,7 @@ - The margin account should not change as no additional margin is required (0019-MCAL-038) - - When the party switches to cross margin mode, the margin accounts will not be updated untill the next MTM(0019-MCAL-036) + - When the party switches to cross margin mode, the margin accounts will not be updated until the next MTM(0019-MCAL-036) - The order will be rejected if the party does not have enough asset in the general account(0019-MCAL-037)