goex

module
v2.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: MIT

README

Introduction

  • Unified and standardize the interfaces of various cryptocurrency trading platforms.

goex

Donate

  • [BTC] 1GoEXwVvXG7kNdQSFaUNF35A3izHojLGxP
  • [USDT-TRC20] TGoExC6xvzE4wSA9cYZnwcPaXEjibA5Vtc

Example

package main

import (
	goexv2 "github.com/opcache/goex/v2"
	"github.com/opcache/goex/v2/logger"
	"github.com/opcache/goex/v2/model"
	"github.com/opcache/goex/v2/options"
	"log"
)

func main() {
	logger.SetLevel(logger.DEBUG)                             //设置日志输出级别
	//goexv2.DefaultHttpCli.SetProxy("socks5://127.0.0.1:1080") //socks代理
	goexv2.DefaultHttpCli.SetTimeout(5)                       // 5 second

	_, _, err := goexv2.OKx.Spot.GetExchangeInfo() //建议调用
	if err != nil {
		panic(err)
	}
	btcUSDTCurrencyPair, err := goexv2.OKx.Spot.NewCurrencyPair(model.BTC, model.USDT)//建议这样构建CurrencyPair
	if err != nil {
		panic(err)
	}
		
	//共有api调用
	log.Println(goexv2.OKx.Spot.GetTicker(btcUSDTCurrencyPair))

	//私有API调用
	okxPrvApi := goexv2.OKx.Spot.NewPrvApi(
		options.WithApiKey(""), 
		options.WithApiSecretKey(""), 
		options.WithPassphrase(""))
	
	//创建订单
	order, _, err := okxPrvApi.CreateOrder(btcUSDTCurrencyPair, 0.01, 18000, model.Spot_Buy, model.OrderType_Limit)
	log.Println(err)
	log.Println(order)
}

Filled The OrderClientID

ord, resp, err := okxPrvApi.CreateOrder(btcUSDTCurrencyPair, 0.01, 23000,
		model.Spot_Buy, model.OrderType_Limit,
		model.OptionParameter{}.OrderClientID("goex123027892")) //client id: goex123027892

Thanks

JetBrains

Directories

Path Synopsis
* @Author: xxxxx@xx.com * @Date: 2024-09-23 02:03:56 * @LastEditors: xxxxx@xx.com * @LastEditTime: 2025-02-11 16:18:03 * @FilePath: \goex-2.0\binance\main.go * @Description: * * Copyright (c) 2022 by xxxxx@xx.com, All Rights Reserved.
* @Author: xxxxx@xx.com * @Date: 2024-09-23 02:03:56 * @LastEditors: xxxxx@xx.com * @LastEditTime: 2025-02-11 16:18:03 * @FilePath: \goex-2.0\binance\main.go * @Description: * * Copyright (c) 2022 by xxxxx@xx.com, All Rights Reserved.
okx
* @Author: robert@xxx@xxx.com.com * @Date: 2024-09-23 02:03:56 * @LastEditors: robert@xxx@xxx.com.com * @LastEditTime: 2025-02-11 15:35:00 * @FilePath: \v2\util\string.go * @Description: * * Copyright (c) 2022 by robert@xxx@xxx.com.com, All Rights Reserved.
* @Author: robert@xxx@xxx.com.com * @Date: 2024-09-23 02:03:56 * @LastEditors: robert@xxx@xxx.com.com * @LastEditTime: 2025-02-11 15:35:00 * @FilePath: \v2\util\string.go * @Description: * * Copyright (c) 2022 by robert@xxx@xxx.com.com, All Rights Reserved.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL