class AccountRepository
Repository for accessing and updating account information.
<init> |
Constructor that allows repository creation from a Context. AccountRepository(context: Context)
Repository for accessing and updating account information. AccountRepository(database: StockAppDatabase) |
balancesLimited |
The latest {BALANCE_LIMIT} account balance values. val balancesLimited: LiveData<List<Balance>> |
currentDepotValue |
The latest depot value. val currentDepotValue: LiveData<DepotValue> |
depot |
All DepotQuotePurchases conflated to DepotQuotes whereby their amount Double is added up and the mean buyingPrice Double is bid from the buyingPrices Double. val depot: LiveData<List<DepotQuote>> |
depotValuesLimited |
The latest {BALANCE_LIMIT} depot values. val depotValuesLimited: LiveData<List<DepotValue>> |
latestBalance |
The latest account balance value. val latestBalance: LiveData<Balance> |
buy |
Buys an asset if possible and stores the related data in the StockAppDatabase. suspend fun buy(quote: Quote, amount: Double): Unit |
calculateBuyCashflow |
Calculates the cashflow of a buy transaction. fun calculateBuyCashflow(quote: Quote?, amount: Double?): Double |
calculateCurrentDepotValue |
Calculates the current value of the depot and inserts a DepotValue into the StockAppDatabase if it has changed. suspend fun calculateCurrentDepotValue(): Unit |
calculateSellCashflow |
Calculates the cashflow of a sell transaction. fun calculateSellCashflow(quote: Quote?, amount: Double?): Double |
depotQuoteBySymbol |
Returns the DepotQuotePurchase with the matching id. fun depotQuoteBySymbol(symbol: String): DepotQuotePurchase? |
depotQuoteWithSymbol |
Returns the DepotQuote with the matching id, wrapped in LiveData. Conflates all DepotQuotePurchases with the matching id and returns them as one DepotQuote, whereby the amount Double is added up and the mean buyingPrice Double is bid from the buyingPrices Double. fun depotQuoteWithSymbol(symbol: String): LiveData<DepotQuote> |
getLatestBalance |
Returns the latest Balance of the StockAppDatabase. suspend fun getLatestBalance(): Balance |
hasBalance |
Checks if the StockAppDatabase has any Balance. suspend fun hasBalance(): Boolean |
resetAccount |
Resets account information by deleting existing data from the StockAppDatabase and inserting default Balances and a DepotValue. suspend fun resetAccount(): Unit |
sell |
Sells an asset if possible and stores the related data in the StockAppDatabase. suspend fun sell(quote: Quote, amount: Double): Unit |