Files
sendico/api/fx/storage/model/rate.go
Stephan D 62a6631b9a
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
service backend
2025-11-07 18:35:26 +01:00

35 lines
1.2 KiB
Go

package model
import (
"time"
"github.com/tech/sendico/pkg/db/storable"
)
// RateSnapshot stores a normalized FX rate observation.
type RateSnapshot struct {
storable.Base `bson:",inline" json:",inline"`
RateRef string `bson:"rateRef" json:"rateRef"`
Pair CurrencyPair `bson:"pair" json:"pair"`
Provider string `bson:"provider" json:"provider"`
Mid string `bson:"mid,omitempty" json:"mid,omitempty"`
Bid string `bson:"bid,omitempty" json:"bid,omitempty"`
Ask string `bson:"ask,omitempty" json:"ask,omitempty"`
SpreadBps string `bson:"spreadBps,omitempty" json:"spreadBps,omitempty"`
AsOfUnixMs int64 `bson:"asOfUnixMs" json:"asOfUnixMs"`
AsOf *time.Time `bson:"asOf,omitempty" json:"asOf,omitempty"`
Source string `bson:"source,omitempty" json:"source,omitempty"`
ProviderRef string `bson:"providerRef,omitempty" json:"providerRef,omitempty"`
}
// Collection implements storable.Storable.
func (*RateSnapshot) Collection() string {
return RatesCollection
}
// AsOfTime converts the stored millisecond timestamp to time.Time.
func (r *RateSnapshot) AsOfTime() time.Time {
return time.UnixMilli(r.AsOfUnixMs)
}