Exemple #1
0
 public static void analyzeHistory(ref HistoryInfo info)
 {
     using (TextReader textReader = new StringReader(info.History))
     {
         CsvReader reader = new CsvReader(textReader, true);
         CsvReader.RecordEnumerator record = reader.GetEnumerator();
         double spent = 0.0, earn = 0.0, deposit = 0.0, withdraw = 0.0;
         double temp = 0.0;
         while (record.MoveNext())
         {
             if (record.Current[2] == "spent")
             {
                 if (Double.TryParse(record.Current[4], out temp))
                     spent += temp;
             }
             else if (record.Current[2] == "fee")
             {
                 if (Double.TryParse(record.Current[4], out temp))
                     spent += temp;
             }
             else if (record.Current[2] == "earned")
             {
                 if (Double.TryParse(record.Current[4], out temp))
                     earn += temp;
             }
             else if (record.Current[2] == "deposit")
             {
                 if (Double.TryParse(record.Current[4], out temp))
                     deposit += temp;
             }
             else if (record.Current[2] == "withdraw")
             {
                 if (Double.TryParse(record.Current[4], out temp))
                     withdraw += temp;
             }
         }
         info.TotalDeposit = deposit;
         info.TotalEarn = earn;
         info.TotalSpent = spent;
         info.TotalWithdraw = withdraw;
     }
 }
Exemple #2
0
        public bool Init()
        {
            bool bReturn = true;
            try
            {
                mtgoxV0.apiKey = MtGoxConfig.Key;
                mtgoxV0.apiSecret = MtGoxConfig.Secret;
                Currency = MtGoxConfig.Currency;
                userInfo = new UserInfo();
                userInfo.Currency = Currency;

                historyFund = new HistoryInfo();
                historyBtc = new HistoryInfo();
                currentHistory = mtgoxV0.info();
                if (currentHistory == null)
                {
                    bReturn = false;
                    return bReturn;
                }

                this.LoadHistory();
                this.loadUserInfo();
                this.loadOrders();
                tickerTimer = new System.Threading.Timer(GetRealtimeTrade, null, Consts.DefaultRefreshTime * 1000, Consts.DefaultRefreshTime * 1000);
                formTimer = new System.Threading.Timer(BindRealtimeTrade, null, Consts.DefaultRefreshTime * 1000 + System.DateTime.Now.Month * 100 + System.DateTime.Now.Year, Consts.DefaultRefreshTime * 1000);
                this.GetRealtimeTrade(null);
                this.BindUserInfo();
            }
            catch (Exception ex)
            {
                bReturn = false;
                Trace.WriteLine(string.Format("{0} \r\n stack:{1}", Utils.GetDetailedException(ex), Utils.GetStackTrace(ex)));
            }
            return bReturn;
        }