Categorygithub.com/PythonohtyP1900/DCEAPI
modulepackage
0.0.0-20210702075353-209235b0ec8b
Repository: https://github.com/pythonohtyp1900/dceapi.git
Documentation: pkg.go.dev

# README

主流数字货币交易所Golang通用SDK

支持交易所:BINANCE HUOBIPRO AOFEX 切换交易所毋需更改任何代码

安装

go get github.com/PythonohtyP1900/DCEAPI

代码实例

package main

import (
	"github.com/PythonohtyP1900/DCEAPI/exchanges"
	"github.com/PythonohtyP1900/DCEAPI"
	"github.com/shopspring/decimal"

	"fmt"
)

func initExchange(exchangeName string) (DCEAPI.SpotAPI) {
	var apiKey string
	var secret string
	switch exchangeName {
	case "aofex":
		apiKey = ""
		secret = ""
	case "huobipro":
		apiKey = ""
		secret = ""
	}
	api := exchanges.NewExchange(exchangeName, apiKey, secret)
	return api
}

func main() {
	api := initExchange("huobipro")
	balance, err := api.FetchBalance()
	var Free decimal.Decimal
	var Frozen decimal.Decimal
	for _, v := range balance {
		if v.Currency == "USDT" {
			Free = v.Free
			Frozen = v.Frozen
		}
	}
	fmt.Println(Free, Frozen, err)

	trade, err := api.FetchTrades("BTC/USDT", "2")
	fmt.Println(trade, err)

	markets, err := api.FetchMarkets()
	fmt.Println(markets, err)

	orderBook, err := api.FetchOrderBook("BTC/USDT", map[string]string{"type":"step0"})
	fmt.Println(orderBook, err)

	kline, err := api.FetchOHLCV("BTC/USDT", "1min", "200")
	fmt.Println(kline, err)

	kline24H, err := api.FetchOHLCV24H("BTC/USDT")
	fmt.Println(kline24H, err)

	order, err := api.LimitBuyOrder("TRX/USDT", "100", "0.07")
	fmt.Println(order, err)

	orderInfo, err := api.FetchOrder("280985812605956")
	fmt.Println(orderInfo, err)

	err = api.CancelOrder(order.OrderID)
	fmt.Println(err)

	openOrders, err := api.FetchClosedOrders("TRX/USDT")
	fmt.Println(openOrders, err)

	success, failed, err := api.BatchCancelOrder("test_orderid1", "test_orderid2")
	fmt.Println(success, failed, err)

}

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
封装基础请求, url已经通过参数builder.

# Structs

余额结构体.
No description provided by the author
No description provided by the author
http状态码!=200时候抛出.
k线结构体.
市场结构体.
订单结构体.
orderbook.
交易对结构.
市场成交结构体.
No description provided by the author

# Interfaces

现货接口.
No description provided by the author

# Type aliases

余额不足.
交易所错误.
认证错误.
下单精度,最大最小量错误.
未知订单.
状态错误.
交易对错误.