From b47dd36c6fdc5d0252e4f2874e0f7488c3637a8b Mon Sep 17 00:00:00 2001 From: Siyuan Wang Date: Mon, 16 Oct 2023 07:49:21 -0500 Subject: [PATCH] fix: get close price by profit (#188) --- .../changes/@yuants/data-model/2023-10-16-12-37.json | 10 ++++++++++ common/changes/@yuants/kernel/2023-10-16-12-37.json | 10 ++++++++++ libraries/data-model/src/utils.ts | 2 +- libraries/kernel/src/utils.ts | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 common/changes/@yuants/data-model/2023-10-16-12-37.json create mode 100644 common/changes/@yuants/kernel/2023-10-16-12-37.json diff --git a/common/changes/@yuants/data-model/2023-10-16-12-37.json b/common/changes/@yuants/data-model/2023-10-16-12-37.json new file mode 100644 index 00000000..9764ae80 --- /dev/null +++ b/common/changes/@yuants/data-model/2023-10-16-12-37.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/data-model", + "comment": "bug fix", + "type": "patch" + } + ], + "packageName": "@yuants/data-model" +} \ No newline at end of file diff --git a/common/changes/@yuants/kernel/2023-10-16-12-37.json b/common/changes/@yuants/kernel/2023-10-16-12-37.json new file mode 100644 index 00000000..6f07ac56 --- /dev/null +++ b/common/changes/@yuants/kernel/2023-10-16-12-37.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/kernel", + "comment": "bug fix", + "type": "patch" + } + ], + "packageName": "@yuants/kernel" +} \ No newline at end of file diff --git a/libraries/data-model/src/utils.ts b/libraries/data-model/src/utils.ts index 8bd3e295..6b889bc6 100644 --- a/libraries/data-model/src/utils.ts +++ b/libraries/data-model/src/utils.ts @@ -110,7 +110,7 @@ export const getClosePriceByDesiredProfit = ( const beta = desiredProfit / (variant_coefficient * volume * (product.value_scale ?? 1)); - if (product.value_unit === 'BASE') { + if (product.value_unit === 'NORM') { return openPrice + beta / cross_product_exchange_rate; } if (product.quoted_currency === currency) { diff --git a/libraries/kernel/src/utils.ts b/libraries/kernel/src/utils.ts index 9f41a39b..dda78e1c 100644 --- a/libraries/kernel/src/utils.ts +++ b/libraries/kernel/src/utils.ts @@ -65,7 +65,7 @@ export const getClosePriceByDesiredProfit = ( const beta = desiredProfit / (variant_coefficient * volume * (product.value_speed ?? 1)); - if (product.is_underlying_base_currency) { + if (!product.is_underlying_base_currency) { return openPrice + beta / cross_product_exchange_rate; } if (product.quoted_currency === currency) {