Пример #1
0
        public void RecordTradingDataInList(int i, string value, TradingData td)
        {
            // Create a NumberFormatInfo object and set some of its properties.

            switch(i)
            {
                case 0:
                    td.Price = Convert.ToDouble(value, NumberProvider);
                    break;
                case 1:
                    td.Volume = Convert.ToDouble(value, NumberProvider);
                    break;
                case 2:
                    td.UnixTime = Convert.ToDouble(value, NumberProvider);
                    break;
                case 3:
                td.BuyOrSell = value;
                    break;
                case 4:
                td.MarketOrLimit = value;
                    break;
                case 5:
                    td.Misc = value;
                    break;
            }
        }
Пример #2
0
        //Public
        public void RecordRecentTradeData()
        {
            long? since = null;
            string filePath = CheckFileAndDirectoryTradingData();

            // Sending rate increase the meter and check if can continue ootherwise stop 4sec;
            SRM.RateAddition(2);
            HTMLUpdate("LastAction", "RecordRecentTradeData");

            recenttrades = this.GetRecentTrades(since);

            // null if error in parsing likely due to a error message from API
            if(recenttrades == null)
            {

                return;
            }

            string LinesToAdd = "";
            foreach (List<string> ls in recenttrades.Datas)
            {
                // Foreach line, register in file and in the lsit
                TradingData td = new TradingData();
                int i = 0;
                foreach (string s in ls)
                {
                    RecordTradingDataInList(i, s, td);
                    LinesToAdd += s + ",";
                    i++;
                    //Console.Write(s);
                }
                //Console.WriteLine();
                ListOftradingDatas.Add(td);
                LinesToAdd += Environment.NewLine;
            }

            File.AppendAllText(filePath,LinesToAdd);
            since = recenttrades.Last;
            Double interval = GetServerTime().unixtime;
            ListOftradingDatas.RemoveAll(a => a.UnixTime < (interval - IntervalInSecond));
        }