diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c8a6920..c829aec 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: @@ -40,7 +44,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 @@ -69,6 +76,14 @@ 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 }}" = "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 + fi + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 @@ -83,6 +98,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 }} diff --git a/src/views/Daily.vue b/src/views/Daily.vue index a68afab..827a636 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 ***************/ @@ -801,11 +831,10 @@ function getOHLC(date, symbol, type) { :data-index="index" class="ms-2 uil uil-tag-alt pointerClass"> -
{{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds) - }} +
+ {{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds) }}