forked from epam/java-cme-mdp3-handler
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kolybelkin/feature/mbo
MBO familiar implementation of MDP3
- Loading branch information
Showing
278 changed files
with
56,253 additions
and
8,555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1 @@ | ||
plugins { | ||
id "java" | ||
id "maven" | ||
id "java-library-distribution" | ||
id "com.github.samueltbrown.cucumber" version "0.9" | ||
id "org.sonarqube" version "2.0.1" | ||
id "me.champeau.gradle.jmh" version "0.3.0" | ||
} | ||
group = 'com.epam.cme' | ||
version = '1.0' | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
|
||
dependencies { | ||
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5' | ||
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5' | ||
runtime group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.5' | ||
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.10' | ||
runtime group: 'commons-collections', name: 'commons-collections', version: '3.2.2' | ||
compile group: 'net.openhft', name: 'chronicle-bytes', version: '1.7.17' | ||
compile group: 'net.openhft', name: 'koloboke-api-jdk8', version: '0.6.8' | ||
runtime group: 'net.openhft', name: 'koloboke-impl-jdk8', version: '0.6.8' | ||
compile group: 'net.openhft', name: 'chronicle-core', version: '1.7.6' | ||
|
||
cucumberCompile 'info.cukes:cucumber-java:1.2.4' | ||
cucumberCompile 'info.cukes:cucumber-picocontainer:1.2.4' | ||
testCompile group: 'junit', name: 'junit', version: '4.11' | ||
} | ||
|
||
distributions { | ||
main { | ||
baseName = 'b2bits-jmdp3' | ||
contents { | ||
from { 'dist' } | ||
} | ||
} | ||
} | ||
defaultTasks 'clean', 'build', 'distZip', 'distTar' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
group 'com.epam.cme' | ||
version '2.0' | ||
|
||
apply plugin: 'java' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
jar { | ||
baseName 'b2bits-jmdp3-core' | ||
} | ||
|
||
dependencies { | ||
compile group: 'net.openhft', name: 'chronicle-bytes', version: '1.7.17' | ||
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.10' | ||
runtime group: 'commons-collections', name: 'commons-collections', version: '3.2.2' | ||
testCompile group: 'junit', name: 'junit', version: '4.12' | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2004-2016 EPAM Systems | ||
* This file is part of Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.epam.cme.mdp3; | ||
|
||
public interface MdConstants { | ||
byte TOP_OF_THE_BOOK_LEVEL = 1; | ||
|
||
int LAST_MSG_SEQ_NUM_PROCESSED = 369; | ||
int SECURITY_ID = 48; | ||
int SEC_DESC_TAG = 55; | ||
int RPT_SEQ_NUM = 83; | ||
int NO_MD_ENTRIES = 268; | ||
int INCR_RFRSH_MD_ENTRY_TYPE = 269; | ||
int INCR_RFRSH_MD_ACTION = 279; | ||
int INCR_RFRSH_MD_PRICE_LEVEL = 1023; | ||
int INCR_RFRSH_MD_ENTRY_PX = 270; | ||
int INCR_RFRSH_MD_ENTRY_SIZE = 271; | ||
int INCR_RFRSH_MD_ORDER_NUM = 346; | ||
int NO_ORDER_ID_ENTRIES = 37705; | ||
int NO_CHUNKS = 37709; | ||
int CURRENT_CHUNK = 37710; | ||
int TOT_NUM_REPORTS = 911; | ||
int REFERENCE_ID = 9633; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
98 changes: 98 additions & 0 deletions
98
core/src/main/java/com/epam/cme/mdp3/core/channel/CoreChannelListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright 2004-2016 EPAM Systems | ||
* This file is part of Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.epam.cme.mdp3.core.channel; | ||
|
||
|
||
import com.epam.cme.mdp3.*; | ||
|
||
public interface CoreChannelListener { | ||
/** | ||
* Called when a Channel Feed is started. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param feedType Type of MDP Feed (e.g. snapshot or incremental) | ||
* @param feed Feed (e.g. A or B) | ||
*/ | ||
void onFeedStarted(final String channelId, final FeedType feedType, final Feed feed); | ||
|
||
/** | ||
* Called when a Channel Feed is stopped. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param feedType type of MDP Feed (e.g. snapshot or incremental) | ||
* @param feed feed (e.g. A or B) | ||
*/ | ||
void onFeedStopped(final String channelId, final FeedType feedType, final Feed feed); | ||
|
||
/** | ||
* Called when a Channel Feed received new MDP Packet. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param feedType Type of MDP Feed (e.g. snapshot or incremental) | ||
* @param feed Feed (e.g. A or B) | ||
* @param mdpPacket MDP Packet which is just received and will be handled after this callback | ||
*/ | ||
void onPacket(final String channelId, final FeedType feedType, final Feed feed, final MdpPacket mdpPacket); | ||
|
||
/** | ||
* Called when a Channel has to start its reset. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param resetMessage MDP Reset Message | ||
*/ | ||
void onBeforeChannelReset(final String channelId, final MdpMessage resetMessage); | ||
|
||
/** | ||
* Called when a Channel just finished its reset. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param resetMessage MDP Reset Message | ||
*/ | ||
void onFinishedChannelReset(final String channelId, final MdpMessage resetMessage); | ||
|
||
/** | ||
* Called when a Channel state is changed. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param prevState Previous state | ||
* @param newState New state | ||
*/ | ||
void onChannelStateChanged(final String channelId, final ChannelState prevState, final ChannelState newState); | ||
|
||
/** | ||
* Called when MDP Security Definition Message is received and processed. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param secDefMessage MDP Security Definition Message | ||
* @return Required Subscription flags | ||
* @see MdEventFlags | ||
*/ | ||
int onSecurityDefinition(final String channelId, final MdpMessage secDefMessage); | ||
|
||
/** | ||
* Called when MDP RFQ Message is received and processed. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param rfqMessage MDP TFQ Message | ||
*/ | ||
void onRequestForQuote(final String channelId, final MdpMessage rfqMessage); | ||
|
||
/** | ||
* Called when MDP Security Status Message is received and processed. | ||
* | ||
* @param channelId ID of MDP Channel | ||
* @param securityId Security ID | ||
* @param secStatusMessage MDP Security Status Message | ||
*/ | ||
void onSecurityStatus(final String channelId, final int securityId, final MdpMessage secStatusMessage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
core/src/main/java/com/epam/cme/mdp3/core/channel/MdpFeedRtmState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2004-2016 EPAM Systems | ||
* This file is part of Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.epam.cme.mdp3.core.channel; | ||
|
||
public enum MdpFeedRtmState { | ||
ACTIVE, PENDING_SHUTDOWN, SHUTDOWN, STOPPED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
core/src/main/java/com/epam/cme/mdp3/core/channel/tcp/MdpTCPChannel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2004-2016 EPAM Systems | ||
* This file is part of Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* Java Market Data Handler for CME Market Data (MDP 3.0) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with Java Market Data Handler for CME Market Data (MDP 3.0). | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.epam.cme.mdp3.core.channel.tcp; | ||
|
||
import com.epam.cme.mdp3.core.cfg.ConnectionCfg; | ||
import com.epam.cme.mdp3.core.channel.MdpFeedContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.EOFException; | ||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.SocketChannel; | ||
import java.util.List; | ||
|
||
public class MdpTCPChannel implements TCPChannel { | ||
private static final Logger logger = LoggerFactory.getLogger(MdpTCPChannel.class); | ||
private final ConnectionCfg cfg; | ||
private volatile SocketChannel socketChannel; | ||
private MdpFeedContext feedContext; | ||
|
||
public MdpTCPChannel(final ConnectionCfg cfg) { | ||
this.cfg = cfg; | ||
this.feedContext = new MdpFeedContext(cfg); | ||
} | ||
|
||
@Override | ||
public boolean connect() { | ||
List<String> hostIPs = cfg.getHostIPs(); | ||
for (String hostIP : hostIPs) { | ||
try { | ||
final InetSocketAddress inetSocketAddress = new InetSocketAddress(hostIP, cfg.getPort()); | ||
socketChannel = SocketChannel.open(inetSocketAddress); | ||
logger.debug("Connected to {}:{}", hostIP, cfg.getPort()); | ||
return true; | ||
} catch (Exception e) { | ||
logger.error("Failed to connect to {}:{}. Exception: {}", hostIP, cfg.getPort(), e.getMessage(), e); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void disconnect() { | ||
try { | ||
socketChannel.close(); | ||
} catch (IOException e) { | ||
logger.error(e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public void send(ByteBuffer bb) throws IOException { | ||
socketChannel.write(bb); | ||
} | ||
|
||
@Override | ||
public int receive(ByteBuffer bb) throws IOException { | ||
int readBytes = socketChannel.read(bb); | ||
if(readBytes < 0) { | ||
throw new EOFException("Length of last received bytes is less than zero '" + readBytes + "'"); | ||
} else { | ||
return readBytes; | ||
} | ||
} | ||
|
||
@Override | ||
public MdpFeedContext getFeedContext() { | ||
return feedContext; | ||
} | ||
} |
Oops, something went wrong.