diff --git a/alphapointhttp.go b/alphapointhttp.go index 13f17a9f..656d2bef 100644 --- a/alphapointhttp.go +++ b/alphapointhttp.go @@ -365,7 +365,7 @@ func (a *Alphapoint) WithdrawCoins(symbol, product string, amount float64, addre request := make(map[string]interface{}) request["ins"] = symbol request["product"] = product - request["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) + request["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) request["sendToAddress"] = address type Response struct { @@ -390,8 +390,8 @@ func (a *Alphapoint) CreateOrder(symbol, side string, orderType int, quantity, p request["ins"] = symbol request["side"] = side request["orderType"] = orderType - request["qty"] = strconv.FormatFloat(quantity, 'f', 8, 64) - request["px"] = strconv.FormatFloat(price, 'f', 2, 64) + request["qty"] = strconv.FormatFloat(quantity, 'f', -1, 64) + request["px"] = strconv.FormatFloat(price, 'f', -1, 64) type Response struct { ServerOrderID int64 `json:"serverOrderId"` diff --git a/bitstamphttp.go b/bitstamphttp.go index f7aa2cf8..e7e19cb6 100644 --- a/bitstamphttp.go +++ b/bitstamphttp.go @@ -220,8 +220,8 @@ func (b *Bitstamp) GetOpenOrders() { func (b *Bitstamp) PlaceOrder(price float64, amount float64, Type int) { var req = url.Values{} - req.Add("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - req.Add("price", strconv.FormatFloat(price, 'f', 2, 64)) + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + req.Add("price", strconv.FormatFloat(price, 'f', -1, 64)) orderType := BITSTAMP_API_BUY if Type == 1 { @@ -247,7 +247,7 @@ func (b *Bitstamp) GetWithdrawalRequests() { func (b *Bitstamp) BitcoinWithdrawal(amount float64, address string) { var req = url.Values{} - req.Add("amount", strconv.FormatFloat(amount, 'f', 8, 64)) + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) req.Add("address", address) err := b.SendAuthenticatedHTTPRequest(BITSTAMP_API_BITCOIN_WITHDRAWAL, req, nil) @@ -275,7 +275,7 @@ func (b *Bitstamp) UnconfirmedBitcoin() { func (b *Bitstamp) RippleWithdrawal(amount float64, address, currency string) { var req = url.Values{} - req.Add("amount", strconv.FormatFloat(amount, 'f', 8, 64)) + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) req.Add("address", address) req.Add("currency", currency) diff --git a/btcchinahttp.go b/btcchinahttp.go index 44fa5844..90bd8835 100644 --- a/btcchinahttp.go +++ b/btcchinahttp.go @@ -313,8 +313,8 @@ func (b *BTCChina) GetAccountInfo(infoType string) { func (b *BTCChina) PlaceOrder(buyOrder bool, price, amount float64, market string) { params := make([]interface{}, 0) - params = append(params, strconv.FormatFloat(price, 'f', 2, 64)) - params = append(params, strconv.FormatFloat(amount, 'f', 8, 64)) + params = append(params, strconv.FormatFloat(price, 'f', -1, 64)) + params = append(params, strconv.FormatFloat(amount, 'f', -1, 64)) if len(market) > 0 { params = append(params, market) @@ -507,10 +507,10 @@ func (b *BTCChina) RequestWithdrawal(currency string, amount float64) { func (b *BTCChina) IcebergOrder(buyOrder bool, price, amount, discAmount, variance float64, market string) { params := make([]interface{}, 0) - params = append(params, strconv.FormatFloat(price, 'f', 2, 64)) - params = append(params, strconv.FormatFloat(amount, 'f', 8, 64)) - params = append(params, strconv.FormatFloat(discAmount, 'f', 2, 64)) - params = append(params, strconv.FormatFloat(variance, 'f', 2, 64)) + params = append(params, strconv.FormatFloat(price, 'f', -1, 64)) + params = append(params, strconv.FormatFloat(amount, 'f', -1, 64)) + params = append(params, strconv.FormatFloat(discAmount, 'f', -1, 64)) + params = append(params, strconv.FormatFloat(variance, 'f', -1, 64)) if len(market) > 0 { params = append(params, market) @@ -587,15 +587,15 @@ func (b *BTCChina) PlaceStopOrder(buyOder bool, stopPrice, price, amount, traili params = append(params, stopPrice) } - params = append(params, strconv.FormatFloat(price, 'f', 2, 64)) - params = append(params, strconv.FormatFloat(amount, 'f', 8, 64)) + params = append(params, strconv.FormatFloat(price, 'f', -1, 64)) + params = append(params, strconv.FormatFloat(amount, 'f', -1, 64)) if trailingAmt > 0 { - params = append(params, strconv.FormatFloat(trailingAmt, 'f', 2, 64)) + params = append(params, strconv.FormatFloat(trailingAmt, 'f', -1, 64)) } if trailingPct > 0 { - params = append(params, strconv.FormatFloat(trailingPct, 'f', 2, 64)) + params = append(params, strconv.FormatFloat(trailingPct, 'f', -1, 64)) } if len(market) > 0 { diff --git a/btcehttp.go b/btcehttp.go index 9c3d32c5..19b9cf1a 100644 --- a/btcehttp.go +++ b/btcehttp.go @@ -222,8 +222,8 @@ func (b *BTCE) Trade(pair, orderType string, amount, price float64) { req := url.Values{} req.Add("pair", pair) req.Add("type", orderType) - req.Add("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - req.Add("rate", strconv.FormatFloat(price, 'f', 2, 64)) + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + req.Add("rate", strconv.FormatFloat(price, 'f', -1, 64)) err := b.SendAuthenticatedHTTPRequest(BTCE_TRADE, req) diff --git a/coinbasehttp.go b/coinbasehttp.go index 96e759b4..2bfdfd38 100644 --- a/coinbasehttp.go +++ b/coinbasehttp.go @@ -463,8 +463,8 @@ func (c *Coinbase) PlaceOrder(clientRef string, price, amount float64, side stri request["client_oid"] = clientRef } - request["price"] = strconv.FormatFloat(price, 'f', 2, 64) - request["size"] = strconv.FormatFloat(amount, 'f', 8, 64) + request["price"] = strconv.FormatFloat(price, 'f', -1, 64) + request["size"] = strconv.FormatFloat(amount, 'f', -1, 64) request["side"] = side request["product_id"] = productID @@ -574,7 +574,7 @@ func (c *Coinbase) GetFills(params url.Values) { func (c *Coinbase) Transfer(transferType string, amount float64, accountID string) { request := make(map[string]interface{}) request["type"] = transferType - request["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) + request["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) request["coinbase_account_id"] = accountID err := c.SendAuthenticatedHTTPRequest("POST", COINBASE_API_URL+COINBASE_TRANSFERS, request, nil) diff --git a/cryptsyhttp.go b/cryptsyhttp.go index 574649fc..953c3022 100644 --- a/cryptsyhttp.go +++ b/cryptsyhttp.go @@ -409,8 +409,8 @@ func (c *Cryptsy) CreateOrder(marketid, orderType string, amount, price float64) req := url.Values{} req.Set("marketid", marketid) req.Set("ordertype", orderType) - req.Set("quantity", strconv.FormatFloat(amount, 'f', 8, 64)) - req.Set("price", strconv.FormatFloat(amount, 'f', 8, 64)) + req.Set("quantity", strconv.FormatFloat(amount, 'f', -1, 64)) + req.Set("price", strconv.FormatFloat(amount, 'f', -1, 64)) err := c.SendAuthenticatedHTTPRequest("POST", CRYPTSY_API_URL+CRYPTSY_ORDER, req) @@ -441,10 +441,10 @@ func (c *Cryptsy) CreateTrigger(marketid int64, orderType string, quantity float req := url.Values{} req.Set("marketid", strconv.FormatInt(marketid, 10)) req.Set("type", orderType) - req.Set("quantity", strconv.FormatFloat(quantity, 'f', 8, 64)) + req.Set("quantity", strconv.FormatFloat(quantity, 'f', -1, 64)) req.Set("comparison", comparison) - req.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) - req.Set("orderprice", strconv.FormatFloat(orderprice, 'f', 8, 64)) + req.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) + req.Set("orderprice", strconv.FormatFloat(orderprice, 'f', -1, 64)) if expires > 0 { req.Set("expires", strconv.FormatInt(expires, 10)) diff --git a/huobihttp.go b/huobihttp.go index 4fcefd54..042f2559 100644 --- a/huobihttp.go +++ b/huobihttp.go @@ -157,8 +157,8 @@ func (h *HUOBI) Trade(orderType string, coinType int, price, amount float64) { orderType = "sell" } values.Set("coin_type", strconv.Itoa(coinType)) - values.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - values.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) + values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + values.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) err := h.SendAuthenticatedRequest(orderType, values) if err != nil { @@ -172,8 +172,8 @@ func (h *HUOBI) MarketTrade(orderType string, coinType int, price, amount float6 orderType = "sell_market" } values.Set("coin_type", strconv.Itoa(coinType)) - values.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - values.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) + values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + values.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) err := h.SendAuthenticatedRequest(orderType, values) if err != nil { @@ -196,8 +196,8 @@ func (h *HUOBI) ModifyOrder(orderType string, coinType, orderID int, price, amou values := url.Values{} values.Set("coin_type", strconv.Itoa(coinType)) values.Set("id", strconv.Itoa(orderID)) - values.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - values.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) + values.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + values.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) err := h.SendAuthenticatedRequest("modify_order", values) if err != nil { diff --git a/itbithttp.go b/itbithttp.go index b3399427..a3f00386 100644 --- a/itbithttp.go +++ b/itbithttp.go @@ -223,8 +223,8 @@ func (i *ItBit) PlaceWalletOrder(walletID, side, orderType, currency string, amo params["side"] = side params["type"] = orderType params["currency"] = currency - params["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) - params["price"] = strconv.FormatFloat(price, 'f', 2, 64) + params["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) + params["price"] = strconv.FormatFloat(price, 'f', -1, 64) params["instrument"] = instrument if clientRef != "" { @@ -287,7 +287,7 @@ func (i *ItBit) WalletTransfer(walletID, sourceWallet, destWallet string, amount params := make(map[string]interface{}) params["sourceWalletId"] = sourceWallet params["destinationWalletId"] = destWallet - params["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) + params["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) params["currencyCode"] = currency err := i.SendAuthenticatedHTTPRequest("POST", path, params) diff --git a/kraken.go b/kraken.go index c7de428c..fef1e055 100644 --- a/kraken.go +++ b/kraken.go @@ -525,11 +525,11 @@ func (k *Kraken) AddOrder(symbol, side, orderType string, price, price2, volume, values.Set("pairs", symbol) values.Set("type", side) values.Set("ordertype", orderType) - values.Set("price", strconv.FormatFloat(price, 'f', 2, 64)) - values.Set("price2", strconv.FormatFloat(price, 'f', 2, 64)) - values.Set("volume", strconv.FormatFloat(volume, 'f', 2, 64)) - values.Set("leverage", strconv.FormatFloat(leverage, 'f', 2, 64)) - values.Set("position", strconv.FormatFloat(position, 'f', 2, 64)) + values.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) + values.Set("price2", strconv.FormatFloat(price, 'f', -1, 64)) + values.Set("volume", strconv.FormatFloat(volume, 'f', -1, 64)) + values.Set("leverage", strconv.FormatFloat(leverage, 'f', -1, 64)) + values.Set("position", strconv.FormatFloat(position, 'f', -1, 64)) result, err := k.SendAuthenticatedHTTPRequest(KRAKEN_ORDER_PLACE, values) diff --git a/lakebtchttp.go b/lakebtchttp.go index ea499a21..31d68774 100644 --- a/lakebtchttp.go +++ b/lakebtchttp.go @@ -160,7 +160,7 @@ func (l *LakeBTC) GetAccountInfo() { } func (l *LakeBTC) Trade(orderType int, amount, price float64, currency string) { - params := strconv.FormatFloat(price, 'f', 8, 64) + "," + strconv.FormatFloat(amount, 'f', 8, 64) + "," + currency + params := strconv.FormatFloat(price, 'f', -1, 64) + "," + strconv.FormatFloat(amount, 'f', -1, 64) + "," + currency err := errors.New("") if orderType == 0 { diff --git a/okcoinhttp.go b/okcoinhttp.go index d5b6c806..3f0868ac 100644 --- a/okcoinhttp.go +++ b/okcoinhttp.go @@ -437,8 +437,8 @@ func (o *OKCoin) GetFuturesPosition(symbol, contractType string) { func (o *OKCoin) Trade(amount, price float64, symbol, orderType string) { v := url.Values{} - v.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - v.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) + v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + v.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) v.Set("symbol", symbol) v.Set("type", orderType) @@ -453,8 +453,8 @@ func (o *OKCoin) FuturesTrade(amount, price float64, matchPrice, leverage int64, v := url.Values{} v.Set("symbol", symbol) v.Set("contract_type", contractType) - v.Set("price", strconv.FormatFloat(price, 'f', 8, 64)) - v.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) + v.Set("price", strconv.FormatFloat(price, 'f', -1, 64)) + v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) v.Set("type", orderType) v.Set("match_price", strconv.FormatInt(matchPrice, 10)) v.Set("lever_rate", strconv.FormatInt(leverage, 10)) @@ -591,10 +591,10 @@ func (o *OKCoin) GetOrderHistory(orderID, pageLength, currentPage int64, orderTy func (o *OKCoin) Withdrawal(symbol string, fee float64, tradePWD, address string, amount float64) { v := url.Values{} v.Set("symbol", symbol) - v.Set("chargefee", strconv.FormatFloat(fee, 'f', 8, 64)) + v.Set("chargefee", strconv.FormatFloat(fee, 'f', -1, 64)) v.Set("trade_pwd", tradePWD) v.Set("withdraw_address", address) - v.Set("withdraw_amount", strconv.FormatFloat(amount, 'f', 8, 64)) + v.Set("withdraw_amount", strconv.FormatFloat(amount, 'f', -1, 64)) err := o.SendAuthenticatedHTTPRequest("withdraw.do", v) @@ -652,8 +652,8 @@ func (o *OKCoin) Borrow(symbol, days string, amount, rate float64) { v := url.Values{} v.Set("symbol", symbol) v.Set("days", days) - v.Set("amount", strconv.FormatFloat(amount, 'f', 8, 64)) - v.Set("rate", strconv.FormatFloat(rate, 'f', 8, 64)) + v.Set("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + v.Set("rate", strconv.FormatFloat(rate, 'f', -1, 64)) err := o.SendAuthenticatedHTTPRequest("borrow_money.do", v) if err != nil { diff --git a/okcoinwebsocket.go b/okcoinwebsocket.go index 52b7143f..2c2aad1f 100644 --- a/okcoinwebsocket.go +++ b/okcoinwebsocket.go @@ -254,8 +254,8 @@ func (o *OKCoin) WebsocketSpotTrade(symbol, orderType string, price, amount floa values := make(map[string]string) values["symbol"] = symbol values["type"] = orderType - values["price"] = strconv.FormatFloat(price, 'f', 8, 64) - values["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) + values["price"] = strconv.FormatFloat(price, 'f', -1, 64) + values["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) channel := "" if o.WebsocketURL == OKCOIN_WEBSOCKET_URL_CHINA { @@ -271,8 +271,8 @@ func (o *OKCoin) WebsocketFuturesTrade(symbol, contractType string, price, amoun values := make(map[string]string) values["symbol"] = symbol values["contract_type"] = contractType - values["price"] = strconv.FormatFloat(price, 'f', 8, 64) - values["amount"] = strconv.FormatFloat(amount, 'f', 8, 64) + values["price"] = strconv.FormatFloat(price, 'f', -1, 64) + values["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) values["type"] = strconv.Itoa(orderType) values["match_price"] = strconv.Itoa(matchPrice) values["lever_rate"] = strconv.Itoa(orderType)