Exemple #1
0
        private static void LoadAccontDetail(string pageData, AccountInfo ac)
        {
            // <td valign="top" width="20%">
               //         <DIV noWrap><a href="/?act=portfolio&xid=616"><B>BoostErr</B></a></DIV>
               //         <DIV noWrap><FONT color=#006600><a href="/?act=broker&id=114"><FONT color=#006600>Alpari-Micro</FONT></a></FONT></DIV>
               // <DIV noWrap><FONT color=#6a5acd><B><span style="color:red">Real</span></B> | USD</FONT></DIV>
               //         <DIV noWrap><B>204677</B></DIV>
               //         <DIV noWrap><B>*****</B></DIV>
               //         <DIV noWrap><B>08/10/2007</B>. &nbsp;days: <B>863</B></DIV>
               //         <DIV noWrap><B>08/10/2007</B>. &nbsp;days: <B>863</B></DIV>
               //         <DIV noWrap><B>16/02/2010</B>. &nbsp;days: <B>1</B></DIV>
               //         <DIV noWrap><FONT color=#339966><B>300.00</B></FONT></DIV>
               //         <DIV noWrap><B>1055</B></DIV>
               //</td>

            //<a href="/\?act=portfolio&xid=\d+"><B>
            //var trader = GetStringBetween("<a href=\"/\\?act=portfolio&xid=\\d+\"><B>", "</B>", pageData);
            //var broker = GetStringBetween("<a href=\"/\\?act=broker&id=\\d+\"><FONT color=#\\d+>", "</FONT>", pageData);
            //var login = GetStringBetween("<DIV noWrap><B>", "</B>", pageData);
            var depo = GetStringBetween("<DIV noWrap><FONT color=#339966><B>", "</B>", pageData);
            ac.InitBalance = DealInfo.ParseDecimalSafe(depo);
        }
Exemple #2
0
 private static List<AccountInfo> ReadAccounts(string pathToAccountFiles)
 {
     var acList = new List<AccountInfo>();
     foreach (var fileInfo in new DirectoryInfo(pathToAccountFiles).GetFiles("*.xml"))
     {
         var ac = new AccountInfo();
         ac.LoadFromFile(fileInfo.FullName);
         acList.Add(ac);
     }
     return acList;
 }
Exemple #3
0
        private static void LoadPageDeals(string pageData, AccountInfo ac)
        {
            // найти вхождения строк таблицы
            // содержит таблицу вида
            //
            //Ticket OpenTime Type Lots Symbol Open SL TP CloseTime Close Swap Profit Comment
            //32344939 2009-04-03 22:00:00 sell 0.10 EURUSD 1.3482 0.0000 1.3467 2009-04-03 22:07:00 1.3467 0.00 15.00 (51)
            //
            // HTML:
            //<tr bgcolor=#F0F0F0 style='padding: 3 5 3 5'>
            //    <td align='right' nowrap><font style='font-size: 5pt'>32344939</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>2009-04-03 22:00:00</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>sell</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>0.10</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>EURUSD</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>1.3482</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>0.0000</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>1.3467</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>2009-04-03 22:07:00</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>1.3467</font></td>
            //    <!--<td align='right' nowrap><font style='font-size: 5pt'>0.00</font></td>-->
            //    <td align='right' nowrap><font style='font-size: 5pt'>0.00</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'>15.00</font></td>
            //    <td align='right' nowrap><font style='font-size: 5pt'> (51)</font></td>
            //</tr>

            // либо

            //<tr bgcolor=#FFFFFF style='padding: 3 5 3 5'>
            //<td align='right' nowrap><font style='font-size: 5pt'>2597784</font></td>
            //<td align='right' nowrap><font style='font-size: 5pt'>2010-01-12 02:14:00</font></td>
            //<td align='right' nowrap><font style='font-size: 5pt'>balance</font></td>
            //<td colspan='8'></td>
            //<td align='right' nowrap><font style='font-size: 5pt'>-4 050.00</font></td>
            //<td align='right' nowrap><font style='font-size: 5pt'> (98)</font></td>
            //</tr>

            var reg = new Regex("<tr bgcolor=#[A-Z,0-9]+ style='padding: 3 5 3 5'>");
            foreach (Match m in reg.Matches(pageData))
            {
                var startIndex = m.Index + m.Value.Length;
                var endIndex = pageData.IndexOf("</tr>", startIndex);
                var obj = ParseDeal(pageData.Substring(startIndex, endIndex - startIndex));
                if (obj != null)
                {
                    if (obj is DealInfo) ac.Deals.Add((DealInfo)obj);
                    if (obj is BalanceInfo) ac.Balances.Add((BalanceInfo)obj);
                }
            }
        }
Exemple #4
0
        private void LoadAccountDeals(int account)
        {
            var url = string.Format("http://www.onix-trade.net/?act=monitoring_history&xid={0}", account);

            var acInf = new AccountInfo { Id = account };

            // запросить данные с сервера
            string pageData = LoadPageData(url);
            if (!IsHistoryPage(pageData)) return;

            // количество страниц
            var pagesTotalReg = new Regex("Total: \\d+");
            var matches = pagesTotalReg.Matches(pageData);
            if (matches.Count == 0) return;
            var pagesCount = int.Parse(matches[0].Value.Substring(7));

            // загрузка сделок
            LoadPageDeals(pageData, acInf);
            LoadAccontDetail(pageData, acInf);

            // и по страницам
            for (var i = 1; i < pagesCount; i++)
            {
                try
                {
                    LoadPageDeals(LoadPageData(string.Format("{0}&p={1}", url, i)), acInf);
                } catch { }
            }

            acInf.SaveInFile(string.Format("{0}\\trader_{1}.xml", tbFolder.Text, account));
        }