Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 100 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Intrinio Java SDK for Real-Time Stock Prices
SDK for working with Intrinio's realtime IEX, NASDAQ Basic, delayed SIP prices, and realtime/delayed [OPRA](https://www.opraplan.com/) options feeds.
SDK for working with Intrinio's realtime IEX, NASDAQ Basic, CBOE One, delayed SIP prices, and realtime/delayed [OPRA](https://www.opraplan.com/) options feeds.

[Intrinio](https://intrinio.com/) provides real-time and delayed stock prices via a two-way WebSocket connection. To get started, [subscribe to a real-time data feed](https://docs.intrinio.com/tutorial/websocket) and follow the instructions below.

Expand Down Expand Up @@ -86,6 +86,7 @@ public record Trade(String symbol, SubProvider subProvider, char marketCenter, d
* **`OTC`** - OTC in the DELAYED_SIP provider.
* **`NASDAQ_BASIC`** - NASDAQ Basic in the NASDAQ_BASIC provider.
* **`IEX`** - From the IEX exchange in the REALTIME provider.
* **`CBOE_ONE`** - From the CBOE One exchanges provider.
* **marketCenter** - Provides the market center
* **price** - the price in USD
* **size** - the size of the last trade.
Expand All @@ -111,13 +112,110 @@ public record Quote(QuoteType type, String symbol, SubProvider subProvider, char
* **`OTC`** - OTC in the DELAYED_SIP provider.
* **`NASDAQ_BASIC`** - NASDAQ Basic in the NASDAQ_BASIC provider.
* **`IEX`** - From the IEX exchange in the REALTIME provider.
* **`CBOE_ONE`** - From the CBOE One exchanges provider.
* **marketCenter** - Provides the market center
* **symbol** - Ticker symbol.
* **price** - the price in USD
* **size** - the size of the last ask or bid).
* **timestamp** - a Unix timestamp in nanoseconds since unix epoch.
* **conditions** - Provides the conditions

### Equities Trade Conditions

| Value | Description |
|-------|---------------------------------------------------|
| @ | Regular Sale |
| A | Acquisition |
| B | Bunched Trade |
| C | Cash Sale |
| D | Distribution |
| E | Placeholder |
| F | Intermarket Sweep |
| G | Bunched Sold Trade |
| H | Priced Variation Trade |
| I | Odd Lot Trade |
| K | Rule 155 Trade (AMEX) |
| L | Sold Last |
| M | Market Center Official Close |
| N | Next Day |
| O | Opening Prints |
| P | Prior Reference Price |
| Q | Market Center Official Open |
| R | Seller |
| S | Split Trade |
| T | Form T |
| U | Extended Trading Hours (Sold Out of Sequence) |
| V | Contingent Trade |
| W | Average Price Trade |
| X | Cross/Periodic Auction Trade |
| Y | Yellow Flag Regular Trade |
| Z | Sold (Out of Sequence) |
| 1 | Stopped Stock (Regular Trade) |
| 4 | Derivatively Priced |
| 5 | Re-Opening Prints |
| 6 | Closing Prints |
| 7 | Qualified Contingent Trade (QCT) |
| 8 | Placeholder for 611 Exempt |
| 9 | Corrected Consolidated Close (Per Listing Market) |


### Equities Trade Conditions (CBOE One)
Trade conditions for CBOE One are represented as the integer representation of a bit flag.

None = 0,
UpdateHighLowConsolidated = 1,
UpdateLastConsolidated = 2,
UpdateHighLowMarketCenter = 4,
UpdateLastMarketCenter = 8,
UpdateVolumeConsolidated = 16,
OpenConsolidated = 32,
OpenMarketCenter = 64,
CloseConsolidated = 128,
CloseMarketCenter = 256,
UpdateVolumeMarketCenter = 512


### Equities Quote Conditions

| Value | Description |
|-------|---------------------------------------------|
| R | Regular |
| A | Slow on Ask |
| B | Slow on Bid |
| C | Closing |
| D | News Dissemination |
| E | Slow on Bid (LRP or Gap Quote) |
| F | Fast Trading |
| G | Trading Range Indication |
| H | Slow on Bid and Ask |
| I | Order Imbalance |
| J | Due to Related - News Dissemination |
| K | Due to Related - News Pending |
| O | Open |
| L | Closed |
| M | Volatility Trading Pause |
| N | Non-Firm Quote |
| O | Opening |
| P | News Pending |
| S | Due to Related |
| T | Resume |
| U | Slow on Bid and Ask (LRP or Gap Quote) |
| V | In View of Common |
| W | Slow on Bid and Ask (Non-Firm) |
| X | Equipment Changeover |
| Y | Sub-Penny Trading |
| Z | No Open / No Resume |
| 1 | Market Wide Circuit Breaker Level 1 |
| 2 | Market Wide Circuit Breaker Level 2 |
| 3 | Market Wide Circuit Breaker Level 3 |
| 4 | On Demand Intraday Auction |
| 45 | Additional Information Required (CTS) |
| 46 | Regulatory Concern (CTS) |
| 47 | Merger Effective |
| 49 | Corporate Action (CTS) |
| 50 | New Security Offering (CTS) |
| 51 | Intraday Indicative Value Unavailable (CTS) |

### Options Trade Message

```java
Expand Down Expand Up @@ -289,7 +387,7 @@ client.leave()
```json
{
"apiKey": "",
"provider": "REALTIME", //or DELAYED_SIP or NASDAQ_BASIC or MANUAL
"provider": "IEX", //or DELAYED_SIP or NASDAQ_BASIC or CBOE_ONE or MANUAL
"symbols": [ "AAPL", "MSFT", "GOOG" ], //This is a list of individual tickers to subscribe to, or "lobby" to subscribe to all at once (firehose).
"tradesOnly": true, //This indicates whether you only want trade events (true) or you want trade, ask, and bid events (false).
"numThreads": 4 //The number of threads to use for processing events.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.intrinio</groupId>
<artifactId>IntrinioRealtimeJavaSDK</artifactId>
<version>7.1.2</version>
<version>7.2.0</version>
<packaging>jar</packaging>
<name>IntrinioRealtimeJavaSDK</name>
<build>
Expand Down
2 changes: 1 addition & 1 deletion src/SampleApp/CompositeSampleApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void run(String[] args){

intrinio.realtime.equities.Config equitiesConfig = null;
try{
equitiesConfig = new intrinio.realtime.equities.Config(apiKey, intrinio.realtime.equities.Provider.NASDAQ_BASIC, null, new String[]{"MSFT", "NVDA", "AAPL"}, true, 4);
equitiesConfig = new intrinio.realtime.equities.Config(apiKey, intrinio.realtime.equities.Provider.NASDAQ_BASIC, null, new String[]{"MSFT", "NVDA", "AAPL"}, true, 4, false);
}catch (Exception e){
System.out.println("Error parsing equities config: " + e.getMessage());
return;
Expand Down
19 changes: 14 additions & 5 deletions src/intrinio/realtime/equities/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Client implements WebSocket.Listener {
private Thread[] processDataThreads;
private boolean isCancellationRequested = false;
private String HeaderClientInformationKey = "Client-Information";
private String HeaderClientInformationValue = "IntrinioRealtimeJavaSDKv7.1";
private String HeaderClientInformationValue = "IntrinioRealtimeJavaSDKv7.2";
private String HeaderMessageVersionKey = "UseNewEquitiesFormat";
private String HeaderMessageVersionValue = "v2";
//endregion Data Members
Expand Down Expand Up @@ -119,10 +119,14 @@ private String getAuthUrl() throws Exception {
switch (config.getEquitiesProvider()) {
case REALTIME: authUrl = "https://realtime-mx.intrinio.com/auth?api_key=" + config.getEquitiesApiKey();
break;
case IEX: authUrl = "https://realtime-mx.intrinio.com/auth?api_key=" + config.getEquitiesApiKey();
break;
case DELAYED_SIP: authUrl = "https://realtime-delayed-sip.intrinio.com/auth?api_key=" + config.getEquitiesApiKey();
break;
case NASDAQ_BASIC: authUrl = "https://realtime-nasdaq-basic.intrinio.com/auth?api_key=" + config.getEquitiesApiKey();
break;
case CBOE_ONE: authUrl = "https://cboe-one.intrinio.com/auth?api_key=" + config.getEquitiesApiKey();
break;
case MANUAL: authUrl = "http://" + config.getEquitiesIpAddress() + "/auth?api_key=" + config.getEquitiesApiKey();
break;
default: throw new Exception("Provider not specified!");
Expand All @@ -132,14 +136,19 @@ private String getAuthUrl() throws Exception {

private String getWebSocketUrl (String token) throws Exception {
String wsUrl;
String delayedPart = config.isEquitiesDelayed() ? "&delayed=true" : "";
switch (config.getEquitiesProvider()) {
case REALTIME: wsUrl = "wss://realtime-mx.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token;
case REALTIME: wsUrl = "wss://realtime-mx.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
case IEX: wsUrl = "wss://realtime-mx.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
case DELAYED_SIP: wsUrl = "wss://realtime-delayed-sip.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
case DELAYED_SIP: wsUrl = "wss://realtime-delayed-sip.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token;
case NASDAQ_BASIC: wsUrl = "wss://realtime-nasdaq-basic.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
case NASDAQ_BASIC: wsUrl = "wss://realtime-nasdaq-basic.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token;
case CBOE_ONE: wsUrl = "wss://cboe-one.intrinio.com/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
case MANUAL: wsUrl = "ws://" + config.getEquitiesIpAddress() + "/socket/websocket?vsn=1.0.0&token=" + token;
case MANUAL: wsUrl = "ws://" + config.getEquitiesIpAddress() + "/socket/websocket?vsn=1.0.0&token=" + token + delayedPart;
break;
default: throw new Exception("Provider not specified!");
}
Expand Down
9 changes: 8 additions & 1 deletion src/intrinio/realtime/equities/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ public class Config {
private String equitiesIpAddress;
private String[] equitiesSymbols;
private boolean equitiesTradesOnly = true;
private boolean equitiesDelayed = false;
private int equitiesNumThreads = 4;

public Config(String equitiesApiKey, Provider equitiesProvider, String equitiesIpAddress, String[] equitiesSymbols, boolean equitiesTradesOnly, int equitiesNumThreads) throws Exception {
public Config(String equitiesApiKey, Provider equitiesProvider, String equitiesIpAddress, String[] equitiesSymbols, boolean equitiesTradesOnly, int equitiesNumThreads, boolean equitiesDelayed) throws Exception {
this.equitiesApiKey = equitiesApiKey;
this.equitiesProvider = equitiesProvider;
this.equitiesIpAddress = equitiesIpAddress;
this.equitiesSymbols = equitiesSymbols;
this.equitiesTradesOnly = equitiesTradesOnly;
this.equitiesDelayed = equitiesDelayed;
this.equitiesNumThreads = equitiesNumThreads;

if (this.equitiesApiKey.isBlank()) {
Expand Down Expand Up @@ -56,6 +58,10 @@ public boolean isEquitiesTradesOnly() {
return equitiesTradesOnly;
}

public boolean isEquitiesDelayed() {
return equitiesDelayed;
}

public int getEquitiesNumThreads() {
return equitiesNumThreads;
}
Expand All @@ -67,6 +73,7 @@ public String toString() {
this.equitiesIpAddress,
String.join(", ", this.equitiesSymbols),
this.equitiesTradesOnly,
this.equitiesDelayed,
this.equitiesNumThreads);
}

Expand Down
6 changes: 4 additions & 2 deletions src/intrinio/realtime/equities/Provider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

public enum Provider {
NONE,
REALTIME,
REALTIME, //Equivalent to IEX
MANUAL,
DELAYED_SIP,
NASDAQ_BASIC
NASDAQ_BASIC,
CBOE_ONE,
IEX
}
3 changes: 2 additions & 1 deletion src/intrinio/realtime/equities/SubProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public enum SubProvider {
UTP,
OTC,
NASDAQ_BASIC,
IEX
IEX,
CBOE_ONE
}
4 changes: 4 additions & 0 deletions src/intrinio/realtime/equities/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static Trade parse(byte[] bytes) {
break;
case 6: subProvider = SubProvider.IEX;
break;
case 7: subProvider = SubProvider.CBOE_ONE;
break;
default: subProvider = SubProvider.IEX;
}

Expand Down Expand Up @@ -119,6 +121,8 @@ public static Trade parse(ByteBuffer bytes) {
break;
case 6: source = SubProvider.IEX;
break;
case 7: source = SubProvider.CBOE_ONE;
break;
default: source = SubProvider.IEX;
}

Expand Down
5 changes: 3 additions & 2 deletions src/intrinio/realtime/equities/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"equitiesApiKey": "",
"equitiesProvider": "REALTIME",
"equitiesProvider": "IEX",
"equitiesSymbols": [ "GOOG", "MSFT", "AAPL" ],
"equitiesTradesOnly": false,
"equitiesNumThreads": 2
"equitiesNumThreads": 2,
"equitiesDelayed": false
}
2 changes: 1 addition & 1 deletion src/intrinio/realtime/options/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Client implements WebSocket.Listener {
private final Lock dataBucketLock = new ReentrantLock();
private final LinkedBlockingDeque<Tuple<byte[], Boolean>> dataBucket = new LinkedBlockingDeque<Tuple<byte[], Boolean>>();
private final WebSocketState wsState = new WebSocketState();
private final String Version = "IntrinioRealtimeOptionsJavaSDKv7.1";
private final String Version = "IntrinioRealtimeOptionsJavaSDKv7.2";
//endregion Final data members

//region Data Members
Expand Down
Loading