Skip to content

Commit

Permalink
Adjust Wrapper to new implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
fiore authored and saniales committed Oct 30, 2018
1 parent fe52649 commit 55237fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bot_helpers/bot_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func InitExchange(exchangeConfig environment.ExchangeConfig, simulatedMode bool,
exch = exchanges.NewBitfinexWrapper(exchangeConfig.PublicKey, exchangeConfig.SecretKey, depositAddresses)
case "hitbtc":
exch = exchanges.NewHitBtcV2Wrapper(exchangeConfig.PublicKey, exchangeConfig.SecretKey, depositAddresses)
case "kucoin":
exch = exchanges.NewKucoinWrapper(exchangeConfig.PublicKey, exchangeConfig.SecretKey, depositAddresses)
default:
return nil
}
Expand Down
20 changes: 14 additions & 6 deletions exchanges/kucoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,24 @@ import (

// KucoinWrapper wrapsKucoin
type KucoinWrapper struct {
api *kucoin.Kucoin
ws *websocket.WebSocket
websocketOn bool
summaries *SummaryCache
orderbook *OrderbookCache
api *kucoin.Kucoin
ws *websocket.WebSocket
websocketOn bool
summaries *SummaryCache
orderbook *OrderbookCache
depositAddresses map[string]string
}

// NewKucoinWrapper creates a generic wrapper of theKucoin
func NewKucoinWrapper(publicKey string, secretKey string) ExchangeWrapper {
func NewKucoinWrapper(publicKey string, secretKey string, depositAddresses map[string]string) ExchangeWrapper {
ws, _ := websocket.NewWS()
return &KucoinWrapper{
api: kucoin.New(publicKey, secretKey),
ws: ws,
websocketOn: false,
summaries: NewSummaryCache(),
orderbook: NewOrderbookCache(),
depositAddresses: depositAddresses,
}
}

Expand Down Expand Up @@ -214,6 +216,12 @@ func (wrapper *KucoinWrapper) GetBalance(symbol string) (*decimal.Decimal, error
return &ret, nil
}

// GetDepositAddress gets the deposit address for the specified coin on the exchange.
func (wrapper *KucoinWrapper) GetDepositAddress(coinTicker string) (string, bool) {
addr, exists := wrapper.depositAddresses[coinTicker]
return addr, exists
}

// CalculateTradingFees calculates the trading fees for an order on a specified market.
func (wrapper *KucoinWrapper) CalculateTradingFees(market *environment.Market, amount float64, limit float64, orderType TradeType) float64 {
var feePercentage float64
Expand Down

0 comments on commit 55237fc

Please sign in to comment.