Authorized by the Bank of Russia 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)
Fair value of 1350+ financial instruments calculated using NSD’s NEW methodology
{ "type": "array", "items": { "$ref": "#/definitions/Valuation" }, "definitions": { "Valuation": { "type": "object", "properties": { "acc_int": { "title": "НКД", "description": "НКД на дату расчета", "type": "number" }, "currency_code": { "title": "Код валюты", "description": "Код валюты инструмента", "type": "string" }, "isin": { "title": "ISIN", "description": "Код ISIN", "type": "string" }, "issuer": { "title": "Эмитент", "description": "Общепринятое наименование эмитента", "type": "string" }, "method_number": { "title": "Метод", "description": "Номер метода расчета (1-3)", "type": "integer" }, "name": { "title": "Инструмент", "description": "Наименование инструмента", "type": "string" }, "nominal": { "title": "Номинал", "description": "Текущий номинал инструмента", "type": "number" }, "nsd_code": { "title": "Код НРД", "description": "Код НРД", "type": "string" }, "price": { "title": "Цена в валюте", "description": "Чистая цена в валюте номинала", "type": "number" }, "rate": { "title": "Цена в %", "description": "Чистая цена в процентах от номинала", "type": "number" }, "rate_lbound": { "title": "Нижний порог цены", "description": "Нижний порог цены в % от номинала", "type": "number" }, "rate_ubound": { "title": "Верхний порог цены", "description": "Верхний порог цены в % от номинала", "type": "number" }, "reg_number": { "title": "Код регистрации", "description": "Код регистрации инструмента", "type": "string" }, "type": { "title": "Тип инструмента", "description": "Тип инструмента, соответствует методике оценки", "type": "string" }, "val_date": { "title": "Дата оценки", "description": "Дата оценки", "type": "string" }, "version": { "title": "Версия", "description": "Технический номер версии методики", "type": "integer" }, "yield": { "title": "Доходность", "description": "Доходность к погашению или к опциону", "type": "number" } } } } }
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; } }