diff --git a/cmd/interval/main.go b/cmd/interval/main.go index b03a4a7..44585c3 100644 --- a/cmd/interval/main.go +++ b/cmd/interval/main.go @@ -1,18 +1,17 @@ package main import ( - "github.com/shopspring/decimal" "encoding/csv" - "log" "fmt" + "github.com/shopspring/decimal" + "log" "os" - "time" "strconv" + "time" "tacitus/postgres" ) - func main() { client := postgres.NewClient() client.Name = "gdax" diff --git a/postgres/trade_service.go b/postgres/trade_service.go index 27b0340..2c003db 100644 --- a/postgres/trade_service.go +++ b/postgres/trade_service.go @@ -8,12 +8,12 @@ import ( const ( trade_columns = `trade_id, product, price, size, buy, sell, timestamp` - trade_insert = `INSERT INTO trades (` + trade_columns + `) VALUES ` + + trade_insert = `INSERT INTO trades (` + trade_columns + `) VALUES ` + `($1, $2, $3, $4, $5, $6, $7) RETURNING id;` - trade_find = `SELECT id, ` + trade_columns + ` FROM trades WHERE id = $1;` + trade_find = `SELECT id, ` + trade_columns + ` FROM trades WHERE id = $1;` trade_find_trade_id = `SELECT id, ` + trade_columns + ` FROM trades ` + `WHERE trade_id = $1 AND product = $2;` - trade_delete = `DELETE FROM trades WHERE id = $1;` + trade_delete = `DELETE FROM trades WHERE id = $1;` trades_in_date_range = `SELECT id, ` + trade_columns + ` FROM ` + `trades WHERE product = $1 AND timestamp >= $2 AND timestamp < $3;` trade_first = `SELECT id, ` + trade_columns + ` FROM trades WHERE ` +