leovinsen / octopush

Financial Education mobile game prototype
0 stars 0 forks source link

Schema for user's mutual funds assets #73

Closed leovinsen closed 4 years ago

leovinsen commented 4 years ago
Table mutual_funds_owned {
   id INTEGER PK AUTOINCREMENT,
   product_id INTEGER FK NOT NULL,
   amount DOUBLE NOT NULL,
   datetime TEXT 
}

Or in sharedprefs

leovinsen commented 4 years ago
Table mutual_funds_history {
   id INTEGER PK AUTOINCREMENT,
   product_id INTEGER FK NOT NULL,
   amount DOUBLE NOT NULL,
   datetime TEXT 
}

sounds more fitting; amount can be positive or negative. To obtain the assets owned in a particular product, simply find by product id and calculate the amount.

leovinsen commented 4 years ago
Table mutual_funds_history {
   id INTEGER PK AUTOINCREMENT,
   product_id INTEGER FK NOT NULL,
   amount DOUBLE NOT NULL,
   datetime TEXT,
   purchase_interval INT
}

ditambah interval untuk hitung interest

Interestnya cukup dibikin flat naik turun (misalnya +5% then -2.5%)

tombol sell dimatiin, tombol buy dinyalain, di bagian atas dikasi bagian "My Mutual Funds" yang berisi portfolio user, compounding interest

leovinsen commented 4 years ago

To calculate total assets, do a COUNT(amount), and each record will serve as a history, interest will be calculated as total of all records * interest