forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trade_aggregation.go
executable file
·33 lines (30 loc) · 974 Bytes
/
trade_aggregation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package resourceadapter
import (
"context"
"github.com/fonero-project/fonero-golang/amount"
"github.com/fonero-project/fonero-golang/price"
"github.com/fonero-project/fonero-golang/services/horizon/internal/db2/history"
. "github.com/fonero-project/fonero-golang/protocols/horizon"
)
// Populate fills out the details of a trade using a row from the history_trades
// table.
func PopulateTradeAggregation(
ctx context.Context,
dest *TradeAggregation,
row history.TradeAggregation,
) (err error) {
dest.Timestamp = row.Timestamp
dest.TradeCount = row.TradeCount
dest.BaseVolume = amount.StringFromInt64(row.BaseVolume)
dest.CounterVolume = amount.StringFromInt64(row.CounterVolume)
dest.Average = price.StringFromFloat64(row.Average)
dest.High = row.High.String()
dest.HighR = row.High
dest.Low = row.Low.String()
dest.LowR = row.Low
dest.Open = row.Open.String()
dest.OpenR = row.Open
dest.Close = row.Close.String()
dest.CloseR = row.Close
return
}