Show change in M$
This commit is contained in:
parent
2cc08ba9e7
commit
ec1a9fab77
|
@ -20,7 +20,7 @@ import { getNotificationDestinationsForUser } from '../../common/user-notificati
|
||||||
import {
|
import {
|
||||||
PerContractInvestmentsData,
|
PerContractInvestmentsData,
|
||||||
OverallPerformanceData,
|
OverallPerformanceData,
|
||||||
} from 'functions/src/weekly-portfolio-emails'
|
} from './weekly-portfolio-emails'
|
||||||
|
|
||||||
export const sendMarketResolutionEmail = async (
|
export const sendMarketResolutionEmail = async (
|
||||||
reason: notification_reason_types,
|
reason: notification_reason_types,
|
||||||
|
@ -643,7 +643,7 @@ export const sendWeeklyPortfolioUpdateEmail = async (
|
||||||
templateData[`question${i + 1}Title`] = investment.questionTitle
|
templateData[`question${i + 1}Title`] = investment.questionTitle
|
||||||
templateData[`question${i + 1}Url`] = investment.questionUrl
|
templateData[`question${i + 1}Url`] = investment.questionUrl
|
||||||
templateData[`question${i + 1}Prob`] = investment.questionProb
|
templateData[`question${i + 1}Prob`] = investment.questionProb
|
||||||
templateData[`question${i + 1}Change`] = investment.questionChange
|
templateData[`question${i + 1}Change`] = formatMoney(investment.difference)
|
||||||
templateData[`question${i + 1}ChangeStyle`] = investment.questionChangeStyle
|
templateData[`question${i + 1}ChangeStyle`] = investment.questionChangeStyle
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import { Txn } from '../../common/txn'
|
||||||
import { formatMoney } from '../../common/util/format'
|
import { formatMoney } from '../../common/util/format'
|
||||||
import { getContractBetMetrics } from '../../common/calculate'
|
import { getContractBetMetrics } from '../../common/calculate'
|
||||||
|
|
||||||
// TODO: reset weeklyPortfolioUpdateEmailSent to false for all users at the start of each week
|
|
||||||
export const weeklyPortfolioUpdateEmails = functions
|
export const weeklyPortfolioUpdateEmails = functions
|
||||||
.runWith({ secrets: ['MAILGUN_KEY'], memory: '4GB' })
|
.runWith({ secrets: ['MAILGUN_KEY'], memory: '4GB' })
|
||||||
// every minute on Friday for an hour at 12pm PT (UTC -07:00)
|
// every minute on Friday for an hour at 12pm PT (UTC -07:00)
|
||||||
|
@ -179,6 +178,8 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
|
||||||
const currentMarketProbability = cpmmContract.resolutionProbability
|
const currentMarketProbability = cpmmContract.resolutionProbability
|
||||||
? cpmmContract.resolutionProbability
|
? cpmmContract.resolutionProbability
|
||||||
: cpmmContract.prob
|
: cpmmContract.prob
|
||||||
|
|
||||||
|
// TODO: returns 0 for resolved markets - doesn't include them
|
||||||
const betsMadeAWeekAgoValue = computeInvestmentValueCustomProb(
|
const betsMadeAWeekAgoValue = computeInvestmentValueCustomProb(
|
||||||
previousBets,
|
previousBets,
|
||||||
contract,
|
contract,
|
||||||
|
@ -196,12 +197,13 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
|
||||||
).profit
|
).profit
|
||||||
const marketChange =
|
const marketChange =
|
||||||
currentMarketProbability - marketProbabilityAWeekAgo
|
currentMarketProbability - marketProbabilityAWeekAgo
|
||||||
|
const profit =
|
||||||
|
betsMadeInLastWeekProfit +
|
||||||
|
(currentBetsMadeAWeekAgoValue - betsMadeAWeekAgoValue)
|
||||||
return {
|
return {
|
||||||
currentValue: currentBetsMadeAWeekAgoValue,
|
currentValue: currentBetsMadeAWeekAgoValue,
|
||||||
pastValue: betsMadeAWeekAgoValue,
|
pastValue: betsMadeAWeekAgoValue,
|
||||||
difference:
|
difference: profit,
|
||||||
betsMadeInLastWeekProfit +
|
|
||||||
(currentBetsMadeAWeekAgoValue - betsMadeAWeekAgoValue),
|
|
||||||
contractSlug: contract.slug,
|
contractSlug: contract.slug,
|
||||||
marketProbAWeekAgo: marketProbabilityAWeekAgo,
|
marketProbAWeekAgo: marketProbabilityAWeekAgo,
|
||||||
questionTitle: contract.question,
|
questionTitle: contract.question,
|
||||||
|
@ -214,9 +216,7 @@ export async function sendPortfolioUpdateEmailsToAllUsers() {
|
||||||
Math.round(marketChange * 100) +
|
Math.round(marketChange * 100) +
|
||||||
'%',
|
'%',
|
||||||
questionChangeStyle: `color: ${
|
questionChangeStyle: `color: ${
|
||||||
currentMarketProbability > marketProbabilityAWeekAgo
|
profit > 0 ? 'rgba(0,160,0,1)' : '#a80000'
|
||||||
? 'rgba(0,160,0,1)'
|
|
||||||
: '#a80000'
|
|
||||||
};`,
|
};`,
|
||||||
} as PerContractInvestmentsData
|
} as PerContractInvestmentsData
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user