diff --git a/aggregation.go b/aggregation.go index 3df93e5..f634e8f 100644 --- a/aggregation.go +++ b/aggregation.go @@ -7,10 +7,13 @@ import ( ) type Aggregation struct { - Id int `json:"id"` - Interval int `json:"interval"` - Product string `json:"product"` - Price decimal.Decimal `json:"price"` + Id int `json:"id"` + Interval int `json:"interval"` + Product string `json:"product"` + OpenningPrice decimal.Decimal + Price decimal.Decimal + LowPrice decimal.Decimal + HighPrice decimal.Decimal BuyVolume decimal.Decimal `json:"buy_volume"` SellVolume decimal.Decimal `json:"sell_volume"` BuyTransactions int `json:"buy_transactions"` diff --git a/postgres/trade_service.go b/postgres/trade_service.go index 4081201..03c0817 100644 --- a/postgres/trade_service.go +++ b/postgres/trade_service.go @@ -17,7 +17,8 @@ const ( `WHERE trade_id = $1 AND product = $2;` trade_delete = `DELETE FROM trades WHERE id = $1;` trade_in_date_range = `SELECT id, ` + trade_columns + ` FROM ` + - `trades WHERE product = $1 AND timestamp >= $2 AND timestamp < $3;` + `trades WHERE product = $1 AND timestamp >= $2 AND timestamp < $3 ` + + `ORDER BY timestamp ASC;` trade_first = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` + `product = $1 ORDER BY trade_id ASC LIMIT $2;` trade_last = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` + @@ -29,7 +30,7 @@ const ( trade_product = `SELECT DISTINCT product FROM trades;` trade_after_all = `SELECT id, ` + trade_columns + ` FROM trades WHERE product = $1 ` + `AND trade_id > $2 ORDER BY trade_id ASC;` - trade_where = `SELECT id, ` + trade_columns + ` FROM trades WHERE` + trade_where = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` ) type TradeService struct {