app / de.uniks.codliners.stock_simulator.ui.quote / QuoteViewModel

QuoteViewModel

class QuoteViewModel : AndroidViewModel

ViewModel for displaying Quote information.

Parameters

application - The context used for creating repositories.

Types

Factory

Factory for the QuoteViewModel.

class Factory : Factory

Constructors

<init>

Refreshes QuoteRepository data and init the timer.

QuoteViewModel(application: Application, id: String, type: Type)

Properties

amount

The amount in the depot of the current quote.

val amount: LiveData<String>

autoBuyAmount

The default buy amount used for StockbrotQuote.

val autoBuyAmount: MutableLiveData<String>

buyAction

Gets triggered if a buy transaction has been requested.

val buyAction: LiveData<Boolean>

buyAmount

The buy amount used for buy transactions.

val buyAmount: MutableLiveData<String>

canAddRemoveQuoteToStockbrot

Indicates if the stockbrotQuote can be added or removed.

val canAddRemoveQuoteToStockbrot: LiveData<Boolean>

canBuy

Indicates if the Quote can be bought.

val canBuy: LiveData<Boolean>

canSell

Indicates if the DepotQuote can be sold.

val canSell: LiveData<Boolean>

canSellAll

Indicates if all DepotQuotes can be sold.

val canSellAll: LiveData<Boolean>

cashflow

The cashflow of the current transaction request.

val cashflow: LiveData<Double>

clickNewsStatus

Button click indicator for reset button.

val clickNewsStatus: MutableLiveData<Boolean?>

depotQuote

The DepotQuote.

val depotQuote: LiveData<DepotQuote>

errorAction

Gets triggered if an error has been occurred.

val errorAction: LiveData<Exception>

historicalPrices

The historical prices for the Quote.

val historicalPrices: LiveData<List<HistoricalPrice>>

inputType

The input type Int or Double depending on the Symbol.Type.

val inputType: Int

isCrypto

Indicates if the type is a crypto currency or not.

val isCrypto: Boolean

quote

The Quote.

val quote: LiveData<Quote>

refreshing

Indicates that the quote repository is currently being refreshed.

val refreshing: LiveData<Boolean>

sellAction

Gets triggered if a sell transaction has been requested.

val sellAction: LiveData<Boolean>

sellAllAction

Gets triggered if a sell of all quotes has been requested.

val sellAllAction: LiveData<Boolean>

sellAmount

The sell amount used for sell transactions.

val sellAmount: MutableLiveData<String>

stockbrotQuote

The StockbrotQuote of the Quote.

val stockbrotQuote: LiveData<StockbrotQuote>

stockbrotQuoteAction

Gets triggered if the stockbrotQuote has been changed.

val stockbrotQuoteAction: LiveData<StockbrotQuote>

thresholdBuy

The buy threshold used for StockbrotQuote.

val thresholdBuy: MutableLiveData<String!>

thresholdSell

The sell threshold used for StockbrotQuote.

val thresholdSell: MutableLiveData<String!>

transactionCosts

The transaction costs used for each transaction.

val transactionCosts: Double

Functions

addRemoveQuoteToStockbrot

Decides depending on the stockbrotQuote value if a quote can be added to or removed from the stockbrot.

fun addRemoveQuoteToStockbrot(): Unit

buy

Buys the current quote using the specified amount.

fun buy(): Unit

confirmBuy

Set the buy confirm indicator.

fun confirmBuy(): Unit

confirmSell

Set the sell confirm indicator.

fun confirmSell(): Unit

confirmSellAll

Set the sell all confirm indicator.

fun confirmSellAll(): Unit

onBuyActionCompleted

Resets the buy indicator.

fun onBuyActionCompleted(): Unit

onBuyActionStarted

Sets the buy amount and calculates the buy cashflow for displaying this values in the confirmation dialog.

fun onBuyActionStarted(): Unit

onCleared

Cancels the timer if the ViewModel is no longer used and will be destroyed.

fun onCleared(): Unit

onErrorActionCompleted

Resets the error indicator.

fun onErrorActionCompleted(): Unit

onSellActionCompleted

Resets the sell indicator.

fun onSellActionCompleted(): Unit

onSellActionStarted

Sets the sell amount and calculates the sell cashflow for displaying this values in the confirmation dialog.

fun onSellActionStarted(): Unit

onSellAllActionCompleted

Resets the sell all indicator.

fun onSellAllActionCompleted(): Unit

onSellAllActionStarted

Sets the sell amount and calculates the sell all cashflow for displaying this values in the confirmation dialog.

fun onSellAllActionStarted(): Unit

onThresholdBuyActionCompleted

Resets the threshold buy indicator.

fun onThresholdBuyActionCompleted(): Unit

refresh

Refreshes QuoteRepository data for all Symbol.Types.

fun refresh(): Unit

sell

Sells the current quote using the specified amount.

fun sell(): Unit

sellAll

Sells all depot quotes that matched the current quote.

fun sellAll(): Unit

showNews

Sets the flag that indicates that news are to be shown.

fun showNews(): Unit