Skip to content

For Go developers, this library offers easy access to dxFeed market data. Built upon the GraalVM Native Image and our flagship dxFeed Java API, it provides a seamless experience for Go-based applications.

License

Notifications You must be signed in to change notification settings

dxFeed/dxfeed-graal-go-api

Repository files navigation

light

This package provides access to dxFeed market data. The library is built as a language-specific wrapper over the dxFeed Graal Native library, which was compiled with GraalVM Native Image and dxFeed Java API (our flagman API).

⚠️ It’s a beta version and still under active development.

Build Platform Go License Release

Table of Contents

Overview

dxFeed Graal Go API allows developers to create efficient applications in Go language. This enables developers to leverage all the benefits of native app development, resulting in maximum performance and usability for end users.

Milestones

We are working diligently to ensure that this new repository meets all of our standards for performance, security, and scalability. We will be providing regular updates throughout the development process.

If you have any questions, please contact us via our customer portal.

Future Development

Features planned with high priority:

  • refactroing public API
  • deployment and publication artifacts in JFrog (to simplify the integration of the package into client applications)
  • add all market events
  • provide more tools and samples
  • generate documentation

Implementation Details

We use GraalVM Native Image technology and specially written code that wraps Java methods into native ones to get dynamically linked libraries for different platforms (Linux, macOS, and Windows) based on the latest Java API package.

Then, the resulting dynamic link library (dxFeed Graal-native) is used through C ABI (application binary interface), and we write programming interfaces that describe our business model (similar to Java API).

As a result, we get a full-featured, similar performance as with Java API. Regardless of the language, writing the final application logic using API calls will be very similar (only the syntax will be amended, "best practices", specific language restrictions)

Below is a scheme of this process:

light

Documentation

Find useful information in our self-service dxFeed Knowledge Base or Go API documentation:

Requirements

Windows

Only x64 versions are supported.

OS Version Architectures
Windows 8, 8.1 x64
Windows 10 Version 1607+ x64
Windows 11 Version 22000+ x64
Windows Server 2012+ x64
Windows Server Core 2012+ x64
Nano Server Version 1809+ x64

Requirements

Linux

Only x64 versions are supported.

Requirements

Libc compatibility

  • glibc: 2.35+ (from Ubuntu 22.04)
  • musl: temporarily unsupported

macOS

OS Version Architectures
macOS 10.13+ x64
macOS 11+ Arm64

Is supported in the Rosetta 2 x64 emulator.

Requirements

Installation

Linux

sudo apt-get update
sudo apt-get install build-essential
go get github.com/dxFeed/dxFeed-graal-go-api
cd ~/go/pkg/mod/github.com/dxfeed/dxfeed-graal-go-api@<version>
go run .

Usage

How to connect to QD endpoint

package main

import (
	"fmt"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/api"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/events/eventcodes"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/events/quote"
	"math"
	"time"
)

type PrintEvents func(events []interface{})

func (pr PrintEvents) Update(events []any) {
	pr(events)
}

func main() {
	// For token-based authorization, use the following address format:
	// "demo.dxfeed.com:7300[login=entitle:token]"
	endpoint, err := api.NewEndpoint(api.Feed)
	if err != nil {
		panic(err)
	}
	defer func(endpoint *api.DXEndpoint) {
		_ = endpoint.Close()
	}(endpoint)

	err = endpoint.Connect("demo.dxfeed.com:7300")
	if err != nil {
		panic(err)
	}

	feed, err := endpoint.GetFeed()
	if err != nil {
		panic(err)
	}

	subscription, err := feed.CreateSubscription(eventcodes.Quote)
	if err != nil {
		panic(err)
	}
	defer subscription.Close()

	err = subscription.AddListener(PrintEvents(func(events []interface{}) {
		for _, event := range events {
			switch v := event.(type) {
			case *quote.Quote:
				fmt.Printf("%s\n", v.String())
			}
		}
	}))

	err = subscription.AddSymbol("AAPL")
	if err != nil {
		panic(err)
	}

	time.Sleep(time.Duration(math.MaxInt64))
}
Output
I 231130 124734.411 [main] QD - Using QDS-3.325+file-UNKNOWN, (C) Devexperts
I 231130 124734.415 [main] QD - Using scheme com.dxfeed.api.impl.DXFeedScheme slfwemJduh1J7ibvy9oo8DABTNhNALFQfw0KmE40CMI
I 231130 124734.418 [main] MARS - Started time synchronization tracker using multicast 239.192.51.45:5145 with dPyAu
I 231130 124734.422 [main] MARS - Started JVM self-monitoring
I 231130 124734.423 [main] QD - monitoring with collectors [Ticker, Stream, History]
I 231130 124734.424 [main] QD - monitoring DXEndpoint with dxfeed.address=demo.dxfeed.com:7300
I 231130 124734.425 [main] ClientSocket-Distributor - Starting ClientSocketConnector to demo.dxfeed.com:7300
I 231130 124734.425 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Resolving IPs for demo.dxfeed.com
I 231130 124734.427 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Connecting to 208.93.103.170:7300
I 231130 124734.530 [demo.dxfeed.com:7300-Reader] ClientSocketConnector - Connected to 208.93.103.170:7300
D 231130 124734.634 [demo.dxfeed.com:7300-Reader] QD - Distributor received protocol descriptor multiplexor@fFLro [type=qtp, version=QDS-3.319, opt=hs, mars.root=mdd.demo-amazon.multiplexor-demo1] sending [TICKER, STREAM, HISTORY, DATA] from 208.93.103.170
Quote{AAPL, eventTime=0, time=20231130-123206.000, timeNanoPart=0, sequence=0, bidTime=20231130-123206.000, bidExchange=P, bidPrice=189.36, bidSize=3.0, askTime=20231130-123129.000, askExchange=P, askPrice=189.53, askSize=10.0}

How to connect to dxLink

package main

import (
	"fmt"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/api"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/events/eventcodes"
	"github.com/dxfeed/dxfeed-graal-go-api/pkg/events/quote"
	"math"
	"time"
)

type PrintEvents func(events []interface{})

func (pr PrintEvents) Update(events []any) {
	pr(events)
}

func main() {
	// The experimental property must be enabled.
	api.SetSystemProperty("dxfeed.experimental.dxlink.enable", "true")
	// Set scheme for dxLink.
	api.SetSystemProperty("scheme", "ext:opt:sysprops,resource:dxlink.xml")

	// For token-based authorization, use the following address format:
	// "dxlink:wss://demo.dxfeed.com/dxlink-ws[login=dxlink:token]"
	endpoint, err := api.NewEndpoint(api.Feed)
	if err != nil {
		panic(err)
	}
	defer func(endpoint *api.DXEndpoint) {
		_ = endpoint.Close()
	}(endpoint)

	err = endpoint.Connect("dxlink:wss://demo.dxfeed.com/dxlink-ws")
	if err != nil {
		panic(err)
	}

	feed, err := endpoint.GetFeed()
	if err != nil {
		panic(err)
	}

	subscription, err := feed.CreateSubscription(eventcodes.Quote)
	if err != nil {
		panic(err)
	}
	defer subscription.Close()

	err = subscription.AddListener(PrintEvents(func(events []interface{}) {
		for _, event := range events {
			switch v := event.(type) {
			case *quote.Quote:
				fmt.Printf("%s\n", v.String())
			}
		}
	}))

	err = subscription.AddSymbol("AAPL")
	if err != nil {
		panic(err)
	}

	time.Sleep(time.Duration(math.MaxInt64))
}
Output
I 231130 124929.817 [main] QD - Using QDS-3.325+file-UNKNOWN, (C) Devexperts
I 231130 124929.821 [main] QD - Using scheme com.dxfeed.api.impl.DXFeedScheme slfwemJduh1J7ibvy9oo8DABTNhNALFQfw0KmE40CMI
I 231130 124929.824 [main] MARS - Started time synchronization tracker using multicast 239.192.51.45:5145 with sWipb
I 231130 124929.828 [main] MARS - Started JVM self-monitoring
I 231130 124929.828 [main] QD - monitoring with collectors [Ticker, Stream, History]
I 231130 124929.829 [main] QD - monitoring DXEndpoint with dxfeed.address=dxlink:wss://demo.dxfeed.com/dxlink-ws
I 231130 124929.831 [main] DxLinkClientWebSocket-Distributor - Starting DxLinkClientWebSocketConnector to wss://demo.dxfeed.com/dxlink-ws
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I 231130 124929.831 [wss://demo.dxfeed.com/dxlink-ws-Writer] DxLinkClientWebSocket-Distributor - Connecting to wss://demo.dxfeed.com/dxlink-ws
I 231130 124930.153 [wss://demo.dxfeed.com/dxlink-ws-Writer] DxLinkClientWebSocket-Distributor - Connected to wss://demo.dxfeed.com/dxlink-ws
D 231130 124931.269 [oioEventLoopGroup-2-1] QD - Distributor received protocol descriptor [type=dxlink, version=0.1-0.18-20231017-133150, keepaliveTimeout=120, acceptKeepaliveTimeout=5] sending [] from wss://demo.dxfeed.com/dxlink-ws
D 231130 124931.271 [oioEventLoopGroup-2-1] QD - Distributor received protocol descriptor [type=dxlink, version=0.1-0.18-20231017-133150, keepaliveTimeout=120, acceptKeepaliveTimeout=5, authentication=] sending [] from wss://demo.dxfeed.com/dxlink-ws
Quote{AAPL, eventTime=0, time=20231130-123421.000, timeNanoPart=0, sequence=0, bidTime=20231130-123421.000, bidExchange=Q, bidPrice=189.47, bidSize=4.0, askTime=20231130-123421.000, askExchange=P, askPrice=189.53, askSize=10.0}

To familiarize with the dxLink protocol, please click here.

Tools

Tools is a collection of utilities that allow you to subscribe to various market events for the specified symbols. The tools can be downloaded from Release

  • Connect connects to the specified address(es) and subscribes to the specified events with the specified symbol
  • Dump dumps all events received from address. This was designed to retrieve data from a file
  • PerfTest connects to the specified address(es) and calculates performance counters (events per second, memory usage, CPU usage, etc.)
  • LatencyTest connects to the specified address(es) and calculates latency

To run tools on macOS, it may be necessary to unquarantine them:

sudo /usr/bin/xattr -r -d com.apple.quarantine <directory_with_tools>

Samples

  • ConvertTapeFile demonstrates how to convert one tape file to another tape file with optional intermediate processing or filtering
  • DxFeedFileParser is a simple demonstration of how events are read form a tape file
  • DxFeedSample is a simple demonstration of how to create multiple event listeners and subscribe to Quote and Trade events
  • PrintQuoteEvents is a simple demonstration of how to subscribe to the Quote event, using a DxFeed instance singleton and dxfeed.properties file
  • WriteTapeFile is a simple demonstration of how to write events to a tape file
  • DxFeedIpfConnect is a simple demonstration of how to get Instrument Profiles
  • DXFeedLiveIpfSample is a simple demonstration of how to get live updates for Instrument Profiles
  • DxFeedPublishProfiles is a simple demonstration of how to publish market events
  • ScheduleSample is a simple demonstration of how to get various scheduling information for instruments
  • DXFeedconnect is a simple demonstration of how to subscribe to different events using TimeSeriesSubscription

Current State

Endpoint Roles

  • FEED connects to the remote data feed provider and is optimized for real-time or delayed data processing, this is a default role

  • STREAM_FEED is similar to Feed and also connects to the remote data feed provider but is designed for bulk data parsing from files

  • PUBLISHER connects to the remote publisher hub (also known as multiplexor) or creates a publisher on the local host

  • STREAM_PUBLISHER is similar to Publisher and also connects to the remote publisher hub, but is designed for bulk data publishing

  • LOCAL_HUB is a local hub without the ability to establish network connections. Events published via Publisher are delivered to local Feed only

  • ON_DEMAND_FEED is similar to Feed, but it is designed to be used with OnDemandService for historical data replay only

Event Types

  • Order is a snapshot of the full available market depth for a symbol

  • SpreadOrder is a snapshot of the full available market depth for all spreads

  • AnalyticOrder is an Order extension that introduces analytic information, such as adding iceberg-related information to a given order

  • Trade is a snapshot of the price and size of the last trade during regular trading hours and an overall day volume and day turnover

  • TradeETH is a snapshot of the price and size of the last trade during extended trading hours and the extended trading hours day volume and day turnover

  • Candle event with open, high, low, and close prices and other information for a specific period

  • Quote is a snapshot of the best bid and ask prices and other fields that change with each quote

  • Profile is a snapshot that contains the security instrument description

  • Summary is a snapshot of the trading session, including session highs, lows, etc.

  • TimeAndSale represents a trade or other market event with price, such as the open/close price of a market, etc.

  • Greeks is a snapshot of the option price, Black-Scholes volatility, and greeks

  • Series is a snapshot of computed values available for all options series for a given underlying symbol based on options market prices

  • TheoPrice is a snapshot of the theoretical option price computation that is periodically performed by dxPrice model-free computation

  • Underlying is a snapshot of computed values available for an option underlying symbol based on the market’s option prices

  • OptionSale represents a trade or another market event with the price (for example, market open/close price, etc.) for each option symbol listed under the specified Underlying

  • Configuration is an event with an application-specific attachment

  • Message is an event with an application-specific attachment

Subscription Symbols

Subscriptions & Models

IPF & Schedule

Services

About

For Go developers, this library offers easy access to dxFeed market data. Built upon the GraalVM Native Image and our flagship dxFeed Java API, it provides a seamless experience for Go-based applications.

Resources

License

Stars

Watchers

Forks

Packages