forked from bnb-chain/go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add pending match flag * support mini token feature Co-authored-by: George <[email protected]>
- Loading branch information
1 parent
7100346
commit 47d4101
Showing
34 changed files
with
1,018 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniClosedOrders returns array of mini closed orders | ||
func (c *client) GetMiniClosedOrders(query *types.ClosedOrdersQuery) (*types.CloseOrders, error) { | ||
err := query.Check() | ||
if err != nil { | ||
return nil, err | ||
} | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, _, err := c.baseClient.Get("/mini/orders/closed", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var orders types.CloseOrders | ||
if err := json.Unmarshal(resp, &orders); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &orders, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniKlines returns mini token klines | ||
func (c *client) GetMiniKlines(query *types.KlineQuery) ([]types.Kline, error) { | ||
err := query.Check() | ||
if err != nil { | ||
return nil, err | ||
} | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp, _, err := c.baseClient.Get("/mini/klines", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
iklines := [][]interface{}{} | ||
if err := json.Unmarshal(resp, &iklines); err != nil { | ||
return nil, err | ||
} | ||
klines := make([]types.Kline, len(iklines)) | ||
// Todo | ||
for index, ikline := range iklines { | ||
kl := types.Kline{} | ||
imap := make(map[string]interface{}, 9) | ||
if len(ikline) >= 9 { | ||
imap["openTime"] = ikline[0] | ||
imap["open"] = ikline[1] | ||
imap["high"] = ikline[2] | ||
imap["low"] = ikline[3] | ||
imap["close"] = ikline[4] | ||
imap["volume"] = ikline[5] | ||
imap["closeTime"] = ikline[6] | ||
imap["quoteAssetVolume"] = ikline[7] | ||
imap["NumberOfTrades"] = ikline[8] | ||
} else { | ||
return nil, fmt.Errorf("Receive kline scheme is unexpected ") | ||
} | ||
bz, err := json.Marshal(imap) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = json.Unmarshal(bz, &kl) | ||
if err != nil { | ||
return nil, err | ||
} | ||
klines[index] = kl | ||
} | ||
return klines, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniMarkets returns list of trading pairs | ||
func (c *client) GetMiniMarkets(query *types.MarketsQuery) ([]types.TradingPair, error) { | ||
err := query.Check() | ||
if err != nil { | ||
return nil, err | ||
} | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, _, err := c.baseClient.Get("/mini/markets", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var listOfPairs []types.TradingPair | ||
if err := json.Unmarshal(resp, &listOfPairs); err != nil { | ||
return nil, err | ||
} | ||
|
||
return listOfPairs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniOrder returns transaction details | ||
func (c *client) GetMiniOrder(orderID string) (*types.Order, error) { | ||
if orderID == "" { | ||
return nil, types.OrderIdMissingError | ||
} | ||
|
||
qp := map[string]string{} | ||
resp, _, err := c.baseClient.Get("/mini/orders/"+orderID, qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var order types.Order | ||
if err := json.Unmarshal(resp, &order); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &order, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniOpenOrders returns array of mini open orders | ||
func (c *client) GetMiniOpenOrders(query *types.OpenOrdersQuery) (*types.OpenOrders, error) { | ||
err := query.Check() | ||
if err != nil { | ||
return nil, err | ||
} | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp, _, err := c.baseClient.Get("/mini/orders/open", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var openOrders types.OpenOrders | ||
if err := json.Unmarshal(resp, &openOrders); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &openOrders, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
) | ||
|
||
// GetMiniTicker24h returns mini token ticker 24h | ||
func (c *client) GetMiniTicker24h(query *types.Ticker24hQuery) ([]types.Ticker24h, error) { | ||
qp, err := common.QueryParamToMap(query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp, _, err := c.baseClient.Get("/mini/ticker/24hr", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tickers := []types.Ticker24h{} | ||
if err := json.Unmarshal(resp, &tickers); err != nil { | ||
return nil, err | ||
} | ||
|
||
return tickers, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniTokens returns list of mini tokens | ||
func (c *client) GetMiniTokens(query *types.TokensQuery) ([]types.MiniToken, error) { | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
resp, _, err := c.baseClient.Get("/mini/tokens", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var tokens []types.MiniToken | ||
if err := json.Unmarshal(resp, &tokens); err != nil { | ||
return nil, err | ||
} | ||
|
||
return tokens, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package query | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/binance-chain/go-sdk/common" | ||
"github.com/binance-chain/go-sdk/common/types" | ||
) | ||
|
||
// GetMiniTrades returns trade details | ||
func (c *client) GetMiniTrades(query *types.TradesQuery) (*types.Trades, error) { | ||
err := query.Check() | ||
if err != nil { | ||
return nil, err | ||
} | ||
qp, err := common.QueryParamToMap(*query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp, _, err := c.baseClient.Get("/mini/trades", qp) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var trades types.Trades | ||
if err := json.Unmarshal(resp, &trades); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &trades, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.