reversed=1и оставить только строчку номер 15 в запросе
limit=1получим запрос вида
https://iss.moex.com/iss/engines/futures/markets/forts/securities/SiZ7/trades.json?reversed=1&limit=1Вариант автоматизации упрощенно:
using System; using System.Net; using System.IO; using System.Text; namespace GetLastPrice { class Program { static void Main(string[] args) { string newLine; string[] lastLine; string link = "https://iss.moex.com/iss/engines/futures/markets/forts/securities/SiZ7/trades.json?reversed=1&limit=1"; int count = 0; for (;;) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(link); request.ContentType = "text/plain; charset=utf-8"; HttpWebResponse response = request.GetResponse() as HttpWebResponse; using (Stream responseStream = response.GetResponseStream()) { StreamReader sr = new StreamReader(responseStream, Encoding.UTF8); while ((newLine = sr.ReadLine()) != null) { if (count == 14) { if (newLine =="") break; else { lastLine = newLine.Split(","); Console.WriteLine("Volume is " + lastLine[6] +" at Price " + lastLine[5]); } } count++; } } count = 0; response.Close(); } } } }
https://iss.moex.com/iss/engines/futures/markets/forts/securities/SiZ7/trades.json— если добавить
?start=0&limit=100то начиная с первой сточки (номер ноль) получим только первые 100 сделок:
https://iss.moex.com/iss/engines/futures/markets/forts/securities/SiZ7/trades.json?start=0&limit=100следующие 100 сделок:
?start=100&limit=100Минутки получить можно так:
http://iss.moex.com/iss/engines/futures/markets/forts/boards/RFUD/securities/SiZ7/candles.json?from=2017-11-08&till=2017-11-08&interval=1&start=0Если заменить .json --> .csv, то скачивается файл:
http://iss.moex.com/iss/engines/futures/markets/forts/boards/RFUD/securities/SiZ7/candles.json?from=2017-11-08&till=2017-11-08&interval=1&start=0Программный пример:
using System; using System.Net; using System.IO; namespace GetDataSmpl { class Program { static void Main(string[] args) { string link = "https://iss.moex.com/iss/engines/futures/markets/forts/securities/SiZ7/trades.json?start=0&limit=10"; string dataLine; int count = 0; using (WebClient wc = new WebClient()) { Stream stream = wc.OpenRead(link); StreamReader sr = new StreamReader(stream); while ((dataLine = sr.ReadLine()) != null) { if (count >= 14 && count <= 23) Console.WriteLine(dataLine); count +=1; } stream.Close(); } } } }
dotnet run
dotnet publish -c Release -r win7-x64для Ubuntu 14.04:
dotnet publish -c Release -r ubuntu.14.04-x64