{{define "wrapper"}} package {{.Name}} import ( "errors" "log" "sync" "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" exchange "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" "github.com/thrasher-/gocryptotrader/exchanges/ticker" ) // Start starts the {{.CapitalName}} go routine func ({{.Variable}} *{{.CapitalName}}) Start(wg *sync.WaitGroup) { wg.Add(1) go func() { {{.Variable}}.Run() wg.Done() }() } // Run implements the {{.CapitalName}} wrapper func ({{.Variable}} *{{.CapitalName}}) Run() { if {{.Variable}}.Verbose { log.Printf("%s Websocket: %s. (url: %s).\n", {{.Variable}}.GetName(), common.IsEnabled({{.Variable}}.Websocket), {{.Variable}}.WebsocketURL) log.Printf("%s polling delay: %ds.\n", {{.Variable}}.GetName(), {{.Variable}}.RESTPollingDelay) log.Printf("%s %d currencies enabled: %s.\n", {{.Variable}}.GetName(), len({{.Variable}}.EnabledPairs), {{.Variable}}.EnabledPairs) } } // UpdateTicker updates and returns the ticker for a currency pair func ({{.Variable}} *{{.CapitalName}}) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error) { var tickerPrice ticker.Price // NOTE EXAMPLE FOR GETTING TICKER PRICE //tick, err := {{.Variable}}.GetTickers() //if err != nil { // return tickerPrice, err //} //for _, x := range {{.Variable}}.GetEnabledCurrencies() { //curr := exchange.FormatExchangeCurrency({{.Variable}}.Name, x) //for y := range tick { // if tick[y].Symbol == curr.String() { // tickerPrice.Pair = x // tickerPrice.Ask = tick[y].AskPrice // tickerPrice.Bid = tick[y].BidPrice // tickerPrice.High = tick[y].HighPrice // tickerPrice.Last = tick[y].LastPrice // tickerPrice.Low = tick[y].LowPrice // tickerPrice.Volume = tick[y].Volume // ticker.ProcessTicker({{.Variable}}.Name, x, tickerPrice, assetType) // } // } //} //return ticker.GetTicker({{.Variable}}.Name, p, assetType) return tickerPrice, nil // NOTE DO NOT USE AS RETURN } // GetTickerPrice returns the ticker for a currency pair func ({{.Variable}} *{{.CapitalName}}) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error) { tickerNew, err := ticker.GetTicker({{.Variable}}.GetName(), p, assetType) if err != nil { return {{.Variable}}.UpdateTicker(p, assetType) } return tickerNew, nil } // GetOrderbookEx returns orderbook base on the currency pair func ({{.Variable}} *{{.CapitalName}}) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error) { ob, err := orderbook.GetOrderbook({{.Variable}}.GetName(), currency, assetType) if err != nil { return {{.Variable}}.UpdateOrderbook(currency, assetType) } return ob, nil } // UpdateOrderbook updates and returns the orderbook for a currency pair func ({{.Variable}} *{{.CapitalName}}) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error) { var orderBook orderbook.Base //NOTE UPDATE ORDERBOOK EXAMPLE //orderbookNew, err := {{.Variable}}.GetOrderBook(exchange.FormatExchangeCurrency({{.Variable}}.Name, p).String(), 1000) //if err != nil { // return orderBook, err //} //for _, bids := range orderbookNew.Bids { // orderBook.Bids = append(orderBook.Bids, orderbook.Item{Amount: bids.Quantity, Price: bids.Price}) //} //for _, asks := range orderbookNew.Asks { // orderBook.Asks = append(orderBook.Asks, orderbook.Item{Amount: asks.Quantity, Price: asks.Price}) //} //orderbook.ProcessOrderbook(b.GetName(), p, orderBook, assetType) //return orderbook.GetOrderbook({{.Variable}}.Name, p, assetType) return orderBook, nil // NOTE DO NOT USE AS RETURN } // GetExchangeAccountInfo retrieves balances for all enabled currencies for the // {{.CapitalName}} exchange func ({{.Variable}} *{{.CapitalName}}) GetExchangeAccountInfo() (exchange.AccountInfo, error) { var response exchange.AccountInfo return response, errors.New("not implemented") } // GetExchangeFundTransferHistory returns funding history, deposits and // withdrawals func ({{.Variable}} *{{.CapitalName}}) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error) { var fundHistory []exchange.FundHistory return fundHistory, errors.New("not supported on exchange") } // GetExchangeHistory returns historic trade data since exchange opening. func ({{.Variable}} *{{.CapitalName}}) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error) { var resp []exchange.TradeHistory return resp, errors.New("trade history not yet implemented") } // SubmitExchangeOrder submits a new order func ({{.Variable}} *{{.CapitalName}}) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error) { return 0, errors.New("not yet implemented") } // ModifyExchangeOrder will allow of changing orderbook placement and limit to // market conversion func ({{.Variable}} *{{.CapitalName}}) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error) { return 0, errors.New("not yet implemented") } // CancelExchangeOrder cancels an order by its corresponding ID number func ({{.Variable}} *{{.CapitalName}}) CancelExchangeOrder(orderID int64) error { return errors.New("not yet implemented") } // CancelAllExchangeOrders cancels all orders associated with a currency pair func ({{.Variable}} *{{.CapitalName}}) CancelAllExchangeOrders() error { return errors.New("not yet implemented") } // GetExchangeOrderInfo returns information on a current open order func ({{.Variable}} *{{.CapitalName}}) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error) { var orderDetail exchange.OrderDetail return orderDetail, errors.New("not yet implemented") } // GetExchangeDepositAddress returns a deposit address for a specified currency func ({{.Variable}} *{{.CapitalName}}) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error) { return "", errors.New("not yet implemented") } // WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is // submitted func ({{.Variable}} *{{.CapitalName}}) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error) { return "", errors.New("not yet implemented") } // WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is // submitted func ({{.Variable}} *{{.CapitalName}}) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error) { return "", errors.New("not yet implemented") } // WithdrawExchangeFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted func ({{.Variable}} *{{.CapitalName}}) WithdrawExchangeFiatFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error) { return "", errors.New("not yet implemented") } {{end}}