change column to net_asset_in_* to avoid confusion

This commit is contained in:
c9s 2022-05-04 19:12:30 +08:00
parent f196cc9ccd
commit 30c9d251fe
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 25 additions and 19 deletions

View File

@ -2,8 +2,8 @@
-- +begin -- +begin
ALTER TABLE `nav_history_details` ALTER TABLE `nav_history_details`
MODIFY COLUMN `net_asset` DECIMAL(32, 8) DEFAULT 0.00000000 NOT NULL, MODIFY COLUMN `net_asset` DECIMAL(32, 8) DEFAULT 0.00000000 NOT NULL,
MODIFY COLUMN `balance_in_usd` DECIMAL(32, 2) DEFAULT 0.00000000 NOT NULL, CHANGE COLUMN `balance_in_usd` `net_asset_in_usd` DECIMAL(32, 2) DEFAULT 0.00000000 NOT NULL,
MODIFY COLUMN `balance_in_btc` DECIMAL(32, 20) DEFAULT 0.00000000 NOT NULL; CHANGE COLUMN `balance_in_btc` `net_asset_in_btc` DECIMAL(32, 20) DEFAULT 0.00000000 NOT NULL;
-- +end -- +end
-- +begin -- +begin

View File

@ -2,16 +2,16 @@
-- +begin -- +begin
CREATE TABLE `nav_history_details` CREATE TABLE `nav_history_details`
( (
gid bigint unsigned auto_increment PRIMARY KEY, `gid` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`exchange` VARCHAR NOT NULL DEFAULT '', `exchange` VARCHAR(30) NOT NULL DEFAULT '',
`subaccount` VARCHAR NOT NULL DEFAULT '', `subaccount` VARCHAR(30) NOT NULL DEFAULT '',
time DATETIME(3) NOT NULL DEFAULT (strftime('%s', 'now')), `time` DATETIME(3) NOT NULL DEFAULT (strftime('%s', 'now')),
currency VARCHAR NOT NULL, `currency` VARCHAR(30) NOT NULL,
balance_in_usd DECIMAL DEFAULT 0.00000000 NOT NULL, `net_asset_in_usd` DECIMAL DEFAULT 0.00000000 NOT NULL,
balance_in_btc DECIMAL DEFAULT 0.00000000 NOT NULL, `net_asset_in_btc` DECIMAL DEFAULT 0.00000000 NOT NULL,
balance DECIMAL DEFAULT 0.00000000 NOT NULL, `balance` DECIMAL DEFAULT 0.00000000 NOT NULL,
available DECIMAL DEFAULT 0.00000000 NOT NULL, `available` DECIMAL DEFAULT 0.00000000 NOT NULL,
locked DECIMAL DEFAULT 0.00000000 NOT NULL `locked` DECIMAL DEFAULT 0.00000000 NOT NULL
); );
-- +end -- +end
-- +begin -- +begin

View File

@ -31,8 +31,8 @@ func (s *AccountService) InsertAsset(time time.Time, session string, name types.
subaccount, subaccount,
time, time,
currency, currency,
balance_in_usd, net_asset_in_usd,
balance_in_btc, net_asset_in_btc,
balance, balance,
available, available,
locked, locked,

View File

@ -11,15 +11,21 @@ import (
) )
type Asset struct { type Asset struct {
Currency string `json:"currency" db:"currency"` Currency string `json:"currency" db:"currency"`
Total fixedpoint.Value `json:"total" db:"total"` Total fixedpoint.Value `json:"total" db:"total"`
InUSD fixedpoint.Value `json:"inUSD" db:"in_usd"`
InBTC fixedpoint.Value `json:"inBTC" db:"in_btc"` NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"`
// InUSD is net asset in USD
InUSD fixedpoint.Value `json:"inUSD" db:"net_asset_in_usd"`
// InBTC is net asset in BTC
InBTC fixedpoint.Value `json:"inBTC" db:"net_asset_in_btc"`
Time time.Time `json:"time" db:"time"` Time time.Time `json:"time" db:"time"`
Locked fixedpoint.Value `json:"lock" db:"lock" ` Locked fixedpoint.Value `json:"lock" db:"lock" `
Available fixedpoint.Value `json:"available" db:"available"` Available fixedpoint.Value `json:"available" db:"available"`
Borrowed fixedpoint.Value `json:"borrowed" db:"borrowed"` Borrowed fixedpoint.Value `json:"borrowed" db:"borrowed"`
NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"`
PriceInUSD fixedpoint.Value `json:"priceInUSD" db:"price_in_usd"` PriceInUSD fixedpoint.Value `json:"priceInUSD" db:"price_in_usd"`
} }