Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 0daaef2

Browse files
refactor: to fix pnl margin calculator issues (#4208)
1 parent 24ff865 commit 0daaef2

File tree

5 files changed

+281
-115
lines changed

5 files changed

+281
-115
lines changed

crowdin/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3092,9 +3092,9 @@
30923092
"-195404006": "Take profit pip value",
30933093
"-1659122470": "Our profit and loss calculator for margin helps you to approximate your losses and/or gains.",
30943094
"-137444201": "Buy",
3095-
"-805098509": "Open price of asset",
30963095
"-213618448": "Stop loss pips",
30973096
"-544680075": "Take profit pips",
3097+
"-805098509": "Open price of asset",
30983098
"-168442931": "How to calculate stop loss and/or take profit level and pip value",
30993099
"-431890384": "The stop loss and/or take profit level and pip value when buying a contract on Deriv MT5 is calculated based on the formula:",
31003100
"-1812417493": "<0>Stop loss and/or take profit level = asset price + {stop loss OR take profit amount ÷ (volume × contract size)}</0>",

src/components/form/input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ const Input = ({
249249
height={height}
250250
showLabel={label}
251251
{...props}
252-
ref={() => current_input}
252+
ref={current_input}
253253
/>
254254
{label && (
255255
<StyledLabel

src/pages/trader-tools/common/_utility.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type ErrorsType = {
44
errors?: null
55
symbol?: string
66
volume?: string | JSX.Element
7-
assetPrice?: string
7+
assetPrice?: string | JSX.Element
88
leverage?: string
99
pointValue?: string | JSX.Element
1010
takeProfitAmount?: string | JSX.Element
@@ -89,7 +89,7 @@ export const getPnlMarginCommon = (values, action) => {
8989
return toFixed(take_profit_level_formula)
9090
}
9191
case 'getStopLossLevelBuy': {
92-
const stop_loss_level_formula = assetPrice + [-stopLossAmount / (volume * contractSize)]
92+
const stop_loss_level_formula = assetPrice + -[stopLossAmount / (volume * contractSize)]
9393
return toFixed(stop_loss_level_formula)
9494
}
9595
case 'getTakeProfitLevelBuy': {

src/pages/trader-tools/common/_validation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ const validation = {
7171
if (!input || input.name === 'default') {
7272
return localize('Asset Price is required')
7373
}
74+
if (input) {
75+
return numberValidation(input.toString(), localize('Asset Price is required'), 15)
76+
}
7477

7578
return null
7679
},

0 commit comments

Comments
 (0)