uexchange

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 8 Imported by: 0

README ¶

logo

Library for working with the exchange UUSD and Crypton written in Golang

made-with-Go GoDoc go-report

What do you get by using this library:

  • crypto currency converter api;
  • crypton crypto currency price api;
  • cryptocurrency trading api;
  • crypto exchange and wallet;
  • anonymous cryptocurrency exchange api.

CRP.is - is the best anonymous bitcoin exchange, on the basis of which you can make your own bot using this library in the Golang language.

🔗 Crypton Exchange API docs

Install

go get github.com/Sagleft/uexchange-go
import (
	uexchange "github.com/Sagleft/uexchange-go"
)

Usage

// create client
client := uexchange.NewClient()

// auth
_, err := client.Auth(uexchange.Credentials{
    AccountPublicKey: "32AE83EF83637ADDA5800E2C9EEB3D456753B0B2CD11D37B90DFA1A1592ED952",
    Password: "mypassword",
})
if err != nil {
    log.Fatalln(err)
}

// get balance
balanceData, err := client.GetBalance()
if err != nil {
    log.Fatalln(err)
}
log.Println(balanceData)

Useful resources

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type APIAuthResponse ¶

type APIAuthResponse struct {
	Success bool                   `json:"success"`
	Error   string                 `json:"text"`
	Result  APIAuthResultContainer `json:"result"`
}

APIAuthResponse - ..

type APIAuthResultContainer ¶

type APIAuthResultContainer struct {
	UserSession UserSessionData `json:"user_session"`
	AuthToken   string          `json:"auth_token"`
}

APIAuthResultContainer - ..

type APIBalanceResponse ¶

type APIBalanceResponse struct {
	Success bool            `json:"success"`
	Error   string          `json:"text"` // srly? text? oh my god, crp.is developers...
	Result  BalanceResponse `json:"result"`
}

APIBalanceResponse - ..

type APIBookValueResponse ¶

type APIBookValueResponse struct {
	Success bool                   `json:"success"`
	Error   string                 `json:"text"`
	Result  BookValueDataContainer `json:"result"`
}

APIBookValueResponse - ..

type APICurrenciesListResponse ¶

type APICurrenciesListResponse struct {
	Success bool               `json:"success"`
	Error   string             `json:"text"`
	Result  CurrenciesListData `json:"result"`
}

APICurrenciesListResponse - ..

type APIOperationsHistoryResponse ¶

type APIOperationsHistoryResponse struct {
	Success bool                           `json:"success"`
	Error   string                         `json:"text"`
	Result  OperationsHistoryDataContainer `json:"result"`
}

APIOperationsHistoryResponse - ..

type APIOrdersHistoryResponse ¶

type APIOrdersHistoryResponse struct {
	Success bool                       `json:"success"`
	Error   string                     `json:"text"`
	Result  OrdersHistoryDataContainer `json:"result"`
}

APIOrdersHistoryResponse - ..

type APIOrdersResponse ¶

type APIOrdersResponse struct {
	Success bool                `json:"success"`
	Error   string              `json:"text"`
	Result  OrdersDataContainer `json:"result"`
}

APIOrdersResponse - response from get orders list

type APIPairsData ¶ added in v1.3.0

type APIPairsData struct {
	Pairs []PairsDataContainer `json:"pairs"`
}

APIPairsData - ..

type APIPairsResponse ¶

type APIPairsResponse struct {
	Success bool         `json:"success"`
	Error   string       `json:"text"`
	Result  APIPairsData `json:"result"`
}

APIPairsResponse - ..

type APIPlainResponse ¶

type APIPlainResponse struct {
	Success bool   `json:"success"`
	Error   string `json:"text"`
	Result  string `json:"result"`
}

APIPlainResponse - ..

type APISessionData ¶

type APISessionData struct {
	ID string `json:"id"` // session ID -- UUID format
}

APISessionData - ..

type APITradeData ¶

type APITradeData struct {
	OrderID  int64 `json:"order_id"`
	DaemonID int64 `json:"daemon_id"`
}

APITradeData - ..

type APITradeHistoryResponse ¶

type APITradeHistoryResponse struct {
	Success bool                      `json:"success"`
	Error   string                    `json:"text"`
	Result  TradeHistoryDataContainer `json:"result"`
}

APITradeHistoryResponse - ..

type APITradeResponse ¶

type APITradeResponse struct {
	Success bool         `json:"success"`
	Error   string       `json:"text"`
	Result  APITradeData `json:"result"`
}

APITradeResponse - ..

type BalanceData ¶

type BalanceData struct {
	ID       int          `json:"id"`
	Currency CurrencyData `json:"currency"`
	Reserve  float64      `json:"reserve"`
	Balance  float64      `json:"balance"`
}

BalanceData - ..

type BalanceResponse ¶

type BalanceResponse struct {
	AllBalance []BalanceData `json:"allbalance"`
	UserID     string        `json:"user_id"`
}

BalanceResponse - ..

type BookValueData ¶

type BookValueData struct {
	Price  float64 `json:"price"`  // example: 0.1752
	Amount float64 `json:"amount"` // example: 1555
	Value  float64 `json:"value"`  // example: 272.436
}

BookValueData - ..

type BookValueDataContainer ¶

type BookValueDataContainer struct {
	Sell []BookValueData `json:"book_sell"`
	Buy  []BookValueData `json:"book_buy"`
}

BookValueDataContainer - ..

type Client ¶

type Client struct {
	APICredentials Credentials `json:"credentials"`
	AuthToken      string      `json:"authToken"`
}

Client - ..

func NewClient ¶

func NewClient() *Client

NewClient - ..

func (*Client) Auth ¶

func (c *Client) Auth(cred Credentials) (*APIAuthResultContainer, error)

Auth client

func (*Client) Buy ¶

func (c *Client) Buy(pairSymbol string, amount, price float64) (int64, error)

Buy currency. returns order ID

func (*Client) Cancel ¶

func (c *Client) Cancel(orderID int64) error

Cancel the specified order

func (*Client) GetBalance ¶

func (c *Client) GetBalance() ([]BalanceData, error)

GetBalance - get balance data for all coins

func (*Client) GetMarketCurrenciesList ¶

func (c *Client) GetMarketCurrenciesList(pairSymbol string) (*CurrenciesListData, error)

GetMarketCurrenciesList - get exchange currencies list

func (*Client) GetOrderBook ¶

func (c *Client) GetOrderBook(pairSymbol string) (*BookValueDataContainer, error)

GetOrderBook by trade pair

func (*Client) GetOrderHistory ¶

func (c *Client) GetOrderHistory(orderID string) (*OrdersHistoryDataContainer, error)

GetOrderHistory - get orders history

func (*Client) GetPairPrice ¶ added in v1.3.3

func (c *Client) GetPairPrice(pairCode string) (PairPriceData, error)

func (*Client) GetPairs ¶

func (c *Client) GetPairs() ([]PairsDataContainer, error)

GetPairs - get trading pairs list

func (*Client) GetTradeHistory ¶

func (c *Client) GetTradeHistory(pairSymbol string) (*TradeHistoryDataContainer, error)

GetTradeHistory - get trading history by pairs

func (*Client) Hold ¶

func (c *Client) Hold(orderID int64) error

Hold or Unhold order

func (*Client) Logout ¶

func (c *Client) Logout() error

Logout - close auth session

func (*Client) NewGetAccountHistoryService ¶

func (c *Client) NewGetAccountHistoryService(requestType string) *GetAccountHistoryService

NewGetAccountHistoryService - create new get account history service

func (*Client) NewGetOrdersService ¶

func (c *Client) NewGetOrdersService() *GetOrdersService

NewGetOrdersService - create new get orders service

func (*Client) Sell ¶

func (c *Client) Sell(pairSymbol string, amount, price float64) (int64, error)

Sell currency. returns order ID

type Credentials ¶

type Credentials struct {
	AccountPublicKey string `json:"PublicKey"` // Utopia Account public key
	Password         string `json:"password"`  // Exchange User password
	TwoFACode        string `json:"2fa_pin"`   // 2-factor-authorization code. optional
}

Credentials - ..

type CurrenciesListData ¶

type CurrenciesListData map[string]CurrencyData

CurrenciesListData - ..

type CurrencyData ¶

type CurrencyData struct {
	ID            int64   `json:"id"`
	Name          string  `json:"name"`             // example: crp
	FullName      string  `json:"fullname"`         // example: Utopia Crypton
	AppName       string  `json:"appname"`          // example: crypton
	Icon          string  `json:"icon"`             // example: crp
	Round         int     `json:"round"`            // round precision, example: 8
	DepositFee    float64 `json:"deposit_fee"`      // example: 0
	DepositFeePRO float64 `json:"withdraw_fee_pro"` // example: 0.1
	MinWithdraw   float64 `json:"withdraw_min"`     // example: 5
	AddressSize   int     `json:"address_size"`     // example: 64
	MinFee        float64 `json:"min_fee"`          // example: 0.00000001
	Enable        bool    `json:"enable"`           // example: true
	Visible       bool    `json:"show"`             // example: true
}

CurrencyData - ..

type GetAccountHistoryService ¶

type GetAccountHistoryService struct {
	// required
	ExchangeClient *Client
	RequestType    string // history type: profile/trade/billing

	// optional
	FromID     string // pagination offset: uuid
	RecordType string // billing operation type (only for billing): payment/comission/withdraw or combined
	Currency   string // currency (only for billing type)
}

GetAccountHistoryService - get operations history service

func (*GetAccountHistoryService) Do ¶

Do request

func (*GetAccountHistoryService) SetCurrency ¶

func (s *GetAccountHistoryService) SetCurrency(newCurrency string) *GetAccountHistoryService

SetCurrency - set currency for request: currency (only for billing type)

func (*GetAccountHistoryService) SetFromID ¶

SetFromID - set form ID for request: pagination offset: uuid

func (*GetAccountHistoryService) SetRecordType ¶

func (s *GetAccountHistoryService) SetRecordType(newRecordType string) *GetAccountHistoryService

SetRecordType - set record type for request: billing operation type (only for billing): payment/comission/withdraw or combined

func (*GetAccountHistoryService) SetRequestType ¶

func (s *GetAccountHistoryService) SetRequestType(newRequestType string) *GetAccountHistoryService

SetRequestType - set request type for request

type GetOrdersService ¶

type GetOrdersService struct {
	ExchangeClient *Client
	OrderType      string // order type: open/close/cancel/hold
	TaskType       string // task type: buy/sell
}

GetOrdersService - get orders service with optional params

func (*GetOrdersService) Do ¶

Do request

func (*GetOrdersService) SetOrderType ¶

func (s *GetOrdersService) SetOrderType(newType string) *GetOrdersService

SetOrderType - set order type: open/close/cancel/hold

func (*GetOrdersService) SetTaskType ¶

func (s *GetOrdersService) SetTaskType(taskType string) *GetOrdersService

SetTaskType - set task type: buy/sell

type MarketDataContainer ¶

type MarketDataContainer struct {
	Open      float64 `json:"open"`       // example: 0.1744
	Close     float64 `json:"close"`      // example: 0.1752
	High      float64 `json:"high"`       // example: 0.1766
	Low       float64 `json:"low"`        // example: 0.1553
	Volume    float64 `json:"volume"`     // example: 67044.815
	VolumeUSD float64 `json:"volume_usd"` // example: 1174.6252
	Value     float64 `json:"value"`      // example: 11346.6402207
	Rate      float64 `json:"rate"`       // example: 0.46
	DateNow   int64   `json:"date_now"`   // example: 1634566376377
}

MarketDataContainer - ..

type OperationsHistoryDataContainer ¶

type OperationsHistoryDataContainer struct {
	Items []TradeHistoryData `json:"items"`
}

OperationsHistoryDataContainer - ..

type OrderData ¶

type OrderData struct {
	OrderID               int64   `json:"order_id"`       // example: 3747944
	Amount                float64 `json:"amount"`         // example: 1
	Price                 float64 `json:"price"`          // example: 3
	Value                 float64 `json:"value"`          // example: 3
	OriginalValue         float64 `json:"orig_value"`     // example: 3
	OriginalAmount        float64 `json:"orig_amount"`    // example: 1
	OrderRegistrationDate int64   `json:"date_reg"`       // example: 1527883807109
	TaskType              string  `json:"task"`           // example: sell
	Status                string  `json:"status"`         // example: open
	BaseTicker            string  `json:"cur"`            // example: crp
	QuoteTicker           string  `json:"ecur"`           // example: usdt
	ExecutedPrice         float64 `json:"price_executed"` // example: 0
	ExecutedValue         float64 `json:"value_executed"` // example: 0
}

OrderData - ..

type OrdersDataContainer ¶

type OrdersDataContainer struct {
	AllOrders     []OrderData    `json:"allorders"`
	Pagination    PaginationData `json:"paginator"`
	Filters       []string       `json:"filters"`
	MyOrdersCount int            `json:"my_order_count"`
}

OrdersDataContainer - orders response data

type OrdersHistoryDataContainer ¶

type OrdersHistoryDataContainer struct {
	Order   OrderData             `json:"order"`
	History []OrderData           `json:"history"`
	Pair    OrdersHistoryPairData `json:"pair"`
}

OrdersHistoryDataContainer - ..

type OrdersHistoryPairData ¶

type OrdersHistoryPairData struct {
	BaseTicker  string `json:"cur"`
	QuoteTicker string `json:"ecur"`
}

OrdersHistoryPairData - ..

type PaginationData ¶

type PaginationData struct {
	Count int `json:"count"`
	Page  int `json:"page"`
	Limit int `json:"limit"`
}

PaginationData - ..

type PairData ¶

type PairData struct {
	ID              int64   `json:"pair_id"`           // example: 25
	PairCode        string  `json:"pair"`              // example: crp_usdt
	PairTitle       string  `json:"pair_show"`         // example: CRP / USDT
	CoinsGroup      string  `json:"group"`             // example: crp
	Visible         bool    `json:"visible"`           // example: true
	Enabled         bool    `json:"enable"`            // example: true
	RoundDealAmount int     `json:"round_deal_amount"` // example: 3
	RoundDealPrice  int     `json:"round_deal_price"`  // example: 4
	MinAmount       float64 `json:"min_amount"`        // 1
	MinPrice        float64 `json:"min_price"`         // 0.001
	MaxPrice        float64 `json:"max_price"`         // 100
}

PairData - ..

type PairPriceData ¶ added in v1.3.3

type PairPriceData struct {
	PairCode     string
	BestAskPrice float64
	BestBidPrice float64
}

type PairsDataContainer ¶

type PairsDataContainer struct {
	Pair       PairData            `json:"pair"`
	MarketData MarketDataContainer `json:"data_market"`
}

PairsDataContainer - ..

type TradeHistoryData ¶

type TradeHistoryData struct {
	RecordID   string  `json:"record_id"`   // UUID format, example: f914ea5d-32ae-4eac-a5e0-e94d55f7b4a7
	RecordType string  `json:"record_type"` // example: buy
	Price      float64 `json:"price"`       // example: 0.1752
	Amount     float64 `json:"amount"`      // example: 1
	Value      float64 `json:"value"`       // 0.1752
	CreatedAt  int64   `json:"created_at"`  // date, example: 1634566302532
}

TradeHistoryData - ..

type TradeHistoryDataContainer ¶

type TradeHistoryDataContainer struct {
	Items []TradeHistoryData    `json:"items"`
	Pair  OrdersHistoryPairData `json:"pair"`
}

TradeHistoryDataContainer - ..

type UserData ¶

type UserData struct {
	ID     string `json:"id"`     // exchange user ID -- UUID format
	Name   string `json:"name"`   // username
	Status string `json:"status"` // example: active
	Lang   string `json:"lang"`   // user language
}

UserData - ..

type UserSessionData ¶

type UserSessionData struct {
	User       UserData       `json:"user"`
	APISession APISessionData `json:"session"`
}

UserSessionData - ..

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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