Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteOrder(tx *sql.Tx, userID, orderID int64, reason string) error
- func FetchOrderRelation(d QueryExecutor, order *Order) error
- func GetSetting(d QueryExecutor, k string) (string, error)
- func HasTradeChanceByOrder(d QueryExecutor, orderID int64) (bool, error)
- func InitBenchmark(d QueryExecutor) error
- func Isubank(d QueryExecutor) (*isubank.Isubank, error)
- func Logger(d QueryExecutor) (*isulogger.Isulogger, error)
- func RunTrade(db *sql.DB) error
- func SetSetting(d QueryExecutor, k, v string) error
- func UserSignup(tx *sql.Tx, name, bankID, password string) error
- type CandlestickData
- type Order
- func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error)
- func GetHighestBuyOrder(d QueryExecutor) (*Order, error)
- func GetLowestSellOrder(d QueryExecutor) (*Order, error)
- func GetOrderByID(d QueryExecutor, id int64) (*Order, error)
- func GetOrdersByUserIDAndLastTradeIdWithRelation(d QueryExecutor, userID int64, tradeID int64) ([]*Order, error)
- func GetOrdersByUserIDWithRelation(d QueryExecutor, userID int64) ([]*Order, error)
- type QueryExecutor
- type Setting
- type Trade
- type User
Constants ¶
View Source
const ( OrderTypeBuy = "buy" OrderTypeSell = "sell" )
View Source
const ( BankEndpoint = "bank_endpoint" BankAppid = "bank_appid" LogEndpoint = "log_endpoint" LogAppid = "log_appid" )
Variables ¶
View Source
var ( ErrBankUserNotFound = errors.New("bank user not found") ErrBankUserConflict = errors.New("bank user conflict") ErrUserNotFound = errors.New("user not found") ErrOrderNotFound = errors.New("order not found") ErrOrderAlreadyClosed = errors.New("order is already closed") ErrCreditInsufficient = errors.New("銀行の残高が足りません") ErrParameterInvalid = errors.New("parameter invalid") ErrNoOrderForTrade = errors.New("no order for trade") )
Functions ¶
func FetchOrderRelation ¶
func FetchOrderRelation(d QueryExecutor, order *Order) error
func GetSetting ¶
func GetSetting(d QueryExecutor, k string) (string, error)
func HasTradeChanceByOrder ¶
func HasTradeChanceByOrder(d QueryExecutor, orderID int64) (bool, error)
func InitBenchmark ¶
func InitBenchmark(d QueryExecutor) error
func SetSetting ¶
func SetSetting(d QueryExecutor, k, v string) error
Types ¶
type CandlestickData ¶
type CandlestickData struct { Time time.Time `json:"time"` Open int64 `json:"open"` Close int64 `json:"close"` High int64 `json:"high"` Low int64 `json:"low"` }
func GetCandlestickData ¶
func GetCandlestickData(d QueryExecutor, mt time.Time, tf string) ([]*CandlestickData, error)
type Order ¶
type Order struct { ID int64 `json:"id"` Type string `json:"type"` UserID int64 `json:"user_id"` Amount int64 `json:"amount"` Price int64 `json:"price"` ClosedAt *time.Time `json:"closed_at"` TradeID int64 `json:"trade_id,omitempty"` CreatedAt time.Time `json:"created_at"` User *User `json:"user,omitempty"` Trade *Trade `json:"trade,omitempty"` }
func GetHighestBuyOrder ¶
func GetHighestBuyOrder(d QueryExecutor) (*Order, error)
func GetLowestSellOrder ¶
func GetLowestSellOrder(d QueryExecutor) (*Order, error)
func GetOrderByID ¶
func GetOrderByID(d QueryExecutor, id int64) (*Order, error)
func GetOrdersByUserIDAndLastTradeIdWithRelation ¶
func GetOrdersByUserIDAndLastTradeIdWithRelation(d QueryExecutor, userID int64, tradeID int64) ([]*Order, error)
func GetOrdersByUserIDWithRelation ¶
func GetOrdersByUserIDWithRelation(d QueryExecutor, userID int64) ([]*Order, error)
type QueryExecutor ¶
type Trade ¶
type Trade struct { ID int64 `json:"id"` Amount int64 `json:"amount"` Price int64 `json:"price"` CreatedAt time.Time `json:"created_at"` }
func GetLatestTrade ¶
func GetLatestTrade(d QueryExecutor) (*Trade, error)
func GetTradeByID ¶
func GetTradeByID(d QueryExecutor, id int64) (*Trade, error)
Click to show internal directories.
Click to hide internal directories.