Send weekly email
kilimchoi opened this issue · comments
Subject of the email should be something like "Your Portfolio up 0.7% last week" Body of the email should include
Weekly Portfolio Report
#{week} e.g. Sep 10, 2017 — Sep 17, 2017
Your Portfolio Total
#{total} e.g. $8,632
1-Week Return
#{weekly_change} 0.7%
Also need to add a link at the bottom where they can unsubscribe from this weekly email.
Unsubscribe to stop receiving the weekly emails.
Clicking on the link above will take the users to the profile page where they can check and uncheck "Receive weekly email notifications on your portfolio changes." option.
I think for this statistics we can use materialized views - one per interval, e.g. per day, per week, per month, per quarter.
They will group transactions and their USD representations and convert to a single record.
For this purposes we can use https://github.com/thoughtbot/scenic which supports versioned views and materialized views.
case 1: I have bought 1 bitcoin at $5000 last week. This week, I bought 1 bitcoin at $6000. Email should say your value has gone up 140% because it went from $5000 to $12000
case 2: I bought 1 bitcoin at $1000 a year ago but I have not made any new transactions lately. If for the current week, bitcoin’s price is at $6000, and bitcoin’s price for the previous week is at $5000, email should say it went up 20%
case 3: I bought 1 bitcoin at $5000 previous week but bitcoin’s price hasn’t changed and I buy 1 bitcoin at $5000 this week. Email should say your value went up by 100% because your portfolio value increased from $5000 to $10000
Portfolio total should always account for the coin's price at the time when the email is sent out.