This repository has been archived on 2022-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
tacitus/postgres/trade_result.go
Kevin Cotugno f4fa7f24b3 watcher: inital validator
This begin this code for the validator. Currently this just build an
array of the starting and ending missing trades.

TODO: Download the missing trades
2017-09-27 23:23:34 -07:00

56 lines
808 B
Go

package postgres
import (
"github.com/kcotugno/tacitus"
"database/sql"
"errors"
)
type TradeResults struct {
rows *sql.Rows
trade tacitus.Trade
err error
}
func (r *TradeResults) Next() bool {
var t tacitus.Trade
var done bool
if r.rows == nil {
r.err = errors.New("No query results")
return false
}
if r.rows.Next() {
r.err = r.rows.Scan(&t.Id, &t.TradeId, &t.Product, &t.Price, &t.Size,
&t.Buy, &t.Sell, &t.Timestamp)
r.trade = t
} else {
done = true
r.err = r.rows.Err()
}
if r.err == nil && !done {
return true
} else {
return false
}
}
func (r *TradeResults) Value() interface{} {
return r.trade
}
func (r *TradeResults) Error() error {
return r.err
}
func (r *TradeResults) Close() error {
if r.rows != nil {
return r.rows.Close()
}
return nil
}