Skip to content

Commit

Permalink
35: watchlist shows OTH values
Browse files Browse the repository at this point in the history
  • Loading branch information
orfins committed Jul 23, 2024
1 parent 9a30358 commit 5378ae5
Show file tree
Hide file tree
Showing 18 changed files with 516 additions and 72 deletions.
296 changes: 296 additions & 0 deletions app/schemas/com.github.premnirmal.ticker.repo.QuotesDB/7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
{
"formatVersion": 1,
"database": {
"version": 6,
"identityHash": "4d82fe2e120504e4e5235767c9ef65fe",
"entities": [
{
"tableName": "QuoteRow",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`symbol` TEXT NOT NULL, `name` TEXT NOT NULL, `last_trade_price` REAL NOT NULL, `change_percent` REAL NOT NULL, `change` REAL NOT NULL, `oth_price` REAL NOT NULL, `oth_change_percent` REAL NOT NULL, `oth_change` REAL NOT NULL, `exchange` TEXT NOT NULL, `currency` TEXT NOT NULL, `is_post_market` INTEGER NOT NULL, `annual_dividend_rate` REAL NOT NULL, `annual_dividend_yield` REAL NOT NULL, `dayHigh` REAL, `dayLow` REAL, `previousClose` REAL NOT NULL, `open` REAL, `regularMarketVolume` REAL, `peRatio` REAL, `fiftyTwoWeekLowChange` REAL, `fiftyTwoWeekLowChangePercent` REAL, `fiftyTwoWeekHighChange` REAL, `fiftyTwoWeekHighChangePercent` REAL, `fiftyTwoWeekLow` REAL, `fiftyTwoWeekHigh` REAL, `dividendDate` REAL, `earningsDate` REAL, `marketCap` REAL, `isTradeable` INTEGER, `isTriggerable` INTEGER, `marketState` TEXT, PRIMARY KEY(`symbol`))",
"fields": [
{
"fieldPath": "symbol",
"columnName": "symbol",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastTradePrice",
"columnName": "last_trade_price",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "changeInPercent",
"columnName": "change_percent",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "change",
"columnName": "change",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "othPrice",
"columnName": "oth_price",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "othChangeInPercent",
"columnName": "oth_change_percent",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "othChange",
"columnName": "oth_change",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "stockExchange",
"columnName": "exchange",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "currency",
"columnName": "currency",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isPostMarket",
"columnName": "is_post_market",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "annualDividendRate",
"columnName": "annual_dividend_rate",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "annualDividendYield",
"columnName": "annual_dividend_yield",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "dayHigh",
"columnName": "dayHigh",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "dayLow",
"columnName": "dayLow",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "previousClose",
"columnName": "previousClose",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "open",
"columnName": "open",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "regularMarketVolume",
"columnName": "regularMarketVolume",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "peRatio",
"columnName": "peRatio",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekLowChange",
"columnName": "fiftyTwoWeekLowChange",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekLowChangePercent",
"columnName": "fiftyTwoWeekLowChangePercent",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekHighChange",
"columnName": "fiftyTwoWeekHighChange",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekHighChangePercent",
"columnName": "fiftyTwoWeekHighChangePercent",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekLow",
"columnName": "fiftyTwoWeekLow",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "fiftyTwoWeekHigh",
"columnName": "fiftyTwoWeekHigh",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "dividendDate",
"columnName": "dividendDate",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "earningsDate",
"columnName": "earningsDate",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "marketCap",
"columnName": "marketCap",
"affinity": "REAL",
"notNull": false
},
{
"fieldPath": "isTradeable",
"columnName": "isTradeable",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "isTriggerable",
"columnName": "isTriggerable",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "marketState",
"columnName": "marketState",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"symbol"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "HoldingRow",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `quote_symbol` TEXT NOT NULL, `shares` REAL NOT NULL, `price` REAL NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "quoteSymbol",
"columnName": "quote_symbol",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "shares",
"columnName": "shares",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "price",
"columnName": "price",
"affinity": "REAL",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "PropertiesRow",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `properties_quote_symbol` TEXT NOT NULL, `notes` TEXT NOT NULL, `alert_above` REAL NOT NULL, `alert_below` REAL NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "quoteSymbol",
"columnName": "properties_quote_symbol",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "alertAbove",
"columnName": "alert_above",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "alertBelow",
"columnName": "alert_below",
"affinity": "REAL",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '4d82fe2e120504e4e5235767c9ef65fe')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
import com.github.premnirmal.ticker.components.AppClock.AppClockImpl
import com.github.premnirmal.ticker.portfolio.PortfolioVH
import com.github.premnirmal.tickerwidget.R
import com.robinhood.ticker.TickerView
import org.threeten.bp.DayOfWeek
Expand Down Expand Up @@ -273,4 +274,4 @@ inline fun <T : ViewBinding> Fragment.viewBinding(
crossinline bindingInflater: (LayoutInflater) -> T) =
lazy(LazyThreadSafetyMode.NONE) {
bindingInflater.invoke(layoutInflater)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.premnirmal.ticker.repo.migrations.MIGRATION_2_3
import com.github.premnirmal.ticker.repo.migrations.MIGRATION_3_4
import com.github.premnirmal.ticker.repo.migrations.MIGRATION_4_5
import com.github.premnirmal.ticker.repo.migrations.MIGRATION_5_6
import com.github.premnirmal.ticker.repo.migrations.MIGRATION_6_7
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -64,6 +65,7 @@ class AppModule {
.addMigrations(MIGRATION_3_4)
.addMigrations(MIGRATION_4_5)
.addMigrations(MIGRATION_5_6)
.addMigrations(MIGRATION_6_7)
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
}

private fun showWhatsNew() {
getString(R.string.error_fetching_whats_new)
val dialog = showDialog(
getString(R.string.whats_new_in, BuildConfig.VERSION_NAME),
getString(R.string.loading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,17 @@ class StocksApi @Inject constructor(
}

private fun YahooQuoteNet.toQuote(): Quote {
val isPreMarket = "PRE" == this.marketState?.uppercase()

val quote = Quote(
symbol = this.symbol,
name = (this.name ?: this.longName).orEmpty(),
lastTradePrice = this.lastTradePrice,
changeInPercent = this.changePercent,
change = this.change
change = this.change,
othPrice = if (isPreMarket) this.preMarketPrice else this.postMarketPrice,
othChangeInPercent = if (isPreMarket) this.preMarketChangePercent else this.postMarketChangePercent,
othChange = if (isPreMarket) this.preMarketChange else this.postMarketChange
)
quote.stockExchange = this.exchange ?: ""
quote.currencyCode = this.currency ?: "USD"
Expand Down
Loading

0 comments on commit 5378ae5

Please sign in to comment.