| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The Barchart API provides support for three operational modes:
The pull modes require a user login and password, please contact Barchart for credentials. The pull by exchange mode requires a refresh/snapshot user and password, so the API can refresh the symbol state via a web service.
The server push mode requires Barchart to push market data to the customer's server and requires the following:
The server push mode does not require a login or password. Please contact Barchart for provisioning.
The API requires Java 8 or higher.
This client will connect up to a JERQ middleware server and display market data.
The source code is in src/**/DdfClientExample.java.
To get help
java -jar ddf-examples-<version>-exe.jar -h
Run in pull by symbol mode for symbols IBM,ESU5
java -jar ddf-examples-<version>-exe.jar -u <user> -p <pass> -sym IBM,ESU5 -l a
Run in pull by exchange mode for exchange NYSE (N) with all logging enabled and background refresh enabled
java -jar ddf-examples-<version>-exe.jar -u <feed user> -p <pass> -e N -l a -su <snaphot user> -sp <snapshot password>
The server example API is used by clients who will receive market data directly from Barchart's internal servers. The source code is in src/**/ServerListenExample.java.
java -cp ddf-examples-<version>-exe.jar com.ddfplus.api.examples.ServerListenExample LISTEN_TCP|LISTEN_UDP address port [interface] [-su user] [-sp password]
where:
LISTEN_TCP|LISTEN_UDP - Specify whether the inbound packets are TCP or UDP
address - Specify the Local Address to bind to. Use 0.0.0.0 for any
port - Specify the port to bind to
interface -(Optional) Only if address is a multicast address.\n" + "")
-su user - Snapshot User Name
-sp password - Snapshot Password
This command will listen on port 10110 for inbound TCP market feed messages on any interface:
java -cp ddfplus-examples-<version>-exe.jar com.ddfplus.api.examples.ServerExample LISTEN_TCP 0.0.0.0 10110
If the refresh/snapshot user and password are set then in the background a refresh request will be sent to obtain the statistics such as (hi,low, etc..).
Create a Java project in your favorite IDE
Add src/main/java to the source directories
Add all the jars in lib to the project classpath
If you want to see the API internal logging, add a SLF7 implementation such as logback-classic-<version>.jar
The project should now build and run.
If you do not have a SL4J implementation jar you will see an error similar to the one below. The API will operate correctly just without internal logging.
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.
Please see DdfClientExample.java for a running example of using the API.
Please look at the DdfClientExample constructor for initialization.
ClientConfig config = new ClientConfig();
config.setUserName("username");
config.setPassword("password");
// Use TCP
DdfClient client = new DdfClientImpl(config);
// Init
client.init();
// Add Handlers, assuming enclosing class implements the handlers
client.addConnectionEventHandler(this);
client.addTimestampHandler(this);
client.addFeedHandler(this);
client.addMarketEventHandler(this);
// Connection
client.connect();
/* On the ConnectionEventHandler.onEvent() LOGIN_SUCESS subscribe
to symbols as desired
*/
QuoteHandler handler = new ClientQuoteHandler();
// This will request quotes if client does not have a subscription
// to the symbol
client.addQuoteHandler(symbol, handler);1. Create a ClientQuoteHandler() 2. Add to client by calling DdfClientImpl.addQuoteHandler(symbol, handler)
1. Create a ClientQuoteExchangeHandler(String exchangeCode) 2. Add to client by calling DdfClientImpl.addQuoteExchangeHandler(exchangeCode, handler)
| Back | FazBrowse Home | New Git URL |