Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
41 changes: 35 additions & 6 deletions src/views/Daily.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
***************/
Expand Down Expand Up @@ -801,11 +831,10 @@ function getOHLC(date, symbol, type) {
:data-index="index" class="ms-2 uil uil-tag-alt pointerClass"></i>

</div>
<div class="col-12 col-lg-auto ms-auto">P&L({{ selectedGrossNet.charAt(0)
}}):
<div class="col-12 col-lg-auto ms-auto">P/L Ratio:
<span
v-bind:class="[itemTrade.pAndL[amountCase + 'Proceeds'] > 0 ? 'greenTrade' : 'redTrade']">{{
useTwoDecCurrencyFormat(itemTrade.pAndL[amountCase + 'Proceeds'])
v-bind:class="[itemTrade.pAndL.grossWinsCount/(itemTrade.pAndL.grossWinsCount+itemTrade.pAndL.grossLossCount) < 0.5 && getPLRatio(itemTrade) < 1.0 ? 'redTrade' : 'greenTrade']">{{
getPLRatio(itemTrade)
}}</span>
</div>

Expand Down Expand Up @@ -882,8 +911,8 @@ function getOHLC(date, symbol, type) {
</div>
<div>
<label>P&L(g)</label>
<p>{{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds)
}}
<p v-bind:class="[itemTrade.pAndL[amountCase + 'Proceeds'] > 0 ? 'greenTrade' : 'redTrade']">
{{ useTwoDecCurrencyFormat(itemTrade.pAndL.grossProceeds) }}
</p>
</div>
</div>
Expand Down