using System;
using System.Net;
using System.Text;
namespace AuthMoexSmpl
{
class Program
{
static void Main(string[] args)
{
string authLink = "https://passport.moex.com/authenticate";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authLink);
request.ContentType = "text/plain; charset=utf-8";
request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("login:password")); //свои данные
request.PreAuthenticate = true;
request.CookieContainer = new CookieContainer();
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
for(int i=0; i < response.Headers.Count; ++i)
Console.WriteLine("\nHeader Name:{0}, Value :{1}",response.Headers.Keys[i],response.Headers[i]);
}
}
}
D:\devel\net\AuthMoexSmpl>dotnet run
Header Name:Cache-Control, Value :no-store, must-revalidate, no-cache, ma
Header Name:Connection, Value :close
Header Name:Date, Value :Fri, 10 Nov 2017 19:53:12 GMT
Header Name:Pragma, Value :no-cache
Header Name:ETag, Value :"xxxxxx"
Header Name:Server, Value :nginx
Header Name:Set-Cookie, Value :MicexPassportCert=xxxxxxx; domain=.moex.com; path=/, _passport_se
m xxxxx; path=/; HttpOnly
Header Name:Status, Value :200 OK
Header Name:X-Runtime, Value :713
Header Name:X-Moex-Passport-Certificate, Value :xxxxxx
Header Name:X-Powered-By, Value :Phusion Passenger 4.0.57
Header Name:Access-Control-Allow-Credentials, Value :true
Header Name:Access-Control-Expose-Headers, Value :X-MicexPassport-Marker
using System;
using System.Net;
using System.Text;
namespace AuthMoexSmpl
{
class Program
{
static void Main(string[] args)
{
string authLink = "https://passport.moex.com/authenticate";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authLink);
request.ContentType = "text/plain; charset=utf-8";
request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("login:password")); // вносим свои данные
request.PreAuthenticate = true;
request.CookieContainer = new CookieContainer();
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
foreach (Cookie cook in response.Cookies) {
Console.WriteLine("Cookie:");
Console.WriteLine("{0} = {1}", cook.Name, cook.Value);
Console.WriteLine("Domain: {0}", cook.Domain);
Console.WriteLine("Path: {0}", cook.Path);
Console.WriteLine("Port: {0}", cook.Port);
Console.WriteLine("Secure: {0}", cook.Secure);
Console.WriteLine("When issued: {0}", cook.TimeStamp);
Console.WriteLine("Expires: {0} (expired? {1})", cook.Expires, cook.Expired);
Console.WriteLine("Don't save: {0}", cook.Discard);
Console.WriteLine("Comment: {0}", cook.Comment);
Console.WriteLine("Uri for comments: {0}", cook.CommentUri);
Console.WriteLine("Version: RFC {0}" , cook.Version == 1 ? "2109" : "2965");
Console.WriteLine ("String: {0}", cook.ToString());
}
}
}
}
D:\devel\net\AuthMoexSmpl>dotnet run
Cookie:
_passport_session = xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Domain: passport.moex.com
Path: /
Port:
Secure: False
When issued: 11.11.2017 01:55:42
Expires: 01.01.0001 00:00:00 (expired? False)
Don't save: False
Comment:
Uri for comments:
Version: RFC 2965
...
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
We are excited to announce the release of .NET Core 1.0, ASP.NET Core 1.0 and Entity Framework Core 1.0, available on Windows, OS X and Linux! .NET Core is a cross-platform, open source, and modular .NET platform for creating modern web apps, microservices, libraries and console applications.
К методам и алгоритмам Data Mining относятся следующие: искусственные нейронныесети, деревья решений, символьные правила, методы ближайшего соседа и k-ближайшегососеда, метод опорных векторов, байесовские сети, линейная регрессия, корреляционно-регрессионный анализ; иерархические методы кластерного анализа, неиерархическиеметоды кластерного анализа, в том числе алгоритмы k-средних и k-медианы; методыпоиска ассоциативных правил, в том числе алгоритм Apriori; метод ограниченногоперебора, эволюционное программирование и генетические алгоритмы, разнообразныеметоды визуализации данных и множество других методов.