├── .gitignore ├── LICENSE.md ├── MarkitQuoteServiceSample.js ├── MarkitTimeseriesServiceSample.js └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS generated files # 2 | ###################### 3 | .DS_Store* 4 | ehthumbs.db 5 | Icon? 6 | Thumbs.db 7 | *.sublime-project 8 | *.sublime-workspace -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2013 Markit On Demand, Inc. http://markitondemand.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /MarkitQuoteServiceSample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Version 1.0, Jan 2012 3 | */ 4 | 5 | var Markit = {}; 6 | /** 7 | * Define the QuoteService. 8 | * First argument is symbol (string) for the quote. Examples: AAPL, MSFT, JNJ, GOOG. 9 | * Second argument is fCallback, a callback function executed onSuccess of API. 10 | */ 11 | Markit.QuoteService = function(sSymbol, fCallback) { 12 | this.symbol = sSymbol; 13 | this.fCallback = fCallback; 14 | this.DATA_SRC = "http://dev.markitondemand.com/Api/v2/Quote/jsonp"; 15 | this.makeRequest(); 16 | }; 17 | /** 18 | * Ajax success callback. fCallback is the 2nd argument in the QuoteService constructor. 19 | */ 20 | Markit.QuoteService.prototype.handleSuccess = function(jsonResult) { 21 | this.fCallback(jsonResult); 22 | }; 23 | /** 24 | * Ajax error callback 25 | */ 26 | Markit.QuoteService.prototype.handleError = function(jsonResult) { 27 | console.error(jsonResult); 28 | }; 29 | /** 30 | * Starts a new ajax request to the Quote API 31 | */ 32 | Markit.QuoteService.prototype.makeRequest = function() { 33 | //Abort any open requests 34 | if (this.xhr) { this.xhr.abort(); } 35 | //Start a new request 36 | this.xhr = $.ajax({ 37 | data: { symbol: this.symbol }, 38 | url: this.DATA_SRC, 39 | dataType: "jsonp", 40 | success: this.handleSuccess, 41 | error: this.handleError, 42 | context: this 43 | }); 44 | }; 45 | 46 | new Markit.QuoteService("AAPL", function(jsonResult) { 47 | 48 | //Catch errors 49 | if (!jsonResult || jsonResult.Message){ 50 | console.error("Error: ", jsonResult.Message); 51 | return; 52 | } 53 | 54 | //If all goes well, your quote will be here. 55 | console.log(jsonResult); 56 | 57 | //Now proceed to do something with the data. 58 | $("h1").first().text(jsonResult.Name); 59 | 60 | /** 61 | * Need help? Visit the API documentation at: 62 | * http://dev.markitondemand.com 63 | */ 64 | }); -------------------------------------------------------------------------------- /MarkitTimeseriesServiceSample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Version 2.0 3 | */ 4 | var Markit = {}; 5 | /** 6 | * Define the InteractiveChartApi. 7 | * First argument is symbol (string) for the quote. Examples: AAPL, MSFT, JNJ, GOOG. 8 | * Second argument is duration (int) for how many days of history to retrieve. 9 | */ 10 | Markit.InteractiveChartApi = function(symbol,duration){ 11 | this.symbol = symbol.toUpperCase(); 12 | this.duration = duration; 13 | this.PlotChart(); 14 | }; 15 | 16 | Markit.InteractiveChartApi.prototype.PlotChart = function(){ 17 | 18 | var params = { 19 | parameters: JSON.stringify( this.getInputParams() ) 20 | } 21 | 22 | //Make JSON request for timeseries data 23 | $.ajax({ 24 | beforeSend:function(){ 25 | $("#chartDemoContainer").text("Loading chart..."); 26 | }, 27 | data: params, 28 | url: "http://dev.markitondemand.com/Api/v2/InteractiveChart/jsonp", 29 | dataType: "jsonp", 30 | context: this, 31 | success: function(json){ 32 | //Catch errors 33 | if (!json || json.Message){ 34 | console.error("Error: ", json.Message); 35 | return; 36 | } 37 | this.render(json); 38 | }, 39 | error: function(response,txtStatus){ 40 | console.log(response,txtStatus) 41 | } 42 | }); 43 | }; 44 | 45 | Markit.InteractiveChartApi.prototype.getInputParams = function(){ 46 | return { 47 | Normalized: false, 48 | NumberOfDays: this.duration, 49 | DataPeriod: "Day", 50 | Elements: [ 51 | { 52 | Symbol: this.symbol, 53 | Type: "price", 54 | Params: ["ohlc"] //ohlc, c = close only 55 | }, 56 | { 57 | Symbol: this.symbol, 58 | Type: "volume" 59 | } 60 | ] 61 | //,LabelPeriod: 'Week', 62 | //LabelInterval: 1 63 | } 64 | }; 65 | 66 | Markit.InteractiveChartApi.prototype._fixDate = function(dateIn) { 67 | var dat = new Date(dateIn); 68 | return Date.UTC(dat.getFullYear(), dat.getMonth(), dat.getDate()); 69 | }; 70 | 71 | Markit.InteractiveChartApi.prototype._getOHLC = function(json) { 72 | var dates = json.Dates || []; 73 | var elements = json.Elements || []; 74 | var chartSeries = []; 75 | 76 | if (elements[0]){ 77 | 78 | for (var i = 0, datLen = dates.length; i < datLen; i++) { 79 | var dat = this._fixDate( dates[i] ); 80 | var pointData = [ 81 | dat, 82 | elements[0].DataSeries['open'].values[i], 83 | elements[0].DataSeries['high'].values[i], 84 | elements[0].DataSeries['low'].values[i], 85 | elements[0].DataSeries['close'].values[i] 86 | ]; 87 | chartSeries.push( pointData ); 88 | }; 89 | } 90 | return chartSeries; 91 | }; 92 | 93 | Markit.InteractiveChartApi.prototype._getVolume = function(json) { 94 | var dates = json.Dates || []; 95 | var elements = json.Elements || []; 96 | var chartSeries = []; 97 | 98 | if (elements[1]){ 99 | 100 | for (var i = 0, datLen = dates.length; i < datLen; i++) { 101 | var dat = this._fixDate( dates[i] ); 102 | var pointData = [ 103 | dat, 104 | elements[1].DataSeries['volume'].values[i] 105 | ]; 106 | chartSeries.push( pointData ); 107 | }; 108 | } 109 | return chartSeries; 110 | }; 111 | 112 | Markit.InteractiveChartApi.prototype.render = function(data) { 113 | //console.log(data) 114 | // split the data set into ohlc and volume 115 | var ohlc = this._getOHLC(data), 116 | volume = this._getVolume(data); 117 | 118 | // set the allowed units for data grouping 119 | var groupingUnits = [[ 120 | 'week', // unit name 121 | [1] // allowed multiples 122 | ], [ 123 | 'month', 124 | [1, 2, 3, 4, 6] 125 | ]]; 126 | 127 | // create the chart 128 | $('#chartDemoContainer').highcharts('StockChart', { 129 | 130 | rangeSelector: { 131 | selected: 1 132 | //enabled: false 133 | }, 134 | 135 | title: { 136 | text: this.symbol + ' Historical Price' 137 | }, 138 | 139 | yAxis: [{ 140 | title: { 141 | text: 'OHLC' 142 | }, 143 | height: 200, 144 | lineWidth: 2 145 | }, { 146 | title: { 147 | text: 'Volume' 148 | }, 149 | top: 300, 150 | height: 100, 151 | offset: 0, 152 | lineWidth: 2 153 | }], 154 | 155 | series: [{ 156 | type: 'candlestick', 157 | name: this.symbol, 158 | data: ohlc, 159 | dataGrouping: { 160 | units: groupingUnits 161 | } 162 | }, { 163 | type: 'column', 164 | name: 'Volume', 165 | data: volume, 166 | yAxis: 1, 167 | dataGrouping: { 168 | units: groupingUnits 169 | } 170 | }], 171 | credits: { 172 | enabled:false 173 | } 174 | }); 175 | }; -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | _These APIs are deprecated and no longer maintained and may be taken down at any moment._ 3 | --------------------------------------------------------------------------------