Categorygithub.com/VitaliBabkin/golang-http-api
modulepackage
0.0.0-20230405203348-28cca759eda5
Repository: https://github.com/vitalibabkin/golang-http-api.git
Documentation: pkg.go.dev

# README

golang-http-api

Golang library for XNT Ltd. HTTP API service provides access to actual endpoints (https://api-live.exante.eu/api-docs/)

Building and installation

To install golang-http-api library, use go get:

$ go get github.com/VitaliBabkin/golang-http-api

Staying up to date

To update to the latest version, use

$ go get -u github.com/VitaliBabkin/golang-http-api

Developing golang-http-api

If you wish to work on golang-http-api itself, you will first need Go installed and configured on your machine (version 1.14+ is preferred, but the minimum required version is 1.8).

Next, using Git, clone the repository via git clone command

git clone https://github.com/VitaliBabkin/golang-http-api.git

Basic usage

First of all you need to get ApplicationID, ClientID and SharedKey from sandbox or production enviroment. And choose one of the authorization methods. It could be BasicAuth or JWT token.

Then instantiate API with NewAPI constructor

h := NewAPI(baseAPIURL,
		"2.0",
		"56ef81eb-c534-499d-936c-a6cefb72d772",
		"8541316993680-124b-8b4c-4d642fcd4493",
		"xpeNrMLpgG3JEoWaj84",
		30, "", "",
	)

Then methods can be called. Try with GetExchanges for example:

data, err := h.GetExchanges()
	if err != nil {
		fmt.Print(err)
	} else {
		fmt.Print(data)
	}

Or order initialization:

	o := OrderSentTypeV1{
		Side:           "buy",
		Duration:       "fill_or_kill",
		Quantity:       "10",
		OrderType:      "market",
		OcoGroup:       "5",
		Account:        "5",
		Instrument:     "Test",
		IfDoneParentID: "1",
	}

	err = h.PlaceOrderV1(&o)
	if err != nil {
		fmt.Print(err)
	} else {
		fmt.Print("OK")
	}

Try to get account summary:

	accSum, err := h.GetAccountSummary("DEW8032.001", "USD",
		GetAccountSummaryPayload{
			DatetimePayload: DatetimePayload{
				Datetime: "2020-10-10",
			},
		})
	if err != nil {
		fmt.Print(err)
	} else {
		fmt.Printf("%+v\n", accSum)
	}

See more code in examples.go file

All public HTTP API methods declared in api.go file

License

Released under the GNU GPL License

# Functions

NewAPI constructor for lib.
NewChangesV1 constructor.
NewChangesV2 constructor.
NewChangesV3 constructor.
NewExchanges constructor.
NewGroups constructor.
NewOHLCQuotes constructor.
NewOHLCTrades constructor.
NewOrdersV1 constructor.
NewOrdersV2 constructor.
NewOrdersV3 constructor.
NewOrderV1 constructor.
NewOrderV2 constructor.
NewOrderV3 constructor.
NewQuote constructor.
NewSchedule constructor.
NewSummary constructor.
NewSymbolSpecification constructor.
NewSymbolsV1 constructor.
NewSymbolsV2 constructor.
NewSymbolsV3 constructor.
NewSymbolV1 constructor.
NewSymbolV2 constructor.
NewSymbolV3 constructor.
NewTransactionsV1 constructor.
NewTransactionsV2 constructor.
NewTransactionsV3 constructor.
NewTypes constructor.
NewUserAccounts constructor.
NewСurrencys constructor.

# Constants

APIv1 api version.
APIv2 api version.
APIv3 api version.
BasicAuth type.
CurrentAPIVersion default api version.
JWTAuth type.
JWTDefaultTTL default lieftime of jwt token.
MDAPICategory md api url prefix.
TRADEAPICategory traders api url prefix.

# Variables

APIVersions list of available api verisons.
Scopes is JWT Auth scopes.

# Structs

Auth ...
BasicAuthMethod ...
CancelOrderPayload method optional payload.
ChangeV1 model.
ChangeV3 model.
CurrencyPos model.
DatetimePayload datetime optional field for requests.
DatetimeRangePayload optional query params for requsts.
Exchange model.
GetAccountSummaryPayload input params for GetAccountSummary method.
GetActiveOrderPayload optional input params for GetActiveOrder method.
GetOHLCOptionalPayload optional params for ohcl methods.
GetOrdersPayload input params for GetOrders method.
GetTransactionsOptionalPayload optional params for GetTransactions endpoint function.
Group model.
HTTPApi struct provide communication with xnt services.
JWTAuthMethod ...
OffsetLimitPayload offset and limit optional params.
OHLCQuote model.
OHLCTrade model.
OrderFill model.
OrderParameters model.
OrderSentTypeV1 model.
OrderSentTypeV2 model.
OrderSentTypeV3 model.
OrderState model.
OrderV1 model.
OrderV2 model.
OrderV3 model.
Period - part of schedule.
Position model.
Quote model.
ReplaceOrderPayload method optional payload.
ResponseLimit max size of response.
Schedule model.
StartStopOptionalPayload optional params.
Summary model.
SymbolIdentifiersDataV3 params for symbol (api v3).
SymbolOptionData optionals params for symbol.
SymbolOptionDataV2 ...
SymbolOptionDataV3 optionals params for symbol (api v3).
SymbolSpecification model.
SymbolV1 model.
SymbolV2 model.
SymbolV3 model.
TransactionV1 model.
TransactionV3 model.
Type concrete knows type.
UserAccount model.
Сurrencys model.

# Interfaces

IAuth ...

# Type aliases

ChangesV1 model.
ChangesV2 model.
ChangesV3 model.
ChangeV2 model.
Currency ..
Exchanges model.
GetTicksByQuotesPayload method optional payload.
GetTicksByTradesPayload method optional payload.
Groups model.
OHLCQuotes models.
OHLCTrades model.
OrdersV1 model.
OrdersV2 model.
OrdersV3 model.
QueryStringParams like ?foo=bar/.
SymbolsV1 model.
SymbolsV2 model.
SymbolsV3 model.
TransactionsV1 model.
TransactionsV2 model.
TransactionsV3 model.
TransactionV2 model.
Types known type.
UserAccounts model.