<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coral Blocks &#187; CoralMD</title>
	<atom:link href="https://www.coralblocks.com/index.php/category/coralmarketdata/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.coralblocks.com/index.php</link>
	<description>Building amazing software, one piece at a time.</description>
	<lastBuildDate>Sat, 25 Apr 2026 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Real-time Bitcoin Market Data</title>
		<link>https://www.coralblocks.com/index.php/free-real-time-bitcoin-market-data/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=free-real-time-bitcoin-market-data</link>
		<comments>https://www.coralblocks.com/index.php/free-real-time-bitcoin-market-data/#comments</comments>
		<pubDate>Fri, 16 Oct 2015 16:23:24 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[CoralMD]]></category>
		<category><![CDATA[bitcoin]]></category>
		<category><![CDATA[coralmd]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[free market data]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[market data]]></category>
		<category><![CDATA[md]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1754</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>To illustrate <a href="/index.php/category/coralmarketdata/" target="_blank">CoralMD</a>, we launched a free server that provides aggregated and per exchange real-time Bitcoin market data. The exchanges we are currently connected to are: <a href="http://www.coinbase.com" target="_blank">Coinbase</a> and <a href="http://www.okcoin.com" target="_blank">Okcoin</a>. Below we explain the three choices of API and protocol you can use to receive live market data updates. <span id="more-1754"></span></p>
<h3 class="coral">HTTP</h3>
<p>Browsers and other http clients can make requests to the URLs below to get a full market data book snapshot in JSON format. The server caches the response for 2 seconds, so any successive requests less than 2 seconds apart will return the same data. This is enough for GUIs and other higher-latency applications. For low-latency real-time updates you should use the TCP or the FIX API.<br />

<style>
.li_urls { margin: 0 0 20px 0; }
</style>
</p>
<p><!-- ul></p>
<li class="li_urls"><font color="#26619b"><strong>Aggregated:</strong></font> <a href="http://www.coralblocks.com:45453/book/BTC-USD" target="_blank">http://www.coralblocks.com:45453/book/BTC-USD</a></li>
<li class="li_urls"><font color="#26619b"><strong>Coinbase:</strong></font> <a href="http://www.coralblocks.com:45453/book/BTC-USD?exchange=BASE" target="_blank">http://www.coralblocks.com:45453/book/BTC-USD?exchange=BASE</a></li>
<li class="li_urls"><font color="#26619b"><strong>Okcoin:</strong></font> <a href="http://www.coralblocks.com:45453/book/BTC-USD?exchange=OKCN" target="_blank">http://www.coralblocks.com:45453/book/BTC-USD?exchange=OKCN</a></li>
</ul -->
<pre>
{
    "success":			true,
    "last updated":		"20151022-03:28:18.676",
    "time zone":		"America/New_York",
    "symbol":			"BTC-USD",
    "exchange code":		"AGGR",
    "exchange name":		"Aggregated",
    "spread":			-2.06,
    "best bid size":		0.02000000,
    "best bid price":		270.60,
    "best ask size":		0.90000000,
    "best ask price":		268.54,

    "bids": [

        [ "BASE",		0.02000000,		270.60],
        [ "BASE",		0.02000000,		270.59],
        [ "BASE",		0.02000000,		270.58],
        ...
    ],

    "asks": [

        [ "OKCN",		0.90000000,		268.54],
        [ "OKCN",		0.86100000,		268.58],
        [ "OKCN",		2.34470000,		268.60],
        ...
    ]
}
</pre>
<p><br/></p>
<h3 class="coral">FIX</h3>
<p>We use FIX version 4.4. The standard FIX header (i.e. <em>BeginString</em>, <em>MsgType</em>, <em>MsgSeqNum</em>, <em>SenderCompID</em> and <em>SendingTime</em>) must be present in every message. The <em>SenderCompID</em> is your username. <a href="/index.php/product-support" target="_blank">Click here to contact us</a> and get the host, port, username and password to connect. Messages not specified below (i.e. <em>Heartbeat</em>, <em>Test Request</em>, etc.) follow the standard FIX format.</p>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">


<style>
pre {
    white-space: pre-wrap; 
    word-break: normal;
}
</style>

  <table class="table">
    <thead>
      <th>Message</th>
      <th>Short Description</th>
    </thead>
    <tbody>
      <tr>
        <td>
          <a data-toggle="collapse" href="#logonCollapse" aria-expanded="false" aria-controls="logonCollapse">
          <p><i class="fa fa-caret-right"></i> Logon ('A')</p></a>
        </td>
        <td><p>To start a FIX session</p></td>
      </tr>
      <tr id="logonCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>You use the <em>Logon</em> message to start a FIX session with the server. The server will reply with a <em>Logon</em> message to indicate that the logon was successful or with a <em>Logout</em> message to indicate that there was a problem with the logon.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>98</td>
                <td>EncryptMethod</td>
                <td>Must always be '0'</td>
              </tr>
              <tr>
                <td>108</td>
                <td>HeartBtInt</td>
                <td>The heartbeat interval in seconds. '30' is a good value.</td>
              </tr>
              <tr>
                <td>553</td>
                <td>Username</td>
                <td>Your username. <a href="/index.php/product-support" target="_blank">Contact Coral Blocks to get one</a>.</td>
              </tr>
              <tr>
                <td>554</td>
                <td>Password</td>
                <td>Your password. <a href="/index.php/product-support" target="_blank">Contact Coral Blocks to get one</a>.</td>
              </tr>
              <tr>
                <td>141</td>
                <td>ResetSeqNumFlag</td>
                <td>Should always be 'Y' to reset the sequences on every new logon.</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#logoutCollapse" aria-expanded="false" aria-controls="logoutCollapse">
          <p><i class="fa fa-caret-right"></i> Logout ('5')</p></a>
        </td>
        <td><p>To end a FIX session</p></td>
      </tr>
      <tr id="logoutCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <em>Logout</em> message can be sent by the client to gracefully disconnect or it can be sent by the server to indicate that a logon attempt was not successful. In that case you should check the <i>Text</i> tag for clues.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>58</td>
                <td>Text</td>
                <td>A description of why the <i>Logon</i> from the client was not accepted (when coming from server)</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>

      <tr>
        <td>
          <a data-toggle="collapse" href="#mdrCollapse" aria-expanded="false" aria-controls="mdrCollapse">
          <p><i class="fa fa-caret-right"></i> MarketDataRequest ('V')</p></a>
        </td>
        <td><p>To subscribe to market data</p></td>
      </tr>
      <tr id="mdrCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <em>MarketDataRequest</em> message can be sent by the client to subscribe to market data. The server supports subscription to all securities or individual subscriptions. The client can also use this message to unsubscribe. If the subscription is successful, the client will receive a <i>MarketDataSnapshotFullRefresh</i> with the book. When unsubscribing, the client will receive a <i>MarketDataSnapshotFullRefresh</i> with an empty book if successful.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>262</td>
                <td>MDReqID</td>
                <td>An identifier number for this request (will be sent back with the <i>MarketDataSnapshotFullRefresh</i> response)</td>
              </tr>
              <tr>
                <td>263</td>
                <td>SubscriptionRequestType</td>
                <td>'A' - subscribe to all<br/>'X' - unsubscribe from all<br/>'S' - subscribe to a single symbol<br/>'U' - unsubscribe from a single symbol</td>
              </tr>
              <tr>
                <td>55</td>
                <td>Symbol</td>
                <td>Required when <i>SubscriptionRequestType</i> above is 'S' or 'U'</td>
              </tr>
            </tbody>
          </table>
          <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#mdjCollapse" aria-expanded="false" aria-controls="mdjCollapse">
          <p><i class="fa fa-caret-right"></i> MarketDataRequestReject ('Y')</p></a>
        </td>
        <td><p>To subscribe to market data</p></td>
      </tr>
      <tr id="mdjCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <em>MarketDataRequestReject</em> message is sent back by the server when it cannot process the <i>MarketDataRequest</i> sent by the client. It contains the reason why the request was rejected.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>262</td>
                <td>MDReqID</td>
                <td>The identifier number used in the <i>MarketDataRequest</i></td>
              </tr>
              <tr>
                <td>281</td>
                <td>MDReqRejReason</td>
                <td>'0' - Tag Missing<br/>'1' - You are already subscribed to all<br/>'2' - No book for requested symbol<br/>'3' - Invalid <i>SubscriptionRequestType</i> tag value</td>
              </tr>
              <tr>
                <td>58</td>
                <td>Text</td>
                <td>A text description with more details about the reject reason</td>
              </tr>
            </tbody>
          </table>
          <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#mdsCollapse" aria-expanded="false" aria-controls="mdsCollapse">
          <p><i class="fa fa-caret-right"></i> MarketDataSnapshotFullRefresh ('W')</p></a>
        </td>
        <td><p>Provides the full view of a market data book, with all open orders</p></td>
      </tr>
      <tr id="mdsCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <em>MarketDataSnapshotFullRefresh</em> message is sent by the server to provide the full market data book for a security. The server sends only one <i>MarketDataSnapshotFullRefresh</i> per symbol, never two symbols in the same message. This message is only sent as a response for a <i>MarketDataRequest</i> message. When processing this message, the client should clear his book before adding the orders.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>262</td>
                <td>MDReqID</td>
                <td>The identifier number that was sent with the <i>MarketDataRequest</i></td>
              </tr>
              <tr>
                <td>55</td>
                <td>Symbol</td>
                <td>Required when <i>SubscriptionRequestType</i> from the <i>MarketDataRequest</i> was 'S' or 'U'</td>
              </tr>
              <tr>
                <td>268</td>
                <td>NoMDEntries</td>
                <td>The number of entries for the repeating group containing the orders</td>
              </tr>
              <tr>
                <td>=> 279</td>
                <td>MDUpdateAction</td>
                <td>'0' - Order added (always)</td>
              </tr>
              <tr>
                <td>=> 54</td>
                <td>Side</td>
                <td>'1' - Bid<br/>'2' - Ask</td>
              </tr>
              <tr>
                <td>=> 5001</td>
                <td>FeedID</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>=> 5002</td>
                <td>ExchangeID</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>=> 5003</td>
                <td>Timestamp</td>
                <td>The epoch timestamp in milliseconds</td>
              </tr>
              <tr>
                <td>=> 278</td>
                <td>MDEntryID</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>=> 271</td>
                <td>MDEntrySize</td>
                <td>The size of the order</td>
              </tr>
              <tr>
                <td>=> 270</td>
                <td>MDEntryPx</td>
                <td>The price of the order</td>
              </tr>
              <tr>
                <td>=> 270</td>
                <td>MDEntryPx</td>
                <td>The price of the order</td>
              </tr>
              <tr>
                <td>=> 5004</td>
                <td>Ownership</td>
                <td>'Y' - The order is mine<br/>'N' - The order is not mine or it can't be determined at this point</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#mdiCollapse" aria-expanded="false" aria-controls="mdiCollapse">
          <p><i class="fa fa-caret-right"></i> MarketDataIncrementalRefresh ('X')</p></a>
        </td>
        <td><p>Provides incremental updates for subscribed market data books</p></td>
      </tr>
      <tr id="mdiCollapse" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <em>MarketDataIncrementalRefresh</em> message is sent by the server to provide incremental updates for subscribed securities. Updates for more than one symbol can come on the same message. It is also used to indicate a live trade and to signal that a book for a security should be cleared.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Tag</th>
              <th>Name</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>268</td>
                <td>NoMDEntries</td>
                <td>The number of entries for the repeating group containing the updates</td>
              </tr>
              <tr>
                <td>=> 279</td>
                <td>MDUpdateAction</td>
                <td>'0' - Order added<br/>'1' - Order modified<br/>'2' - Order removed<br/>'O' - Order owned<br/>'T' - Live Trade (will not contain the <em>Side</em> and the <em>MDEntryID</em>)<br/>'C' - Book cleared (will only contain the <em>FeedID</em>, <em>ExchangeID</em> (optionally) and <em>Symbol</em>)</td>
              </tr>
              <tr>
                <td>=> 54</td>
                <td>Side</td>
                <td>'1' - Bid<br/>'2' - Ask</td>
              </tr>
              <tr>
                <td>=> 55</td>
                <td>Symbol</td>
                <td>The symbol of this update</td>
              </tr>
              <tr>
                <td>=> 5001</td>
                <td>FeedID</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>=> 5002</td>
                <td>ExchangeID</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>=> 5003</td>
                <td>Timestamp</td>
                <td>The epoch timestamp in milliseconds (not sent for <i>MDUpdateAction</i> 'C' and 'O')</td>
              </tr>
              <tr>
                <td>=> 278</td>
                <td>MDEntryID</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>=> 271</td>
                <td>MDEntrySize</td>
                <td>The size of the order (not sent for <i>MDUpdateAction</i> '2', 'C' and 'O')</td>
              </tr>
              <tr>
                <td>=> 270</td>
                <td>MDEntryPx</td>
                <td>The price of the order (not sent for <i>MDUpdateAction</i> '2', 'C' and 'O')</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


    </tbody>
  </table>
</p>
<h3 style="margin-top: 40px !important;" class="coral">TCP</h3>
<p>For low-latency you should use our TCP API which is shorter and faster than FIX. It uses a <i>byte-payload</i> protocol where the first byte contains the size of the payload that follows. All binary numbers follow the <i>big-endian</i> network format. If you are using Java, you can use the <code>ByteBuffer</code> methods <i>getShort</i> (2 bytes), <i>getInt</i> (4 bytes) and <i>getLong</i> (8 bytes) to read binary numbers. The &#8220;Z&#8221; message (batch end) is always sent after previous update messages to denote that a full batch update has been sent by the server. That way the client might choose to take action only after a full batch has been received instead of taking action on individual updates. (Note: For FIX you can assume that each <i>MarketDataIncrementalRefresh</i> message contains a batch)</p>


  <table class="table">
    <thead>
      <th>Message</th>
      <th>Short Description</th>
    </thead>
    <tbody>

      <tr>
        <td>
          <a data-toggle="collapse" href="#logonCollapseT" aria-expanded="false" aria-controls="logonCollapseT">
          <p><i class="fa fa-caret-right"></i> Login ('L')</p></a>
        </td>
        <td><p>To login to the server</p></td>
      </tr>
      <tr id="logonCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The <i>Login</i> message must be the first message sent by the client to the server upon connection. It provides username, password and the heartbeat interval the client wants to configure. The server will reply with an 'L' message back (without any fields) to indicate that the login was successful.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'L'</td>
              </tr>
              <tr>
                <td>Heartbeat</td>
                <td>4 (int)</td>
                <td>The heartbeat interval in seconds the client wants to configure</td>
              </tr>
              <tr>
                <td>Username</td>
                <td>12 (ascii)</td>
                <td>Your username. <a href="/index.php/product-support" target="_blank">Contact Coral Blocks to get one</a>.</td>
              </tr>
              <tr>
                <td>Password</td>
                <td>12 (ascii)</td>
                <td>Your password. <a href="/index.php/product-support" target="_blank">Contact Coral Blocks to get one</a>.</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#errorCollapseT" aria-expanded="false" aria-controls="errorCollapseT">
          <p><i class="fa fa-caret-right"></i> Error ('E')</p></a>
        </td>
        <td><p>Sent by the server to indicate that an error happened</p></td>
      </tr>
      <tr id="errorCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server can send an error message to indicate any error condition like for example if the client can't be authenticated. It contains a text message with the details about the error. The text field does not have a fixed length. Its length will be the remaining of the message.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'E'</td>
              </tr>
              <tr>
                <td>Text</td>
                <td>remaining (ascii)</td>
                <td>A text message with the details of the error</td>
              </tr>
              
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#aCollapseT" aria-expanded="false" aria-controls="aCollapseT">
          <p><i class="fa fa-caret-right"></i> SubscribeAll ('A')</p></a>
        </td>
        <td><p>Message to subscribe to all symbols</p></td>
      </tr>
      <tr id="aCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The client sends a <i>SubscribeAll</i> message to receive updates for all books. The server will reply with another 'A' message back if the subscription was successful. The client will receive all open orders from all books immediately after subscribing to all, so it should clear its books before sending this message. (Note: The subscription confirmation ('A' back) is sent by the server only after all orders are resent to the client)
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'A'</td>
              </tr>
              
            </tbody>
          </table>
           <br/>
        </td>
      </tr>

      <tr>
        <td>
          <a data-toggle="collapse" href="#xCollapseT" aria-expanded="false" aria-controls="xCollapseT">
          <p><i class="fa fa-caret-right"></i> UnsubscribeAll ('X')</p></a>
        </td>
        <td><p>Message to unsubscribe from all symbols</p></td>
      </tr>
      <tr id="xCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The client sends an <i>UnsubscribeAll</i> message to stop receiving updates for all books. The server will reply with another 'X' message back if the unsubscribe request was successful. The client should clear all its books after receiving the unsubscribe confirmation back from the server.
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'X'</td>
              </tr>
              
            </tbody>
          </table>
           <br/>
        </td>
      </tr>

      <tr>
        <td>
          <a data-toggle="collapse" href="#sCollapseT" aria-expanded="false" aria-controls="sCollapseT">
          <p><i class="fa fa-caret-right"></i> Subscribe ('S')</p></a>
        </td>
        <td><p>Message to subscribe to a symbol</p></td>
      </tr>
      <tr id="sCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The client sends a <i>Subscribe</i> message to subscribe for updates for a single symbol. The server will reply with another 'S' message back if the subscription was successful. The client will receive all open orders for the requested symbol immediately after sending the subscription, so it should clear its book before sending this message. (Note: The subscription confirmation ('S' back) is sent by the server only after all orders for the symbol are resent to the client)
          </pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'S'</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to subscribe</td>
              </tr>
              
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#uCollapseT" aria-expanded="false" aria-controls="uCollapseT">
          <p><i class="fa fa-caret-right"></i> Unsubscribe ('U')</p></a>
        </td>
        <td><p>Message to unsubscribe from a symbol</p></td>
      </tr>
      <tr id="uCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The client sends an <i>Unsubscribe</i> message to stop receiving updates for the provided symbol. The server will reply with another 'U' message back if the unsubscribe request was successful. The client should clear the book for the symbol after receiving the unsubscribe confirmation back from the server.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'U'</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to subscribe</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>



      <tr>
        <td>
          <a data-toggle="collapse" href="#hCollapseT" aria-expanded="false" aria-controls="hCollapseT">
          <p><i class="fa fa-caret-right"></i> Heartbeat ('H')</p></a>
        </td>
        <td><p>Heartbeat to keep the connection alive</p></td>
      </tr>
      <tr id="hCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The client should send a heartbeat message after a period of inactivity, in other words, after a period of silence when it hasn't sent any messages to the server. The heartbeat period is configured in the <i>Login</i> message. If the server does not receive any message after the heartbeat interval it disconnects the client due to a read timeout. The server also sends heartbeats to the client.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'H'</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#nCollapseT" aria-expanded="false" aria-controls="nCollapseT">
          <p><i class="fa fa-caret-right"></i> NewOrder ('N')</p></a>
        </td>
        <td><p>New order added to the book</p></td>
      </tr>
      <tr id="nCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>NewOrder</i> message to indicate that a new order was added to the book.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'N'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td>8 (long)</td>
                <td>The epoch timestamp in milliseconds</td>
              </tr>
              <tr>
                <td>OrderID</td>
                <td>8 (long)</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>Side</td>
                <td>1 (ascii)</td>
                <td>'B' - Bid<br/>'A' - Ask</td>
              </tr>
              <tr>
                <td>Size</td>
                <td>8 (long)</td>
                <td>The order size. <strong>Must be divided by 100,000,000</strong> for the decimal size</td>
              </tr>
              <tr>
                <td>Price</td>
                <td>8 (long)</td>
                <td>The order price. <strong>Must be divided by 100,000,000</strong> for the decimal price</td>
              </tr>
              <tr>
                <td>Ownership</td>
                <td>1 (ascii)</td>
                <td>'Y' - The order is mine<br/>'N' - The order is not mine or it can't be determined at this point</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to where this order belongs</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#oCollapseT" aria-expanded="false" aria-controls="oCollapseT">
          <p><i class="fa fa-caret-right"></i> OwnOrder ('O')</p></a>
        </td>
        <td><p>This order should now be marked as mine</p></td>
      </tr>
      <tr id="oCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>OwnOrder</i> message to indicate that this order should be marked as mine.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'N'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>OrderID</td>
                <td>8 (long)</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>Side</td>
                <td>1 (ascii)</td>
                <td>'B' - Bid<br/>'A' - Ask</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to where this order belongs</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#mCollapseT" aria-expanded="false" aria-controls="mCollapseT">
          <p><i class="fa fa-caret-right"></i> ModifyOrder ('M')</p></a>
        </td>
        <td><p>An existing order was modified</p></td>
      </tr>
      <tr id="mCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>ModifyOrder</i> message to indicate that an order was modified and should be updated in the client book. This message has the same format as the <i>NewOrder</i> message, with a different type ('M' instead of 'N').
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'M'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td>8 (long)</td>
                <td>The epoch timestamp in milliseconds</td>
              </tr>
              <tr>
                <td>OrderID</td>
                <td>8 (long)</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>Side</td>
                <td>1 (ascii)</td>
                <td>'B' - Bid<br/>'A' - Ask</td>
              </tr>
              <tr>
                <td>Size</td>
                <td>8 (long)</td>
                <td>The order size. <strong>Must be divided by 100,000,000</strong> for the decimal size</td>
              </tr>
              <tr>
                <td>Price</td>
                <td>8 (long)</td>
                <td>The order price. <strong>Must be divided by 100,000,000</strong> for the decimal price</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to where this order belongs</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>



      <tr>
        <td>
          <a data-toggle="collapse" href="#rCollapseT" aria-expanded="false" aria-controls="rCollapseT">
          <p><i class="fa fa-caret-right"></i> RemoveOrder ('R')</p></a>
        </td>
        <td><p>An existing order was removed from the book</p></td>
      </tr>
      <tr id="rCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>RemoveOrder</i> message to indicate that an order was deleted and should be removed from the client book.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'R'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that originated this order<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td>8 (long)</td>
                <td>The epoch timestamp in milliseconds</td>
              </tr>
              <tr>
                <td>OrderID</td>
                <td>8 (long)</td>
                <td>The order id number</td>
              </tr>
              <tr>
                <td>Side</td>
                <td>1 (ascii)</td>
                <td>'B' - Bid<br/>'A' - Ask</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol to where this order belongs</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>



      <tr>
        <td>
          <a data-toggle="collapse" href="#zCollapseT" aria-expanded="false" aria-controls="zCollapseT">
          <p><i class="fa fa-caret-right"></i> BatchEnd ('Z')</p></a>
        </td>
        <td><p>A batch of order changes is completed</p></td>
      </tr>
      <tr id="zCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>BatchEnd</i> message to indicate that it has sent a full batch of book changes. The client might want to take action only after a full batch has been received instead of taking action on each individual book update. A client can assume that it will always receive a 'Z' message after one or more book update messages.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'Z'</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#tCollapseT" aria-expanded="false" aria-controls="tCollapseT">
          <p><i class="fa fa-caret-right"></i> LiveTrade ('T')</p></a>
        </td>
        <td><p>A trade happened</p></td>
      </tr>
      <tr id="tCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>LiveTrade</i> message to indicate that a trade in one of the exchanges has occured.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'T'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that originated this trade<br/>(currently each exchange is coming from only one feed, so we have four different feeds, one for each exchange)</td>
              </tr>
              <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>"BASE" - Coinbase<br/>"OKCN" - Okcon<br/>"SETR" - Coinsetter<br/>"LAKE" - LakeBTC</td>
              </tr>
              <tr>
                <td>Timestamp</td>
                <td>8 (long)</td>
                <td>The epoch timestamp in milliseconds</td>
              </tr>
              <tr>
                <td>Size</td>
                <td>8 (long)</td>
                <td>The trade size. <strong>Must be divided by 100,000,000</strong> for the decimal size</td>
              </tr>
              <tr>
                <td>Price</td>
                <td>8 (long)</td>
                <td>The trade price. <strong>Must be divided by 100,000,000</strong> for the decimal price</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol that was traded</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#kCollapseT" aria-expanded="false" aria-controls="kCollapseT">
          <p><i class="fa fa-caret-right"></i> ClearBook ('K')</p></a>
        </td>
        <td><p>Clear the book for this feed ID</p></td>
      </tr>
      <tr id="kCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>ClearBook</i> message to indicate that the client should clear all orders belonging to this feed ID for the given symbol.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'K'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that needs to be cleared</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol that needs to be cleared</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>


      <tr>
        <td>
          <a data-toggle="collapse" href="#cCollapseT" aria-expanded="false" aria-controls="cCollapseT">
          <p><i class="fa fa-caret-right"></i> ClearBookByExchange ('C')</p></a>
        </td>
        <td><p>Clear the book for this feed ID and exchange ID</p></td>
      </tr>
      <tr id="cCollapseT" class="collapse">
        <td colspan="2">
          <h4>Description</h4>
          <pre>The server sends a <i>ClearBookByExchange</i> message to indicate that the client should clear all orders belonging to this feed ID and exchange ID for the given symbol.
</pre>
<br/>
          <h4>Format</h4>
          <table class="table">
            <thead>
              <th>Name</th>
              <th>Size</th>
              <th>Description</th>
            </thead>
            <tbody>
              <tr>
                <td>Type</td>
                <td>1 (ascii)</td>
                <td>'C'</td>
              </tr>
              <tr>
                <td>FeedID</td>
                <td>4 (int)</td>
                <td>The id number of the feed that needs to be cleared</td>
              </tr>
             <tr>
                <td>ExchangeID</td>
                <td>4 (ascii)</td>
                <td>The exchange that needs to be cleared</td>
              </tr>
              <tr>
                <td>Symbol</td>
                <td>remaining (ascii)</td>
                <td>The symbol that needs to be cleared</td>
              </tr>
            </tbody>
          </table>
           <br/>
        </td>
      </tr>



    </tbody>
  </table>

]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/free-real-time-bitcoin-market-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a Bitcoin Liquidity Aggregator with CoralMD</title>
		<link>https://www.coralblocks.com/index.php/writing-a-bitcoin-liquidity-aggregator-with-coralmd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=writing-a-bitcoin-liquidity-aggregator-with-coralmd</link>
		<comments>https://www.coralblocks.com/index.php/writing-a-bitcoin-liquidity-aggregator-with-coralmd/#comments</comments>
		<pubDate>Fri, 16 Oct 2015 16:25:00 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[CoralMD]]></category>
		<category><![CDATA[aggregator]]></category>
		<category><![CDATA[bitcoin]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[liquidity]]></category>
		<category><![CDATA[liquidity aggregator]]></category>
		<category><![CDATA[market data]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1739</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In this article we explore how we used CoralMD to write a <em>liquidity aggregator</em> for the Bitcoin market. Most importantly, we show how you can distribute market data to internal applications and to external clients using straightforward and efficient APIs over standard protocols. CoralMD supports three market data APIs on top of HTTP, TCP and FIX as you will see below. <span id="more-1739"></span><br />
<br/></p>
<h3 class="coral">Aggregated Book</h3>
<p>When you write and run multiple market data feeds, CoralMD automatically and transparently aggregates the quotes from all feeds inside the security market data book. See the example below:</p>
<pre class="brush: java; title: ; notranslate">
Security sec = Security.get(&quot;BTC-USD&quot;);

NioReactor nio = NioReactor.create();

Feed coinbase = CoinbaseFeed.create(nio, 1);
Feed okcoin = OkcoinFeed.create(nio, 2);
Feed lakebtc = LakeBtcFeed.create(nio, 3);
Feed coinsetter = CoinsetterFeed.create(nio, 4);

coinbase.subscribe(sec);
okcoin.subscribe(sec);
lakebtc.subscribe(sec);
coinsetter.subscribe(sec);

coinbase.open();
okcoin.open();
lakebtc.open();
coinsetter.open();

nio.start();
</pre>
<p><br/></p>
<p>Now you have access to the following market data books:</p>
<pre class="brush: java; title: ; notranslate">
Security sec = Security.get(&quot;BTC-USD&quot;);

Book aggregated = Book.get(sec); // aggregated book with quotes from all feeds

Book coinbase = Book.get(sec, CoinbaseFeed.EXCHANGE_ID); // book with quotes coming only from Coinbase exchange

Book okcoin = Book.get(sec, OkcoinFeed.EXCHANGE_ID); // book with quotes coming only from Okcoin exchange
</pre>
<p><br/></p>
<p>You can also display the market data book using the <code>com.coralblocks.coralmd.BookViewer</code> class, as the example below shows:</p>
<pre class="brush: java; title: ; notranslate">
Security sec = Security.get(&quot;BTC-USD&quot;);
Book aggregated = Book.get(sec);

BookViewer bookViewer = new BookViewer(nio, aggregated);
bookViewer.start();
</pre>
<p><br/><br />
In your terminal you see:<br />
<a href="http://www.coralblocks.com/wp-content/uploads/2015/10/aggregated.png"><img src="http://www.coralblocks.com/wp-content/uploads/2015/10/aggregated.png" alt="aggregated" width="668" height="603" class="alignnone size-full wp-image-1745" /></a><br />
<br/></p>
<h3 class="coral">Market Data over HTTP</h3>
<p>CoralMD comes with a <code>MarketDataHttpServer</code> that you can use to serve your market data to http clients. Below how you launch the server:</p>
<pre class="brush: java; title: ; notranslate">
MapConfiguration config = new MapConfiguration();
config.add(&quot;priceDecimals&quot;, 2);

Server httpServer = new MarketDataHttpServer(nio, 45453, config);
httpServer.open();
</pre>
<p><br/></p>
<h3 class="coral">Market Data over TCP</h3>
<p>For a fast, clean, efficient and simple binary protocol, you can use <code>MarketDataTcpServer</code>. <a href="/index.php/2015/10/free-real-time-bitcoin-market-data/" target="_blank">Click here</a> to check the message specification and to learn how to write your own TCP client that can get access to live Bitcoin market data from our servers. Below how you would launch a TCP server with CoralMD:</p>
<pre class="brush: java; title: ; notranslate">
Server tcpServer = new MarketDataTcpServer(nio, 45454);
tcpServer.open();
</pre>
<p><br/></p>
<h3 class="coral">Market Data over FIX</h3>
<p>To use the standard FIX protocol, you can launch CoralMD&#8217;s <code>MarketDataFixServer</code>. <a href="/index.php/2015/10/free-real-time-bitcoin-market-data/" target="_blank">Click here</a> to check the FIX message specification and to learn how to write your own FIX client that can get access to live Bitcoin market data from our FIX servers. Below how you would launch the FIX server with CoralMD:</p>
<pre class="brush: java; title: ; notranslate">
Server fixServer = new MarketDataFixServer(nio, 45455);
fixServer.open();
</pre>
<p><br/></p>
<h3 class="coral">Conclusion</h3>
<p>CoralMD makes it very easy to aggregate market data from multiple sources (i.e. feeds) and to serve them internally or externally through simple and efficient HTTP, TCP and FIX APIs.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/writing-a-bitcoin-liquidity-aggregator-with-coralmd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tick-to-Trade Latency Numbers using CoralMD and CoralGateway</title>
		<link>https://www.coralblocks.com/index.php/tick-to-trade-latency-numbers-using-coralmd-and-coralgateway/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tick-to-trade-latency-numbers-using-coralmd-and-coralgateway</link>
		<comments>https://www.coralblocks.com/index.php/tick-to-trade-latency-numbers-using-coralmd-and-coralgateway/#comments</comments>
		<pubDate>Wed, 02 Sep 2015 04:05:39 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[CoralGateway]]></category>
		<category><![CDATA[CoralMD]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[coralgateway]]></category>
		<category><![CDATA[coralmd]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[strategy]]></category>
		<category><![CDATA[trading]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1598</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In a <a href="/index.php/2015/08/tick-to-trade-latency-numbers-using-coralfix-and-coralreactor/" target="_blank">previous article</a> we measured the tick-to-trade latency using CoralFIX and CoralReactor. In this article we use wireshark and tcpdump to analyze the latency numbers of a test trading strategy that receives a market data tick through UDP using CoralMD and places a trade order through FIX using CoralGateway. <span id="more-1598"></span></p>
<h3 class="coral">Test Details</h3>
<p>A pseudo market data generator sends UDP packets containing market data updates (i.e. ticks). Our test trading strategy receives these packets, parses them and places a trade order using the FIX protocol on a pseudo exchange that immediately executes the order. To warm up the test strategy, we initially send 1 million market data updates. Then we proceed to send one packet every 5 seconds. To measure the latency, we use tcpdump to record the UDP packet coming in and the FIX order going out. With the packet capture file from tcpdump we then use wireshark to calculate the difference in the timestamps of the packet arriving and the FIX order leaving.</p>
<h3 class="coral">Results</h3>
<p>As you can see from the wireshark screenshot below, the <font color="#008F63"><b>tick-to-trade latencies are around 10-11 microseconds</b></font>. If you compare these numbers with the results from <a href="/index.php/2015/08/tick-to-trade-latency-numbers-using-coralfix-and-coralreactor/" target="_blank">the same tick-to-trade test using CoralFIX and CoralReactor</a>, you will see that CoralMD and CoralGateway add around <font color="#008F63"><b>1-3 microseconds on top of CoralReactor and CoralFIX</b></font>.</p>
<p><a href="/wp-content/uploads/2015/09/tick-to-trade4.png"><img src="/wp-content/uploads/2015/09/tick-to-trade4.png" alt="tick-to-trade4" width="1275" height="1183" class="alignnone size-full wp-image-1607" /></a></p>
<h3 class="coral">Source Code</h3>
<p>Market data is received through a feed implemented using CoralMD. The trade order is placed through a gateway implemented using CoralGateway. As you can see from the source code below, our test strategy receives a book update from the market data feed and proceeds to place an order using the gateway. Also note that the source code down below produces zero garbage for the GC.</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralgateway.bench;

import com.coralblocks.coralgateway.FixGateway;
import com.coralblocks.coralgateway.FixGateway.FixOrder;
import com.coralblocks.coralgateway.Order.Side;
import com.coralblocks.coralgateway.Order.TimeToLive;
import com.coralblocks.coralgateway.Order.Type;
import com.coralblocks.coralgateway.sample.TestFixGateway;
import com.coralblocks.coralmd.Book;
import com.coralblocks.coralmd.Book.State;
import com.coralblocks.coralmd.BookListener;
import com.coralblocks.coralmd.Security;
import com.coralblocks.coralmd.feed.Feed;
import com.coralblocks.coralmd.sample.SimpleFeed;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class BenchStrategy implements BookListener {
	
	private final FixGateway&lt;FixOrder&gt; gateway;
	private final Feed feed;
	private boolean isStarted = false;
	
	public BenchStrategy(FixGateway&lt;FixOrder&gt; gateway, Feed feed) {
		this.gateway = gateway;
		this.feed = feed;
		Book.addGlobalBookListener(this);
	}
	
	public void open() {
		gateway.open();
		feed.open();
	}
	
	public void close() {
		gateway.close();
		feed.close();
	}
	
	public void setStarted(boolean flag) {
		this.isStarted = flag;
	}

	///// BookListener ////
	
	@Override
    public void onBookUpdated(Book book) {
	    
		if (!isStarted) return;
		
		Security sec = book.getSecurity();
		long size = book.getBestAskSize();
		long price = book.getBestAskPrice();
		
		gateway.send(TimeToLive.IOC, Side.BUY, Type.LIMIT, sec.getSymbolString(), size, price);
    }

	@Override
    public void onTopOfBookChanged(Book book, 
               int oldNumberOfBidQuotes, long oldBidSize, long oldBidPrice, 
               int oldNumberOfAskQuotes, long oldAskSize, long oldAskPrice) {
	    
    }

	@Override
    public void onStateChanged(Book book, State oldState) {
	    
    }
	
	public static void main(String[] args) {
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration gwConfig = new MapConfiguration();
		gwConfig.add(&quot;fixVersion&quot;, 44);
		gwConfig.add(&quot;senderComp&quot;, &quot;TEST1&quot;);
		gwConfig.add(&quot;forceSeqReset&quot;, true);
		
		FixGateway&lt;FixOrder&gt; gateway = new TestFixGateway(nio, args.length &gt; 0 ? args[0] : &quot;localhost&quot;, 55559, gwConfig);
		
		MapConfiguration feedConfig = new MapConfiguration();
		feedConfig.add(&quot;host&quot;, &quot;0.0.0.0&quot;);
		feedConfig.add(&quot;port&quot;, 55558);
		
		Feed feed = new SimpleFeed(nio, feedConfig);
		
		BenchStrategy strategy = new BenchStrategy(gateway, feed);
		strategy.open();
		strategy.setStarted(true);
		
		nio.start();
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/tick-to-trade-latency-numbers-using-coralmd-and-coralgateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
