From d93ef16e508caf539cfbdfc926d4330d8b45d396 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 02:40:16 +0000 Subject: [PATCH 01/10] Implement daily P&L Ratio --- src/views/Daily.vue | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index a68afab..fbe89d7 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -393,6 +393,36 @@ const checkDate = ((param1, param2) => { return check }) +// Compute P/L Ratio for a daily itemTrade (avg win per share / avg loss per share) +const getPLRatio = (itemTrade) => { + try { + if (!itemTrade || !itemTrade.pAndL) return '-' + const p = itemTrade.pAndL + const pref = amountCase && amountCase.value ? amountCase.value : amountCase + + const winSum = p[pref + 'SharePLWins'] || p[pref + 'SharePLWins'] === 0 ? p[pref + 'SharePLWins'] : null + const winCount = p[pref + 'WinsCount'] || p[pref + 'WinsCount'] === 0 ? p[pref + 'WinsCount'] : null + const lossSum = p[pref + 'SharePLLoss'] || p[pref + 'SharePLLoss'] === 0 ? p[pref + 'SharePLLoss'] : null + const lossCount = p[pref + 'LossCount'] || p[pref + 'LossCount'] === 0 ? p[pref + 'LossCount'] : null + + if (!winSum || !winCount || !lossSum || !lossCount) { + // Fallback: try keys without 'SharePL' prefix (older structures) + const altWinSum = p[pref + 'Wins'] || p[pref + 'Wins'] === 0 ? p[pref + 'Wins'] : null + const altLossSum = p[pref + 'Loss'] || p[pref + 'Loss'] === 0 ? p[pref + 'Loss'] : null + if (altWinSum == null || altLossSum == null || winCount == 0 || lossCount == 0) return '-' + } + + const avgWinPerShare = (winSum / winCount) + const avgLossPerShare = (-(lossSum) / lossCount) + + if (!isFinite(avgWinPerShare) || !isFinite(avgLossPerShare) || avgLossPerShare === 0) return '-' + + return (avgWinPerShare / avgLossPerShare).toFixed(2) + } catch (e) { + return '-' + } +} + /************** * SATISFACTION ***************/ @@ -808,6 +838,9 @@ function getOHLC(date, symbol, type) { useTwoDecCurrencyFormat(itemTrade.pAndL[amountCase + 'Proceeds']) }} +
P/L Ratio: + {{ getPLRatio(itemTrade) }} +
From 414645bc186c66faf3371df2c693c75de6de9ebc Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 02:58:53 +0000 Subject: [PATCH 02/10] always build and publish dockerfile --- .github/workflows/docker-publish.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c8de5ac..0958e96 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -34,7 +34,7 @@ jobs: push-to-ghcr: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' needs: build-test permissions: contents: read @@ -63,6 +63,16 @@ jobs: run: | echo "LOWERCASE_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Set IMAGE_TAG for build-test + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "IMAGE_TAG=test" >> $GITHUB_ENV + elif [ "${{ github.ref }}" = "refs/heads/main" ]; then + echo "IMAGE_TAG=latest" >> $GITHUB_ENV + else + echo "IMAGE_TAG=${GITHUB_SHA::8}" >> $GITHUB_ENV + fi + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 @@ -77,6 +87,6 @@ jobs: file: ./docker/Dockerfile push: true tags: | - ghcr.io/${{ env.LOWERCASE_REPO }}:latest + ghcr.io/${{ env.LOWERCASE_REPO }}:${{ env.IMAGE_TAG }} ghcr.io/${{ env.LOWERCASE_REPO }}:${{ github.sha }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 9523fb191a24c59fb3d33f9c53bd8e36e99c6223 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 16:51:33 +0000 Subject: [PATCH 03/10] use workflow for pushing tag test image --- .github/workflows/docker-publish.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0958e96..bedaf61 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,6 +7,12 @@ on: branches: [ main ] release: types: [ published ] + workflow_dispatch: + inputs: + manual_push: + description: 'Set to "yes" to push tag :test image to GHCR for testing before merging to main' + required: false + default: 'no' jobs: @@ -34,7 +40,10 @@ jobs: push-to-ghcr: runs-on: ubuntu-latest - # if: github.ref == 'refs/heads/main' + # Run if on main branch, or if manual_push is yes from workflow_dispatch + if: >- + (github.ref == 'refs/heads/main') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.manual_push == 'yes') needs: build-test permissions: contents: read @@ -65,12 +74,10 @@ jobs: - name: Set IMAGE_TAG for build-test run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.manual_push }}" = "yes" ]; then echo "IMAGE_TAG=test" >> $GITHUB_ENV elif [ "${{ github.ref }}" = "refs/heads/main" ]; then echo "IMAGE_TAG=latest" >> $GITHUB_ENV - else - echo "IMAGE_TAG=${GITHUB_SHA::8}" >> $GITHUB_ENV fi - name: Extract metadata for Docker From 556b826bc843a524028c82c8245ef16981e17cb7 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 17:25:46 +0000 Subject: [PATCH 04/10] update view --- src/views/Daily.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index fbe89d7..c262886 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -838,8 +838,11 @@ function getOHLC(date, symbol, type) { useTwoDecCurrencyFormat(itemTrade.pAndL[amountCase + 'Proceeds']) }}
-
P/L Ratio: - {{ getPLRatio(itemTrade) }} +
P/L Ratio: + {{ + useTwoDecCurrencyFormat(getPLRatio(itemTrade)) + }}
From 0adaa6d0f8de67a8487aa4c04598f424aacb5c55 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 17:30:04 +0000 Subject: [PATCH 05/10] choice for dropdown --- .github/workflows/docker-publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bedaf61..38a2976 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -13,6 +13,10 @@ on: description: 'Set to "yes" to push tag :test image to GHCR for testing before merging to main' required: false default: 'no' + type: choice + options: + - no + - yes jobs: From 3e49465b96667820af4181bd75c8866085232355 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 17:46:09 +0000 Subject: [PATCH 06/10] typo misspeeling --- src/views/Daily.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index c262886..bf4a31a 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -840,7 +840,7 @@ function getOHLC(date, symbol, type) {
P/L Ratio: {{ + v-bind:class="[itemTrade.pAndL.grossWinsCount/(itemTrade.pAndL.grossWinsCount+itemTrade.pAndL.grossLossCount) >=0.5 && getPLRatio(itemTrade) >= 1.0 ? 'greenTrade' : 'redTrade']">{{ useTwoDecCurrencyFormat(getPLRatio(itemTrade)) }}
From 69aeff401710b2dfd24c11866803f44d36a19eee Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 17:53:19 +0000 Subject: [PATCH 07/10] dev --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a531efc..c829aec 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -15,8 +15,8 @@ on: default: 'no' type: choice options: - - no - - yes + - 'no' + - 'yes' jobs: From 1c5302bb103790504159ea03ba32a99c43af0d95 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 18:08:29 +0000 Subject: [PATCH 08/10] remove currency --- src/views/Daily.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index bf4a31a..572e116 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -841,7 +841,7 @@ function getOHLC(date, symbol, type) {
P/L Ratio: {{ - useTwoDecCurrencyFormat(getPLRatio(itemTrade)) + getPLRatio(itemTrade) }}
From 497e1be10dbeaf1233cc044a5a77149ce090d4d9 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 18:19:17 +0000 Subject: [PATCH 09/10] bug --- src/views/Daily.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index 572e116..2870262 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -840,7 +840,7 @@ function getOHLC(date, symbol, type) {
P/L Ratio: {{ + v-bind:class="[itemTrade.pAndL.grossWinsCount/(itemTrade.pAndL.grossWinsCount+itemTrade.pAndL.grossLossCount) < 0.5 && getPLRatio(itemTrade) < 1.0 ? 'redTrade' : 'greenTrade']">{{ getPLRatio(itemTrade) }}
@@ -918,8 +918,8 @@ function getOHLC(date, symbol, type) {
-

{{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds) - }} +

+ {{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds) }}

From b110620f1e962c1e336e9c6a7d450092c3766065 Mon Sep 17 00:00:00 2001 From: gitricko Date: Tue, 14 Oct 2025 18:41:58 +0000 Subject: [PATCH 10/10] remove P&L dup data in daily --- src/views/Daily.vue | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index 2870262..827a636 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -831,13 +831,6 @@ function getOHLC(date, symbol, type) { :data-index="index" class="ms-2 uil uil-tag-alt pointerClass"> -
P&L({{ selectedGrossNet.charAt(0) - }}): - {{ - useTwoDecCurrencyFormat(itemTrade.pAndL[amountCase + 'Proceeds']) - }} -
P/L Ratio: {{