Documentation ¶
Overview ¶
Package client implements a client to connect with CryptoMarket using the endpoints given at https://developers.cryptomkt.com/.
Index ¶
- Variables
- type Account
- type AccountResponse
- type Amount
- type Balance
- type BalancesResponse
- type BankAccount
- type Book
- type BookData
- type BookResponse
- type Candle
- type Client
- func (client *Client) CancelOrder(arguments ...args.Argument) (*Order, error)
- func (client *Client) CreateInstant(arguments ...args.Argument) error
- func (client *Client) CreateOrder(arguments ...args.Argument) (*Order, error)
- func (client *Client) GetAccount() (*Account, error)
- func (client *Client) GetActiveOrders(arguments ...args.Argument) (*OrderList, error)
- func (client *Client) GetActiveOrdersAllPages(arguments ...args.Argument) ([]Order, error)
- func (client *Client) GetAllTransactions(argus ...args.Argument) ([]Transaction, error)
- func (client *Client) GetBalance() ([]Balance, error)
- func (client *Client) GetBook(arguments ...args.Argument) (*Book, error)
- func (client *Client) GetExecutedOrders(arguments ...args.Argument) (*OrderList, error)
- func (client *Client) GetExecutedOrdersAllPages(arguments ...args.Argument) ([]Order, error)
- func (client *Client) GetInstant(arguments ...args.Argument) (*Instant, error)
- func (client *Client) GetMarkets() ([]string, error)
- func (client *Client) GetOrderStatus(arguments ...args.Argument) (*Order, error)
- func (client *Client) GetPrices(arguments ...args.Argument) (*Prices, error)
- func (client *Client) GetTicker(arguments ...args.Argument) ([]Ticker, error)
- func (client *Client) GetTrades(arguments ...args.Argument) (*Trades, error)
- func (client *Client) GetTradesAllPages(arguments ...args.Argument) ([]TradeData, error)
- func (client *Client) GetTransactions(arguments ...args.Argument) (*TransactionList, error)
- func (client *Client) GetWallets() ([]Balance, error)
- func (client *Client) RequestDeposit(arguments ...args.Argument) error
- func (client *Client) RequestWithdrawal(arguments ...args.Argument) error
- func (client *Client) String() string
- func (client *Client) Transfer(arguments ...args.Argument) error
- type DataPrices
- type HMACAuth
- type Instant
- type InstantResponse
- type MarketListResponse
- type Order
- type OrderList
- type OrderListResp
- type OrderResponse
- type Pagination
- type Prices
- type PricesResponse
- type Rate
- type Ticker
- type TickerResponse
- type TradeData
- type Trades
- type TradesResponse
- type Transaction
- type TransactionList
- type TransactionsResponse
Constants ¶
This section is empty.
Variables ¶
var ( // DELAY is the amount to wait in seconds between requests to the server, // too many requests and the ip is blocked. DELAY float64 = 2.5 )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Name string Email string Rate Rate BankAccounts []BankAccount `json:"bank_accounts"` }
type AccountResponse ¶
type BalancesResponse ¶
type BankAccount ¶
type Book ¶
type Book struct { Data []BookData // contains filtered or unexported fields }
func (*Book) GetNext ¶
GetNext lets you go to the next page if it exists, returns (*Book, nil) if it is successfull and (nil, error) otherwise
func (*Book) GetPrevious ¶
GetPrevious lets you go to the previous page if it exists, returns (*Book, nil) if it is successfull and (nil, error) otherwise
type BookResponse ¶
type BookResponse struct { Status string Message string Pagination Pagination Data []BookData }
type Candle ¶
type Candle struct { CandleId int `json:"candle_id"` OpenPrice string `json:"open_price"` HightPrice string `json:"hight_price"` ClosePrice string `json:"close_price"` LowPrice string `json:"low_price"` VolumeSum string `json:"volume_sum"` CandleDate string `json:"candle_date"` TickCount string `json:"tick_count"` }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client keep the needed data to connect with the asociated CryptoMarket account.
func (*Client) CancelOrder ¶
CancelOrder cancel an order in CryptoMarket, given its id Returns an Order struct that supports Close() and Refresh() to cancel or update the order respectively.
List of accepted Arguments:
- required: Id (string)
- optional: none
func (*Client) CreateInstant ¶
CreateInstant makes an order in the Instant Exchange of CryptoMarket Returns an error if something goes wrong
List of accepted Arguments:
- required: Market (string), Type (string), Amount (string)
- optional: none
func (*Client) CreateOrder ¶
CreateOrder creates an order to buy or sell in a market of CryptoMarket Returns an Order struct that supports Close() and Refresh() to cancel or update the order respectively.
List of accepted Arguments:
- required: Amount (string), Market (string), Price (string), Type (string)
- optional: none
func (*Client) GetAccount ¶
GetAccount gives the information of the cryptoMarket account. Returns the data in an Account struct
func (*Client) GetActiveOrders ¶
GetActiveOrders returns the list of active orders of the client in a given market. Retunrs an OrderList struct, where all the orders are in the Data field, in a slice of Order. OrderLists supports Next() and Previous() to get the corresponding pages. OrderLists also supports Close() and Refresh(), to close or refresh all the orders of the list.
List of accepted Arguments:
- required: Market (string)
- optional: Page (int), Limit (int)
func (*Client) GetActiveOrdersAllPages ¶
GetActiveOrdersAllPages gets all the actives orders of the client in a given market. returns an array of orders.
List of accepted Arguments:
- required: Market (string)
- optional: none
func (*Client) GetAllTransactions ¶
func (client *Client) GetAllTransactions(argus ...args.Argument) ([]Transaction, error)
GetAllTransactions returns an array of transactions made in cryptomkt.
List of arguments:
required: currency (string)
func (*Client) GetBalance ¶
GetBalance returns the actual balance of the wallets of the client in CryptoMarket Returns the a slice of Balance structs
func (*Client) GetBook ¶
GetBook returns a pointer to a Book struct with the data given by the api and an error message. It returns (nil, error) when an error is raised and (*Book, nil) when the operation is successful. The data fields are: Price, Amount and Timestamp. To access these fields, you can call them by *Book.Data[indexYouWant].FieldYouWant
List of accepted Arguments:
- required: Market (string), Type (string)
- optional: Page (int), Limit (int)
func (*Client) GetExecutedOrders ¶
GetExecutedOrders return a list of the executed orders of the client in a given market. Retunrs an OrderList struct, where all the orders are in the Data field, in a slice of Order. OrderLists supports Next() and Previous() to get the corresponding pages. OrderLists also supports Close() and Refresh(), to close or refresh all the orders of the list.
List of accepted Arguments:
- required: Market (string)
- optional: Page (int), Limit (int)
func (*Client) GetExecutedOrdersAllPages ¶
GetExecutedOrdersAllPages gets all executed orders of the client in a given market
List of accepted Arguments:
- required: Market (string)
- optional: none
func (*Client) GetInstant ¶
GetInstant emulates an order in the current state of the Instant Exchange of CryptoMarket Returns an Instant struct holding the data.
List of accepted Arguments:
- required: Market (string), Type (string), Amount (string)
- optional: none
func (*Client) GetMarkets ¶
GetMarkets returns the available markets in cryptomarket as a string slice
func (*Client) GetOrderStatus ¶
GetOrderStatus gives the status of an order given its id. Returns an Order struct that supports Close() and Refresh() to cancel or update the order respectively.
List of accepted Arguments:
- required: Id (string)
- optional: none
func (*Client) GetPrices ¶
GetPrices return a pointer to a Prices struct with the data given by the api and an error message. It returns (nil,error) when an error is raised and (*Prices, nil) when the operation is successful. The data fields are classified in two categories, Ask and Bid. The fields are CandleId, OpenPrice, HightPrice, ClosePrice, LowPrice, VolumeSum CandleDate and TickCount. To access the data you can call this way: *Prices.Data.Ask[indexYouWant].FieldYouWant or *Prices.Data.Bid[indexYouWant].FieldYouWant
List of accepted Arguments:
- required: Market (string), Timeframe (string)
- optional: Page (int), Limit (int)
func (*Client) GetTicker ¶
GetTicker returns a list of Tickers. It returns (nil,error) when an error is raised and ([]Tiker, nil) when the operation is successful. The data fields are: High, Low, Ask, Bid, LastPrice, Volume, Market and Timestamp.
List of accepted Arguments:
- required: none
- optional: Market (string)
func (*Client) GetTrades ¶
GetTrades returns a pointer to a Trades struct with the data given by the api and an error message. It returns (nil, error) when an error is raised and (*Trades, nil) when the operation is successful. The data fields are MarketTaker, Price, Amount, Tid, Timestamp and Market. You can access them by *Trades.Data[indexYouWant].FieldYouWant
List of accepted Arguments:
- required: Market (string)
- optional: Start (string YYYY-MM-DD), End (YYYY-MM-DD), Page (int), Limit (int)
func (*Client) GetTradesAllPages ¶
GetTradesAllPages returns a pointer to a Trades struct with the data given by the api and an error message. It returns (nil, error) when an error is raised and (*Trades, nil) when the operation is successful. If end argument is not provided, the maximum data amount will be trucated when it raises more than 100 elements. It is not sure it will give you exactly 100 TradeData Data.
List of accepted Arguments:
- required: Market (string)
- optional: Start (string YYYY-MM-DD), End (string YYYY-MM-DD)
func (*Client) GetTransactions ¶
func (client *Client) GetTransactions(arguments ...args.Argument) (*TransactionList, error)
GetTransactions returns the movements of the wallets of the client for a given currency. Returns a TransactionList struct, where all the transactions are in the Data field in a slice of Transaction. TransactionList supports Next() and Previous to get the corresponding pages.
List of accepted Arguments:
- required: Currency (string)
- optional: Page (int), Limit (int)
func (*Client) GetWallets ¶
GetWallets is an alias for Balance, returns the actual balance of wallets of the client in CryptoMarket
func (*Client) RequestDeposit ¶
RequestDeposit makes a deposit to a wallet of local currency Returns an error if something goes wrong
List of accepted Arguments:
- required: Amount (string), BankAccount (string)
- required only for México, Brasil and European Union: Voucher (file)
- required only for México: Date (string dd/mm/yyyy), TrackingCode (string)
func (*Client) RequestWithdrawal ¶
RequestWithdrawal makes a withdrawal from a bank account of the client Returns an error if something goes wrong
List of accepted Arguments:
- required: Amount (string), BankAccount (string)
- optional: none
type DataPrices ¶
type HMACAuth ¶
type HMACAuth struct {
// contains filtered or unexported fields
}
A HMACAuth keeps the keys of a client making them usable along all request of the client to crpytomkt
type InstantResponse ¶
type MarketListResponse ¶
type Order ¶
type Order struct { Id string Status string Type string Price string Amount Amount ExecutionPrice string `json:"execution_price"` AvgExecutionPrice int `json:"avg_execution_price"` Market string CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` ExecutedAt string `json:"executed_at"` // contains filtered or unexported fields }
func (*Order) Close ¶
Close closes the calling order, and changes the order to reflect the new state of the order, after being closed. Calls CancelOrder with the asociated client of the order. https://developers.cryptomkt.com/es/#cancelar-una-orden
func (*Order) Refresh ¶
Refresh refreshes the calling order, and changes it to be the actual state of the order. Calls GetOrderStatus with the asociated client of the order. https://developers.cryptomkt.com/es/#estado-de-orden
type OrderList ¶
type OrderList struct { Status string Warnings string Data []Order // contains filtered or unexported fields }
func (*OrderList) GetNext ¶
GetNext lets you go to the next page if it exists, returns (*Prices, nil) if it is successfull and (nil, error) otherwise
func (*OrderList) GetPrevious ¶
GetPrevious get the previous page of the List of orders. If there is no previous page, rise an error.
type OrderListResp ¶
type OrderListResp struct { Status string Message string Pagination Pagination Warnings string Data []Order }
type OrderResponse ¶
type Pagination ¶
Data structs for this sdk
func (*Pagination) String ¶
func (pagination *Pagination) String() string
type Prices ¶
type Prices struct { Data DataPrices // contains filtered or unexported fields }
func (*Prices) GetLimit ¶
GetLimit returns the limit you have provided, but if you have not, it provides the default
func (*Prices) GetNext ¶
GetNext lets you go to the next page if it exists, returns (*Prices, nil) if it is successfull and (nil, error) otherwise
func (*Prices) GetPrevious ¶
GetPrevious lets you go to the previous page if it exists, returns (*Prices, nil) if it is successfull and (nil, error) otherwise
type PricesResponse ¶
type PricesResponse struct { Status string Message string Pagination Pagination Data DataPrices }
type Ticker ¶
type TickerResponse ¶
type TradeData ¶
type Trades ¶
type Trades struct { Data []TradeData // contains filtered or unexported fields }
func (*Trades) GetNext ¶
GetNext lets you go to the next page if it exists, returns (*Trades, nil) if it is successfull and (nil, error) otherwise
func (*Trades) GetPrevious ¶
GetPrevious lets you go to the previous page if it exists, returns (*Trades, nil) if it is successfull and (nil, error) otherwise
type TradesResponse ¶
type TradesResponse struct { Status string Message string Pagination Pagination Data []TradeData }
type Transaction ¶
type Transaction struct { Id string Type int Amount string FeePercent string `json:"fee_percent"` FeeAmount string `json:"fee_amount"` Balance string Date string Hash string Address string Memo string }
func (*Transaction) ToMap ¶
func (transaction *Transaction) ToMap() map[string]string
type TransactionList ¶
type TransactionList struct { Data []Transaction // contains filtered or unexported fields }
func (*TransactionList) GetLimit ¶
func (tList *TransactionList) GetLimit() int
GetLimit returns the limit number of elements per page
func (*TransactionList) GetNext ¶
func (tList *TransactionList) GetNext() (*TransactionList, error)
GetNext lets you go to the next page if it exists, returns (*Prices, nil) if it is successfull and (nil, error) otherwise
func (*TransactionList) GetPage ¶
func (tList *TransactionList) GetPage() int
GetPage returns the actual page.
func (*TransactionList) GetPrevious ¶
func (tList *TransactionList) GetPrevious() (*TransactionList, error)
GetPrevious get the previous page of the Transaction list If there is no previous page, rise an error.
type TransactionsResponse ¶
type TransactionsResponse struct { Status string Message string Pagination Pagination Data []Transaction // contains filtered or unexported fields }