Child pages
  • Fintech Kodi.SimpleApi
Skip to end of metadata
Go to start of metadata

JavaScript Api

  • Is hosted at Kóði CDN.
  • Need to initialize with token. Logging in is available, but providing a token from the server is preferred.
  • All parameters are optional and will be swapped out for default parameters if ommited.

The Api

var KodiService = new function () {

    this.setToken = function (t) { }
 
    this.login = function (username) {
        var turl = "https://users.livemarketdata.com/v2/token/create", msg = { "username": username, "password": password, "system_id": "kodiak_web" };
        $.ajax({
            type: "POST",
            url: turl,
            async: false,
            data: JSON.stringify(msg),
            headers: {
                "Content-Type": "application/json"
            },
            success: function (data) {
                token = data.access_token;
            },
            error: function (error) {
                console.log('error', error);
            }
        });
    }

    this.GetAllTradables = function (params, success, error) {
        // Params includes 'exchange'
    };

    this.GetShares = function (params, success, error) {
        // Params includes 'exchange' and 'symbol'
    };

    this.GetBonds = function (params, success, error) {
        // Params includes 'exchange' and 'symbol'
    };

    this.GetEndOfDayPrices = function (params, success, error) {
        // Params includes 'symbol', 'fromDate' and 'toDate'
    };

    this.GetTradableStatistics = function (params, success, error) {
        // Params includes 'symbol'
    };

    this.GetSharesSnapshot = function (params, success, error) {
        // Params includes 'exchange' and 'symbol'
    };

    this.GetBondsSnapshot = function (params, success, error) {
        // Params includes 'exchange' and 'symbol'
    };
}

 

Examples

This is an example HTML page that includes the required packages and calls all the functions of the API.

It also demonstrates different use cases of a few functions.

<!DOCTYPE html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js" type="text/javascript"></script>
  <script src="https://cdn.livemarketdata.com/KodiService.js" type="text/javascript"></script>
</head>
<body>
  <script type="text/javascript">
    // Logging in on server side and providing the JavaScript with a token is much better than providing the JavaScript with a username and password and asking it to take care of the login.
    // Logging in is covered here as an example of how it is done.
    
    // KodiService.login('USERNAME');
    KodiService.setToken('YOUR TOKEN HERE');
    
    function Success(source) {
      return function(data) {
        console.debug('success', source, data);
      }
    }
    
    function Error(source) {
      return function(error) {
        console.debug('error', source, error);
      }
    }
    
    $(function() {
      var exchange = 'XICE';
      var symbol = 'MARL', bondSymbol = 'HFF150224';
      var fromDate = new Date(2016, 0, 1); // January 1st
      var toDate = new Date();
      
      KodiService.GetAllTradables({
        exchange: exchange
      }, Success('GetAllTradables'), Error('GetAllTradables'));
      
      KodiService.GetShares({
        exchange: exchange
      }, Success('GetAllShares'), Error('GetShares'));
      
      KodiService.GetShares({
        exchange: exchange,
        symbol: symbol
      }, Success('GetShare'), Error('GetShares'));
      
      KodiService.GetBonds({
        exchange: exchange
      }, Success('GetAllBonds'), Error('GetBonds'));
      
      KodiService.GetBonds({
        exchange: exchange,
        symbol: bondSymbol
      }, Success('GetBond'), Error('GetBonds'));
      
      KodiService.GetEndOfDayPrices({
        symbol: symbol,
        fromDate: fromDate,
        toDate: toDate
      }, Success('GetEndOfDayPrices'), Error('GetEndOfDayPrices'));
      
      KodiService.GetSharesSnapshot({
        exchange: exchange
      }, Success('GetAllSharesSnapshot'), Error('GetAllSharesSnapshot'));
      
      KodiService.GetSharesSnapshot({
        symbol: symbol
      }, Success('GetSharesSnapshot'), Error('GetSharesSnapshot'));
      
      KodiService.GetBondsSnapshot({
        exchange: exchange
      }, Success('GetAllBondsSnapshot'), Error('GetAllBondsSnapshot'));
      
      KodiService.GetBondsSnapshot({
        symbol: bondSymbol
      }, Success('GetBondsSnapshot'), Error('GetBondsSnapshot'));
      
      KodiService.GetTradableStatistics({
        symbol: symbol
      }, Success('GetTradableStatistics'), Error('GetTradableStatistics'));
    });
  </script>
</body>
</html>

 

.NET C# Api

Nuget package

Add the following nuget package feed:

https://www.myget.org/F/kodiak_public/

The Api

        /// <summary>
        /// Creates the service and authenticates through the authentication service
        /// </summary>
        /// <param name="UserName">Arion FinTechPartý users should use "ArionFinTech1"</param>
        public KodiService(string UserName)

        /// <summary>
        /// Returns all tradable for a given exchange
        /// </summary>
        /// <param name="exchangeMic">XICE or XSTO or XHEL or XCHP or "*"</param>
        /// <returns>All tradables</returns>
        public async Task<List<ShortTradable>> GetAllTradables(string exchangeMic = "*")

        /// <summary>
        /// Returns all shares
        /// </summary>
        /// <param name="exchangeMic">XICE or XSTO or XHEL or XCHP or "*"</param>
        /// <param name="symbol">Symbol of the tradable, e.g. "MARL" or "*"</param>
        /// <returns>ShortTradable record</returns>
        public async Task<List<ShortTradable>> GetShares(string exchangeMic, string symbol = "*")

        /// <summary>
        /// Returns all bonds
        /// </summary>
        /// <param name="exchangeMic">XICE or XSTO or XHEL or XCHP or "*"</param>
        /// <param name="symbol">Symbol of the tradable, e.g. "HFF150224" or "*"</param>
        /// <returns>ShortTradable record</returns>
        public async Task<List<ShortTradable>> GetBonds(string exchangeMic, string symbol = "*")

        /// <summary>
        /// Returns End of Day prices for a given symbol. Note that eod data is calculated end of day
        /// </summary>
        /// <param name="symbol">Symbol of the tradable, e.g. "MARL" or "*"</param>
        /// <param name="fromDate">Starting date</param>
        /// <param name="toDate">End date</param>
        /// <returns>Timeseries with EOD prices</returns>
        public async Task<List<History>> GetEndOfDayPrices(string symbol, DateTime fromDate, DateTime toDate)

        /// <summary>
        /// Returns statistics for a given symbol
        /// </summary>
        /// <param name="symbol">Symbol of the tradable, e.g. "MARL" or "*"</param>
        /// <returns>Statistics record</returns>
        public async Task<List<StatisticsShort>> GetTradableStatistics(string symbol = "*")

        /// <summary>
        /// Returns a 15 min. delayed snapshot for a given symbol
        /// </summary>
        /// <param name="symbol">Symbol of the tradable, e.g. "MARL" or "*"</param>
        /// <returns>Snapshot record</returns>
        public async Task<List<Snapshot>> GetSharesSnapshot(string symbol = "*")

        /// <summary>
        /// Returns a 15 min. delayed snapshot for a given symbol
        /// </summary>
        /// <param name="symbol">Symbol of the tradable, e.g. "HFF150224" or "*"</param>
        /// <returns>Snapshot record</returns>
        public async Task<List<Snapshot>> GetBondsSnapshot(string symbol = "*")

Example Console app

Below is a C# console app that uses the Kodi.SimleApi. Just add the Kodi.SimpleApi nuget package and paste the following code into your console applicaton project.

Kodi.SimpleApi.Console
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kodi.SimpleApi.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            string exchange = "XICE";
            string eqSymbol = "MARL";
            string bondSymbol = "HFF150224";
            DateTime fromDate = DateTime.Now.AddDays(-30).Date;
            DateTime toDate = DateTime.Now.Date;

            var service = new KodiService("ArionFinTech1");

            System.Console.WriteLine("Getting all tradables for " + exchange);
            var tradables = service.GetAllTradables(exchange).Result;
            foreach(var t in tradables)
            {
                System.Console.WriteLine(string.Format("Symbol: {0} Name: {1}", t.Symbol, t.Name));
            }
            if (tradables.Count == 0) System.Console.WriteLine("No data for " + exchange);

            System.Console.WriteLine("-------------------------------------------");            
            System.Console.WriteLine("Getting all shares for " + exchange);
            var shares = service.GetShares(exchange, "").Result;
            foreach (var s in shares)
            {
                System.Console.WriteLine(string.Format("Symbol: {0} Name: {1}", s.Symbol, s.Name));
            }
            if (shares.Count == 0) System.Console.WriteLine("No data for " + exchange);

            System.Console.WriteLine("-------------------------------------------");
            System.Console.WriteLine("Getting all bonds for " + exchange);
            var bonds = service.GetShares(exchange, "").Result;
            foreach (var s in bonds)
            {
                System.Console.WriteLine(string.Format("Symbol: {0} Name: {1}", s.Symbol, s.Name));
            }
            if (bonds.Count == 0) System.Console.WriteLine("No data for " + exchange);
            System.Console.WriteLine("-------------------------------------------");
            System.Console.WriteLine("Getting EOD prices for " + eqSymbol);
            var eod = service.GetEndOfDayPrices(eqSymbol, fromDate, toDate).Result;
            foreach (var e in eod)
            {
                System.Console.WriteLine(string.Format("Symbol: {0} Date: {1} Price: {2}", 
                    e.Symbol, 
                    e.TradingDate.Value.ToString("dd.mm.yyyy"), 
                    e.Close.Value.ToString("N3")));
            }
            if (eod.Count == 0) System.Console.WriteLine("No data for " + eqSymbol);

            System.Console.WriteLine("-------------------------------------------");
            System.Console.WriteLine("Getting a snapshot for " + eqSymbol);
            var snap = service.GetSharesSnapshot(eqSymbol).Result;
            foreach (var e in snap)
            {
                System.Console.WriteLine(string.Format("Symbol: {0}\n - Ask: {1}\n - Bid: {2}\n - Last Price: {3}\n - Intraday turnover: {4}", 
                    e.Symbol, 
                    e.Ask.Value.ToString("N3"), 
                    e.Bid.Value.ToString("N3"), 
                    e.LastPrice.Value.ToString("N3"), 
                    e.IntradayAccumulatedTurnover.Value.ToString("N3")));
            }
            if (snap.Count == 0) System.Console.WriteLine("No data for " + eqSymbol);

            System.Console.WriteLine("-------------------------------------------");
            System.Console.WriteLine("Getting a snapshot for " + bondSymbol);
            snap = service.GetBondsSnapshot(bondSymbol).Result;
            foreach (var e in snap)
            {
                System.Console.WriteLine(string.Format("Symbol: {0}\n - Ask: {1} AskYield: {5}\n - Bid: {2} BidYield: {6}\n - Last Price: {3} LastYield: {7}\n - Intraday turnover: {4}", 
                    e.Symbol, e.Ask.Value.ToString("N3"), 
                    e.Bid.Value.ToString("N3"), 
                    e.LastPrice.Value.ToString("N3"), 
                    e.IntradayAccumulatedTurnover.Value.ToString("N3"), 
                    e.AskYield.Value.ToString("P"), 
                    e.BidYield.Value.ToString("P"), 
                    e.LastYield.Value.ToString("P")));
            }
            if (snap.Count == 0) System.Console.WriteLine("No data for " + bondSymbol);
            

            System.Console.WriteLine("-------------------------------------------");
            System.Console.WriteLine("Getting statistics for " + eqSymbol);
            var stats = service.GetTradableStatistics(eqSymbol).Result;
            foreach (var e in stats)
            {
                System.Console.WriteLine(string.Format("Symbol: {0}\n - 7 Day Change: {1}\n - 4 Week Change: {2}\n - Year Change: {3}", 
                    e.Symbol, e.Days7PriceChangePer.Value.ToString("P"), 
                    e.Weeks4PriceChangePer.Value.ToString("P"), 
                    e.YearPriceChangePer.Value.ToString("P")));
            }
            if (stats.Count == 0) System.Console.WriteLine("No data for " + eqSymbol);

            
            System.Console.ReadLine();
        }
    }
}



 

 
  • No labels