gemini

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: MIT Imports: 12 Imported by: 0

README

GitHub license Donate Bitcoin Donate Ethereum

API wrapper for the Gemini Exchange REST API

Gemini-api is a wrapper for the Gemini Exchange REST API https://docs.gemini.com/rest-api/ it can connect to the production site https://api.gemini.com or to the Sandbox site https://api.sandbox.gemini.com for testing purposes.

This package is based on the https://github.com/jsgoyette/gemini, I have rewritten many things, added some more functionalities, debug & trace logging but I haven't had time to fully test everything, it is working fine for me but use it at your own risk.

gemini_cli

This package is used by the gemini_cli https://github.com/claudiocandio/gemini_cli a cli command to facilitate the use of the Gemini Exchange via REST API.

Usage Example

$ go get github.com/claudiocandio/gemini-api

Simple example:

package main

import (
 "encoding/json"
 "fmt"

 "github.com/claudiocandio/gemini-api"
)

func main() {

 api := gemini.New(
  false, // if this is false, it will use Gemini Sandox site: <https://api.sandbox.gemini.com>
         // if this is true,  it will use Gemini Production site: <https://api.gemini.com>
  "MyGeminiApiKey",    // GEMINI_API_KEY
  "MyGeminiApiSecret", // GEMINI_API_SECRET
 )

 // check more api methods in private.go & public.go
 accountDetail, err := api.AccountDetail()
 if err != nil {
  fmt.Printf("Error AccountDetail: %s\n", err)
  return
 }
 j, err := json.MarshalIndent(&accountDetail, "", " ")
 if err != nil {
  fmt.Printf("Error MarshalIndent: %s\n", err)
 }

 fmt.Printf("%s", j)
}

Check more api methods in private.go & public.go

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountName string    `json:"accountname"`
	ShortName   string    `json:"shortname"`
	Type        string    `json:"type"`
	Created     int64     `json:"created,string"`
	CreatedT    time.Time `json:"createdt,omitempty"`
}

type AccountDetail

type AccountDetail struct {
	Account             Account `json:"account"`
	Users               []Users `json:"users"`
	Memo_Reference_Code string  `json:"memo_reference_code"`
}

type Api

type Api struct {
	// contains filtered or unexported fields
}

func New

func New(live bool, key, secret string) *Api

func (*Api) AccountDetail

func (api *Api) AccountDetail() (AccountDetail, error)

Account

func (*Api) ActiveOrders

func (api *Api) ActiveOrders() ([]Order, error)

Active Orders

func (*Api) AuctionHistory

func (api *Api) AuctionHistory(symbol string, args Args) ([]Auction, error)

Auction History Args{"since": 50, "limit": 0, "includeIndicative": true}

func (*Api) Balances

func (api *Api) Balances() ([]FundBalance, error)

Balances

func (*Api) CancelAll

func (api *Api) CancelAll() (CancelResult, error)

Cancel All This will cancel all outstanding orders created by all sessions owned by this account, including interactive orders placed through the UI. Note that this cancels orders that were not placed using this API key.

func (*Api) CancelOrder

func (api *Api) CancelOrder(orderId string) (Order, error)

Cancel Order

func (*Api) CancelSession

func (api *Api) CancelSession() (CancelResult, error)

This will cancel all orders opened by this session. This will have the same effect as heartbeat expiration if "Require Heartbeat" is selected for the session.

func (*Api) CurrentAuction

func (api *Api) CurrentAuction(symbol string) (CurrentAuction, error)

Current Auction

func (*Api) DepositAddresses

func (api *Api) DepositAddresses(currency string) ([]DepositAddresses, error)

Get Deposit Addresseses currency can be bitcoin, ethereum, bitcoincash, litecoin, zcash, filecoin

func (*Api) Heartbeat

func (api *Api) Heartbeat() (GenericResponse, error)

Heartbeat This will prevent a session from timing out and canceling orders if the require heartbeat flag has been set. Note that this is only required if no other private API requests have been made. The arrival of any message resets the heartbeat timer.

func (*Api) NewDepositAddress

func (api *Api) NewDepositAddress(currency, label string) (NewDepositAddress, error)

New Deposit Address currency can be bitcoin, ethereum, bitcoincash, litecoin, zcash, or filecoin

func (*Api) NewOrder

func (api *Api) NewOrder(symbol, clientOrderId string, amount, price float64, side string, options []string) (Order, error)

New Order

func (*Api) OrderBook

func (api *Api) OrderBook(symbol string, args Args) (Book, error)

Order Book

func (*Api) OrderStatus

func (api *Api) OrderStatus(orderId string) (Order, error)

Order Status

func (*Api) PastTrades

func (api *Api) PastTrades(symbol string, args Args) ([]PastTrade, error)

Past Trades Args{"limit_trades": 50, "timestamp": "2021-12-01T15:04:01"} limit_trades": 0 -> retrieves all trades

func (*Api) Symbols

func (api *Api) Symbols() ([]string, error)

Symbols

func (*Api) TickerV1

func (api *Api) TickerV1(symbol string) (TickerV1, error)

TickerV1

func (*Api) TickerV2

func (api *Api) TickerV2(symbol string) (TickerV2, error)

TickerV2

func (*Api) TradeVolume

func (api *Api) TradeVolume() ([][]TradeVolume, error)

Trade Volume

func (*Api) Trades

func (api *Api) Trades(symbol string, args Args) ([]Trade, error)

Trades

func (*Api) Transfers

func (api *Api) Transfers(args Args) ([]Transfer, error)

Args{"timestamp": "2021-12-01T15:04:01", "limit_transfers": 20,"show_completed_deposit_advances": false}

func (*Api) WithdrawFunds

func (api *Api) WithdrawFunds(currency, address string, amount float64) (WithdrawFundsResult, error)

Withdraw Crypto Funds currency can be btc or eth

type Args

type Args map[string]interface{}

type Auction

type Auction struct {
	Timestampms     int64     `json:"timestampms"`
	TimestampmsT    time.Time `json:"timestampmst,omitempty"`
	AuctionId       int64     `json:"auction_id"`
	Eid             int64     `json:"eid"`
	EventType       string    `json:"event_type"`
	AuctionResult   string    `json:"auction_result"`
	AuctionPrice    float64   `json:"auction_price,string"`
	AuctionQuantity float64   `json:"auction_quantity,string"`
	HighestBidPrice float64   `json:"highest_bid_price,string"`
	LowestAskPrice  float64   `json:"lowest_ask_price,string"`
	CollarPrice     float64   `json:"collar_price,string"`
}

type Book

type Book struct {
	Bids BookEntries `json:"bids"`
	Asks BookEntries `json:"asks"`
}

type BookEntries

type BookEntries []BookEntry

type BookEntry

type BookEntry struct {
	Price  float64 `json:"price,string"`
	Amount float64 `json:"amount,string"`
}

type CancelResult

type CancelResult struct {
	Result  string              `json:"result"`
	Details CancelResultDetails `json:"details"`
}

type CancelResultDetails

type CancelResultDetails struct {
	CancelledOrders []float64 `json:"cancelledOrders"`
	CancelRejects   []float64 `json:"cancelRejects"`
}

type CurrentAuction

type CurrentAuction struct {
	ClosedUntil                  int64     `json:"closed_until_ms,omitempty"`
	LastAuctionEid               int64     `json:"last_auction_eid,omitempty"`
	LastAuctionPrice             float64   `json:"last_auction_price,string,omitempty"`
	LastAuctionQuantity          float64   `json:"last_auction_quantity,string,omitempty"`
	LastHighestBidPrice          float64   `json:"last_highest_bid_price,string,omitempty"`
	LastLowestAskPrice           float64   `json:"last_lowest_ask_price,string,omitempty"`
	LastCollarPrice              float64   `json:"last_collar_price,string,omitempty"`
	MostRecentIndicativePrice    float64   `json:"most_recent_indicative_price,string,omitempty"`
	MostRecentIndicativeQuantity float64   `json:"most_recent_indicative_quantity,string,omitempty"`
	MostRecentHighestBidPrice    float64   `json:"most_recent_highest_bid_price,string,omitempty"`
	MostRecentLowestAskPrice     float64   `json:"most_recent_lowest_ask_price,string,omitempty"`
	MostRecentCollarPrice        float64   `json:"most_recent_collar_price,string,omitempty"`
	NextUpdate                   int64     `json:"next_update_ms,omitempty"`
	NextUpdateT                  time.Time `json:"next_update_mst,omitempty"`
	NextAuction                  int64     `json:"next_auction_ms"`
	NextAuctionT                 time.Time `json:"next_auction_mst,omitempty"`
}

type DepositAddresses

type DepositAddresses struct {
	Address      string    `json:"address"`
	Timestamp    int64     `json:"timestamp"`
	TimestampmsT time.Time `json:"timestampmst,omitempty"`
	Label        string    `json:"label,omitempty"`
}

type FundBalance

type FundBalance struct {
	Currency               string  `json:"currency"`
	Amount                 float64 `json:"amount,string"`
	Available              float64 `json:"available,string"`
	AvailableForWithdrawal float64 `json:"availableForWithdrawal,string"`
	Type                   string  `json:"type"`
}

type GenericResponse

type GenericResponse struct {
	Result string `json:"result"`
}

type NewDepositAddress

type NewDepositAddress struct {
	Request string `json:"request"`
	Address string `json:"address"`
	Label   string `json:"label"`
}

type Order

type Order struct {
	OrderId           string   `json:"order_id"`
	ClientOrderId     string   `json:"client_order_id"`
	Symbol            string   `json:"symbol"`
	Exchange          string   `json:"exchange"`
	Price             float64  `json:"price,string"`
	AvgExecutionPrice float64  `json:"avg_execution_price,string"`
	Side              string   `json:"side"`
	Type              string   `json:"type"`
	Options           []string `json:"options"`
	//	Timestamp         string    `json:"timestamp"`
	Timestampms     int64     `json:"timestampms"`
	TimestampmsT    time.Time `json:"timestampmst,omitempty"`
	IsLive          bool      `json:"is_live"`
	IsCancelled     bool      `json:"is_cancelled"`
	Reason          string    `json:"reason"`
	WasForced       bool      `json:"was_forced"`
	ExecutedAmount  float64   `json:"executed_amount,string"`
	RemainingAmount float64   `json:"remaining_amount,string"`
	OriginalAmount  float64   `json:"original_amount,string"`
	IsHidden        bool      `json:"is_hidden"`
}

type PastTrade

type PastTrade struct {
	Price           float64   `json:"price,string"`
	Amount          float64   `json:"amount,string"`
	Timestamp       int64     `json:"timestamp"`
	Timestampms     int64     `json:"timestampms"`
	TimestampmsT    time.Time `json:"timestampmst,omitempty"`
	Type            string    `json:"type"`
	Aggressor       bool      `json:"aggressor"`
	FeeCurrency     string    `json:"fee_currency"`
	FeeAmount       float64   `json:"fee_amount,string"`
	TradeId         int64     `json:"tid"`
	OrderId         string    `json:"order_id"`
	Client_Order_Id string    `json:"client_order_id,omitempty"`
	Exchange        string    `json:"exchange"`
	IsAuctionFill   bool      `json:"is_auction_fill"`
	Break           string    `json:"break,omitempty"`
}

type TickerV1

type TickerV1 struct {
	Bid    float64        `json:"bid,string"`
	Ask    float64        `json:"ask,string"`
	Last   float64        `json:"last,string"`
	Volume TickerV1Volume `json:"volume"`
}

type TickerV1Volume

type TickerV1Volume struct {
	BTC       float64 `json:",string"`
	ETH       float64 `json:",string"`
	USD       float64 `json:",string"`
	Timestamp int64   `json:"timestamp"`
}

type TickerV2

type TickerV2 struct {
	Symbol  string   `json:"symbol"`
	Open    float64  `json:"open,string"`
	High    float64  `json:"high,string"`
	Low     float64  `json:"low,string"`
	Close   float64  `json:"close,string"`
	Changes []string `json:"changes"`
	Bid     float64  `json:"bid,string"`
	Ask     float64  `json:"ask,string"`
}

type Trade

type Trade struct {
	Timestamp    int64     `json:"timestamp"`
	Timestampms  int64     `json:"timestampms"`
	TimestampmsT time.Time `json:"timestampmst,omitempty"`
	TradeId      int64     `json:"tid"`
	Price        float64   `json:"price,string"`
	Amount       float64   `json:"amount,string"`
	Exchange     string    `json:"exchange"`
	Type         string    `json:"type"`
	Broken       bool      `json:"broken,omitempty"`
}

type TradeVolume

type TradeVolume struct {
	Symbol            string  `json:"symbol"`
	BaseCurrency      string  `json:"base_currency"`
	NotionalCurrency  string  `json:"notional_currency"`
	DataDate          string  `json:"data_date"`
	TotalVolumeBase   float64 `json:"total_volume_base"`
	MakeBuySellRatio  float64 `json:"maker_buy_sell_ratio"`
	BuyMakerBase      float64 `json:"buy_maker_base"`
	BuyMakerNotional  float64 `json:"buy_maker_notional"`
	BuyMakerCount     float64 `json:"buy_maker_count"`
	SellMakerBase     float64 `json:"sell_maker_base"`
	SellMakerNotional float64 `json:"sell_maker_notional"`
	SellMakerCount    float64 `json:"sell_maker_count"`
	BuyTakerBase      float64 `json:"buy_taker_base"`
	BuyTakerNotional  float64 `json:"buy_taker_notional"`
	BuyTakerCount     float64 `json:"buy_taker_count"`
	SellTakerBase     float64 `json:"sell_taker_base"`
	SellTakerNotional float64 `json:"sell_taker_notional"`
	SellTakerCount    float64 `json:"sell_taker_count"`
}

type Transfer

type Transfer struct {
	Type         string    `json:"type"`
	Status       string    `json:"status"`
	Timestampms  int64     `json:"timestampms"`
	TimestampmsT time.Time `json:"timestampmst,omitempty"`
	Eid          int64     `json:"eid"`
	AdvancedEid  int64     `json:"advanceEid"`
	Currency     string    `json:"currency"`
	Amount       float64   `json:"amount,string"`
	Method       string    `json:"method,omitempty"`
	TxHash       string    `json:"txHash,omitempty"`
	OutputIdx    float64   `json:"outputIdx,omitempty"`
	Destination  string    `json:"destination,omitempty"`
	Purpose      string    `json:"purpose,omitempty"`
}

type Users

type Users struct {
	Name        string    `json:"name"`
	LastSignIn  time.Time `json:"lastsignin"`
	Status      string    `json:"status"`
	CountryCode string    `json:"countrycode"`
	IsVerified  bool      `json:"isverified"`
}

type WithdrawFundsResult

type WithdrawFundsResult struct {
	Address      string `json:"address"`
	Amount       string `json:"amount"`
	TxHash       string `json:"txHash"`
	WithdrawalID string `json:"withdrawalID,omitempty"`
	Message      string `json:"message,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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