mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
service: insert asset fields
This commit is contained in:
parent
2fba2c335b
commit
d93fd3cc48
|
@ -16,19 +16,29 @@ func NewAccountService(db *sqlx.DB) *AccountService {
|
|||
}
|
||||
|
||||
func (s *AccountService) InsertAsset(time time.Time, name types.ExchangeName, account string, assets types.AssetMap) error {
|
||||
|
||||
if s.DB == nil {
|
||||
//skip db insert when no db connection setting.
|
||||
// skip db insert when no db connection setting.
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
for _, v := range assets {
|
||||
_, _err := s.DB.Exec(`
|
||||
insert into nav_history_details ( exchange, subaccount, time, currency, balance_in_usd, balance_in_btc,
|
||||
balance,available,locked)
|
||||
values (?,?,?,?,?,?,?,?,?);
|
||||
`, name, account, time, v.Currency, v.InUSD, v.InBTC, v.Total, v.Available, v.Locked)
|
||||
INSERT INTO nav_history_details (
|
||||
exchange,
|
||||
subaccount,
|
||||
time,
|
||||
currency,
|
||||
balance_in_usd,
|
||||
balance_in_btc,
|
||||
balance,
|
||||
available,
|
||||
locked,
|
||||
borrowed,
|
||||
net_asset,
|
||||
price_in_usd)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?);
|
||||
`, name, account, time, v.Currency, v.InUSD, v.InBTC, v.Total, v.Available, v.Locked, v.Borrowed, v.NetAsset, v.PriceInUSD)
|
||||
|
||||
err = multierr.Append(err, _err) // successful request
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user