implemented persistence
This commit is contained in:
+18
-2
@@ -22,10 +22,26 @@ func NewFiller(r Record) *Filler {
|
||||
}
|
||||
}
|
||||
|
||||
// NewFillerFromState constructs a Filler from a previously persisted state.
|
||||
// It bypasses the Record-derived defaults so callers can restore a lot that
|
||||
// may have been split-adjusted or partially filled since the Record was first
|
||||
// created.
|
||||
func NewFillerFromState(record Record, quantity, price, filled decimal.Decimal) *Filler {
|
||||
return &Filler{
|
||||
Record: record,
|
||||
filled: filled,
|
||||
quantity: quantity,
|
||||
price: price,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Filler) Quantity() decimal.Decimal { return f.quantity }
|
||||
|
||||
func (f *Filler) Price() decimal.Decimal { return f.price }
|
||||
|
||||
// Filled returns how much of the Filler's quantity has already been consumed.
|
||||
func (f *Filler) Filled() decimal.Decimal { return f.filled }
|
||||
|
||||
// Fill accrues some quantity. Returns how mutch was accrued in the 1st return value and whether
|
||||
// it was filled or not on the 2nd return value.
|
||||
func (f *Filler) Fill(quantity decimal.Decimal) (decimal.Decimal, bool) {
|
||||
@@ -70,8 +86,8 @@ func (fq *FillerQueue) Push(f *Filler) {
|
||||
fq.l.PushBack(f)
|
||||
}
|
||||
|
||||
// Pop removes and returns the first Filler of the queue in the 1st return value. If the list is
|
||||
// empty returns false on the 2nd return value, true otherwise.
|
||||
// Pop removes and returns the first Filler of the queue in the 1st return value if there is one. If
|
||||
// the queue is already empty returns false on the 2nd return value, otherwise returns true.
|
||||
func (fq *FillerQueue) Pop() (*Filler, bool) {
|
||||
el := fq.frontElement()
|
||||
if el == nil {
|
||||
|
||||
Reference in New Issue
Block a user