Source of information on the fair value of bonds calculated using NSD’s methodology and integrated into your system (daily updates, as well as historical data)
TTL - Bond liquidity assessment
{ "type": "array", "items": [ { "type": "object", "properties": { "calc_date": { "title": "Дата расчета", "description": "Дата расчета", "type": "string" }, "details": { "title": "Детали расчета", "description": "Детали расчета дисконта ликвидации", "type": "array", "items": [ { "type": "object", "properties": { "isin": { "title": "ISIN", "description": "Код ISIN бумаги", "type": "string" }, "issuer": { "title": "Наименование эмитента", "description": "Наименование эмитента", "type": "string" }, "hh": { "title": "Индекс Херфиндаля-Хиршмана", "description": "Индекс Херфиндаля-Хиршмана на основе данных об остатках на счетах в НРД", "type": "number" }, "num_observations": { "title": "Количество наблюдений", "description": "Количество наблюдений при расчете дисконта", "type": "integer" }, "moex_trades": { "title": "Использование в расчете биржевых сделок", "description": "Использование в расчете биржевых сделок", "type": "boolean" }, "otc_trades": { "title": "Использование в расчете OTC-сделок", "description": "Использование в расчете OTC-сделок", "type": "boolean" }, "orderbook": { "title": "Использование в расчете стакана заявок", "description": "Использование в расчете стакана заявок", "type": "boolean" } }, "required": [ "isin", "issuer", "hh", "num_observations", "moex_trades", "otc_trades", "orderbook" ] } ] }, "surface": { "title": "Поверхность ликвидности", "description": "Поверхность ликвидности (объем, число дней, дисконт)", "type": "array", "items": [ { "type": "object", "properties": { "volume": { "title": "Объем", "description": "Количество бумаг для ликвидации", "type": "integer" }, "days": { "title": "Количество дней", "description": "Количество дней для ликвидации", "type": "integer" }, "discount": { "title": "Дисконт", "description": "Дисконт ликвидации", "type": "number" }, "ldiscount": { "title": "Нижняя граница дисконта", "description": "Дисконт ликвидации, нижняя граница (с учетом рыночного риска)", "type": "number" }, "udiscount": { "title": "Верхняя граница дисконта", "description": "Дисконт ликвидации, верхняя граница (с учетом рыночного риска)", "type": "number" } }, "required": [ "volume", "days", "discount", "ldiscount", "udiscount" ] } ] } }, "required": [ "details", "calc_date", "surface" ] } ] }
URL
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using Newtonsoft.Json.Linq; using ClosedXML.Excel; namespace ApiSample { class Program { public const string ApiUrl = "http://172.23.24.198:5000/securities?limit=100"; public static HashSet<string> SetOfIsins = new HashSet<string>(new[] { "RU0007202057", "RU0007202545", "RU0007201018", "RU0007202032" }); public const string FileName = "coupons.xlsx"; static void Main(string[] args) { Console.WriteLine("Загрузка данных..."); var wc = new WebClient() { Encoding = Encoding.UTF8, }; var json = wc.DownloadString(ApiUrl); var bonds = JArray.Parse(json); var filteredBonds = bonds.Where(b => SetOfIsins.Contains((string)b["isin"])).ToList(); Console.WriteLine("Формирование Excel..."); GenerateExcel(filteredBonds); Console.WriteLine("Готово!"); } private static void GenerateExcel(List<JToken> input) { var workbook = new XLWorkbook(); workbook.Use1904DateSystem = true; var ws = workbook.Worksheets.Add("Coupons info"); ws.Column(1).Width = 16; ws.Column(2).Width = 70; ws.Column(3).Width = 50; ws.Column(4).Width = 35; ws.Column(5).Width = 16; var columns = new[] { "ISIN", "Название", "Эмитент", "Корпоративное действие", "Дата" }; foreach (var j in Enumerable.Range(0, columns.Length)) { ws.Cell(1, j + 1).Value = columns[j]; ws.Cell(1, j + 1).Style.Fill.BackgroundColor = XLColor.FromTheme(XLThemeColor.Accent6); } var data = new List<List<JToken>>(); foreach (var bond in input) { var corpActions = bond["corp_actions"]?.ToArray(); if (corpActions == null || corpActions.Length == 0) continue; foreach (var c in corpActions) try { data.Add(new List<JToken>() { bond["isin"], bond["name_full"], bond["issuer"]["name_full"], c["corp_action_type"]["name"], c["action_date_plan"] }); } catch (Exception ex) { Console.WriteLine(ex); continue; } } for (int i = 0; i < data.Count; i++) for (int j = 0; j < columns.Length; j++) { ws.Cell(i + 2, j + 1).SetValue<string>(Convert.ToString(data[i][j])); ws.Cell(i + 2, j + 1).Style.Fill.BackgroundColor = i % 2 == 0 ? XLColor.FromTheme(XLThemeColor.Accent6, 0.5) : XLColor.FromTheme(XLThemeColor.Accent6, 0.8); } ws.RangeUsed().SetAutoFilter(); workbook.SaveAs(FileName); System.Diagnostics.Process.Start(FileName); } } }
package ru.nsd.example; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.DefaultClientConfig; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.json.JSONArray; import org.json.JSONObject; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import java.io.FileOutputStream; import java.io.IOException; public class RestClientExample { private static final String NSD_DATA_HOST = "http://172.23.24.198:5000"; private static final String METHOD_NAME = "securities"; private static final String RESULT_EXCEL_PATH = "C:/Temp/securities100.xls"; public static void main(String[] args) { saveExcel(getFirstHundredSecurities()); } private static JSONArray getFirstHundredSecurities() { Client client = Client.create(new DefaultClientConfig()); WebResource webResource = client.resource(UriBuilder.fromUri(NSD_DATA_HOST).build()); String jsonData = webResource.path(METHOD_NAME).queryParam("limit", "100") .accept(MediaType.APPLICATION_JSON_TYPE).get(String.class); return new JSONArray(jsonData); } private static void saveExcel(JSONArray securities) { try { FileOutputStream stream = new FileOutputStream(RESULT_EXCEL_PATH); HSSFWorkbook workbook = generateExcel(securities); workbook.write(stream); stream.close(); } catch (IOException ex) { System.out.println(ex); } } private static HSSFWorkbook generateExcel(JSONArray securities) { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); int rownum = 1; HSSFRow headRow = sheet.createRow(rownum++); headRow.createCell(0).setCellValue("ISIN"); headRow.createCell(1).setCellValue("Полное наименование"); for (Object obj : securities) { JSONObject json = (JSONObject) obj; HSSFRow row = sheet.createRow(rownum++); row.createCell(0).setCellValue(json.optString("isin")); row.createCell(1).setCellValue(json.optString("name_full")); } return workbook; } }