This commit is contained in:
Kevin Cotugno 2018-06-23 10:32:05 -07:00
parent 4e36400f3e
commit 4a6e7a71bb
2 changed files with 10 additions and 6 deletions

View File

@ -7,10 +7,13 @@ import (
) )
type Aggregation struct { type Aggregation struct {
Id int `json:"id"` Id int `json:"id"`
Interval int `json:"interval"` Interval int `json:"interval"`
Product string `json:"product"` Product string `json:"product"`
Price decimal.Decimal `json:"price"` OpenningPrice decimal.Decimal
Price decimal.Decimal
LowPrice decimal.Decimal
HighPrice decimal.Decimal
BuyVolume decimal.Decimal `json:"buy_volume"` BuyVolume decimal.Decimal `json:"buy_volume"`
SellVolume decimal.Decimal `json:"sell_volume"` SellVolume decimal.Decimal `json:"sell_volume"`
BuyTransactions int `json:"buy_transactions"` BuyTransactions int `json:"buy_transactions"`

View File

@ -17,7 +17,8 @@ const (
`WHERE trade_id = $1 AND product = $2;` `WHERE trade_id = $1 AND product = $2;`
trade_delete = `DELETE FROM trades WHERE id = $1;` trade_delete = `DELETE FROM trades WHERE id = $1;`
trade_in_date_range = `SELECT id, ` + trade_columns + ` FROM ` + 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 ` + trade_first = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` +
`product = $1 ORDER BY trade_id ASC LIMIT $2;` `product = $1 ORDER BY trade_id ASC LIMIT $2;`
trade_last = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` + trade_last = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` +
@ -29,7 +30,7 @@ const (
trade_product = `SELECT DISTINCT product FROM trades;` trade_product = `SELECT DISTINCT product FROM trades;`
trade_after_all = `SELECT id, ` + trade_columns + ` FROM trades WHERE product = $1 ` + trade_after_all = `SELECT id, ` + trade_columns + ` FROM trades WHERE product = $1 ` +
`AND trade_id > $2 ORDER BY trade_id ASC;` `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 { type TradeService struct {