Ejemplo n.º 1
0
 public void RemoveItem(BalanceItem item)
 {
     Items.Remove(item);
     item.EloElements.ForEach(x => {
         if (Count > 1)
         {
             double oldAvg = EloAvg;
             EloSum       -= x;
             EloAvg        = EloSum / --Count;
             EloVarSum    -= (x - oldAvg) * (x - EloAvg);
         }
         else
         {
             EloSum = EloVarSum = EloAvg = Count = 0;
         }
     });
     if (Count > 1)
     {
         EloVar = EloVarSum / (Count - 1);
     }
     else
     {
         EloVar = 0;
     }
     EloStdev = Math.Sqrt(EloVar);
 }
Ejemplo n.º 2
0
        public void NotBalanceItemFact()
        {
            var s    = "abA";
            var item = new BalanceItem("a", 0, 2);

            Assert.Equal(3, item.Distance());
            Assert.False(item.IsBalance(s));
            Assert.False(item.IsShortedBalance());
            Assert.True(item.IsUpperLowerSet());
        }
Ejemplo n.º 3
0
        public static IEnumerable <string> GetListOfSubCategorias(DataGridView dgv, BalanceItem item)
        {
            var source = GetDGVData(dgv);
            var items  = source.Where(c => c.Sinal == item.Sinal &&
                                      c.Grupo == item.Grupo &&
                                      c.Categoria == item.Categoria &&
                                      !string.IsNullOrEmpty(c.SubCategoria))
                         .Select(c => c.SubCategoria);

            return(GetListOfSubCategorias(item.Grupo, item.Categoria, item.Sinal)
                   .Union(items)
                   .OrderBy(s => s));;
        }
Ejemplo n.º 4
0
        public void BalanceItemFact()
        {
            var s    = "abAB";
            var item = new BalanceItem("ab", 0, 3);

            Assert.Equal(4, item.Distance());
            Assert.True(item.IsBalance(s));
            Assert.False(item.IsShortedBalance());
            Assert.True(item.IsUpperLowerSet());

            item.AddLowerCase('c');
            Assert.Equal("ABC", item.UpperCases);
        }
Ejemplo n.º 5
0
        public void AddPurchaseTest()
        {
            var result = new BalanceItem();

            result.Item      = "Кирка";
            result.Gold      = 100;
            result.Category  = BalanceCategory.Mine;
            result.BigTicket = true;
            result.IsProfit  = false;

            ObjectProvider.Instance.AddBalanceItem(result);
            Assert.Greater(result.ID, 0);
        }
Ejemplo n.º 6
0
        public void ShortestBalanceItemFact()
        {
            Assert.Equal("aaa", new String(new List <char> {
                'a', 'a', 'a'
            }.ToArray()));

            var s    = "aA";
            var item = new BalanceItem('a', 0, 1);

            Assert.Equal(2, item.Distance());
            Assert.True(item.IsBalance(s));
            Assert.True(item.IsShortedBalance());
            Assert.True(item.IsUpperLowerSet());
        }
Ejemplo n.º 7
0
 public void AddItem(BalanceItem item)
 {
     Items.Add(item);
     EloSum += item.EloSum;
     Count  += item.Count;
     if (Count > 0)
     {
         AvgElo = EloSum / Count;
     }
     else
     {
         AvgElo = 0;
     }
 }
Ejemplo n.º 8
0
        public Balance getBalance()
        {
            var response = _api.Account.GetBalance().Result;

            if (response == null)
            {
                throw new Exception($"[{DateTime.UtcNow.TimeOfDay}] Критическая ошибка. Ордербук вообще не вернулся с сервера HitBtc. Возможно не подходит pairName.");
            }

            if (response.Error != null)
            {
                throw new Exception(response.Exception.ToString());
            }

            if (response.Exception != null)
            {
                throw new Exception(response.Error.ToString());
            }

            if (_symbol == null)
            {
                throw new Exception("инструмент не найден, перед запросом баланса - необходимо получить данные по инструменту");
            }

            BalanceItem baseBalance  = null;
            BalanceItem quoteBalance = null;

            foreach (var item in response.BalanceList)
            {
                if (item.Currency == _symbol.BaseCurrency)
                {
                    baseBalance = new BalanceItem(_symbol.BaseCurrency, item.Available);
                }
                if (item.Currency == _symbol.QuoteCurrency)
                {
                    quoteBalance = new BalanceItem(_symbol.QuoteCurrency, item.Available);
                }
            }

            if (baseBalance == null)
            {
                baseBalance = new BalanceItem(_symbol.BaseCurrency, 0);
            }
            if (quoteBalance == null)
            {
                quoteBalance = new BalanceItem(_symbol.QuoteCurrency, 0);
            }

            return(new Balance(baseBalance, quoteBalance));
        }
Ejemplo n.º 9
0
 public void RemoveItem(BalanceItem item)
 {
     Items.Remove(item);
     EloSum -= item.EloSum;
     Count  -= item.Count;
     if (Count > 0)
     {
         AvgElo = EloSum / Count;
     }
     else
     {
         AvgElo = 0;
     }
 }
Ejemplo n.º 10
0
 public void AddItem(BalanceItem item)
 {
     Items.Add(item);
     item.EloElements.ForEach(x => {
         double oldAvg = EloAvg;
         EloSum       += x;
         EloAvg        = EloSum / ++Count;
         EloVarSum    += (x - oldAvg) * (x - EloAvg);
     });
     if (Count > 1)
     {
         EloVar = EloVarSum / (Count - 1);
     }
     EloStdev = Math.Sqrt(EloVar);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates the balance item.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        private BalanceItem CreateBalanceItem(IDataRecord reader)
        {
            var result = new BalanceItem();

            result.Date     = reader.GetDateTime(0);
            result.IsProfit = reader.GetBoolean(1);

            result.Category    = (BalanceCategory)reader.GetByte(2);
            result.Gold        = reader.GetInt32(3);
            result.Cristal     = reader.GetInt16(4);
            result.Item        = reader.GetString(5);
            result.SmallTicket = reader.GetBoolean(6);
            result.BigTicket   = reader.GetBoolean(7);

            return(result);
        }
Ejemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            BalanceItem bi = null;

            try
            {
                bi = new BalanceItem(_balanceItemsRepository.BalanceItems.First(x => x.Id.Equals(id)));
            }
            catch (Exception ex)
            {
                SetErrorMessage("Error cancelling product change: {0}", ex.Message);
                Error("Error showing confirmation to delete from balance_item", ex);
            }

            return(View("Delete", bi));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds the purchase.
        /// </summary>
        /// <param name="result">The result.</param>
        public void AddBalanceItem(BalanceItem result)
        {
            var command = (OleDbCommand)connection.CreateCommand(
                @"INSERT INTO [AccountBalance]
([Profit],[CategoryID],[Gold], [Cristal],[Item],[SmallTicket],[BigTicket])
VALUES (?,?,?,?,?,?,?)");

            command.AddParameter("@Profit", result.IsProfit);
            command.AddParameter("@CategoryID", (byte)result.Category);
            command.AddParameter("@Gold", result.Gold);
            command.AddParameter("@Cristal", (byte)result.Cristal);
            command.AddParameter("@Item", result.Item);
            command.AddParameter("@SmallTicket", result.SmallTicket);
            command.AddParameter("@BigTicket", result.BigTicket);

            command.ExecuteNonQuery();
            result.ID = connection.GetInsertedID();
        }
Ejemplo n.º 14
0
        //실시간 종목 조회 응답시//
        private void UpdateAccountBalanceDataGridViewRow(string itemCode, long c_lPrice)
        {
            if (balanceItemList.Find(o => (o.itemCode == itemCode)) != null)
            {
                BalanceItem     item = balanceItemList.Find(o => (o.itemCode == itemCode));
                DataGridViewRow row  = item.ui_rowItem;
                if (row.Index == -1)
                {
                    coreEngine.SendLogErrorMessage(itemCode + " 계좌잔고 ui 업데이트에러");
                    return;
                }
                if (row != null && row.Cells["계좌잔고_종목코드"].Value != null)
                {
                    if (row.Cells["계좌잔고_종목코드"].Value.ToString().Contains(itemCode))
                    {
                        row.Cells["계좌잔고_현재가"].Value = c_lPrice;

                        double buyingPrice     = double.Parse(row.Cells["계좌잔고_평균단가"].Value.ToString());
                        int    balanceCount    = int.Parse(row.Cells["계좌잔고_보유수량"].Value.ToString());
                        double currentAllPrice = c_lPrice * balanceCount;

                        if (buyingPrice != 0)
                        {
                            //row.Cells["계좌잔고_평균단가"].Value = buyingPrice;
                            row.Cells["계좌잔고_평가금액"].Value = currentAllPrice;

                            double sellPrice    = buyingPrice;                                                 // 평단가
                            double stockFee     = ((double)c_lPrice * 0.01 * FEE_RATE) * (double)balanceCount; //+ ((double)c_lPrice * 0.01 * 0.015 * (double)balanceCount); //+ ((double)buyingPrice * 0.01 * 0.015 * (double)balanceCount);
                            double allSellPrice = (sellPrice * (double)balanceCount) + stockFee;

                            row.Cells["계좌잔고_손익금액"].Value = (currentAllPrice - allSellPrice);

                            double profitRate = GetProfitRate((double)c_lPrice, (double)sellPrice);
                            row.Cells["계좌잔고_손익률"].Value = double.Parse(profitRate.ToString("F2"));
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void ParseData(HtmlDocument document)
        {
            string[] ar;

            string tempName = "", tempCode, tempPrice;
            var    td = document.DocumentNode.SelectNodes("//table/tbody/tr/td/p").FirstOrDefault(x => x.InnerText.IndexOf("kodas ir pavadinimas") > 0);

            _loaded.Clear();
            if (td != null)
            {
                //Log4cs.Log("Got header of guns list...");
                var tbody = td.ParentNode.ParentNode.ParentNode;
                if (tbody != null)
                {
                    var trs = tbody.SelectNodes(".//tr");
                    //Log4cs.Log("Got {0} rows in guns table", trs == null ? "NO" : trs.Count.ToString());
                    // Skip first row - header
                    for (int i = 1; i < trs.Count; i++)
                    {
                        var tds = trs[i].SelectNodes(".//td");
                        if (tds.Count > 2)
                        {
                            try
                            {
                                BalanceItem bi = new BalanceItem();

                                tempName  = tds[0].InnerText.Replace("&nbsp;", "").Trim();
                                tempCode  = tds[1].InnerText.Replace("&nbsp;", "").Trim();
                                tempPrice = tds[2].InnerText.Replace("&nbsp;", "").Trim();
                                //Log4cs.Log("Name: {0}, price: {1}, code: {2}", tempName, tempPrice, tempCode);
                                ar = tempName.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                                try
                                {
                                    bi.Quantity     = 1;
                                    bi.InternalCode = tempCode;
                                    bi.ProductName  = tempName;
                                    //g.TypeOfGun = GetTypeByName(ar[1]);
                                    //g.Name = tempName;
                                    //g.Code = tempCode;
                                } catch (KeyNotFoundException)
                                {
                                    //g = ParseLineHarder(tempName);
                                    //if(g == null)
                                    //{
                                    //    sbIncorrectLines.AppendLine(tempName);
                                    //    throw;
                                    //}
                                }

                                bi.Price = decimal.Parse(tempPrice);

                                _loaded.Add(bi);
                                //AddOrUpdate(g);
                            } catch (Exception ex)
                            {
                                //Log4cs.Log(Importance.Error, "Error parsing and saving Gun object!");
                                //Log4cs.Log(Importance.Debug, ex.ToString());
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 public void RemoveItem(BalanceItem item)
 {
     Items.Remove(item);
     EloSum -= item.EloSum;
     Count -= item.Count;
     if (Count > 0) AvgElo = EloSum / Count;
     else AvgElo = 0;
 }
Ejemplo n.º 17
0
 public void AddItem(BalanceItem item)
 {
     Items.Add(item);
     EloSum += item.EloSum;
     Count += item.Count;
     if (Count > 0) AvgElo = EloSum / Count;
     else AvgElo = 0;
 }
Ejemplo n.º 18
0
 public ActionResult Index(BalanceItem model)
 {
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 19
0
 public BalanceItemViewModel(BalanceItem balanceItem)
 {
     BalanceItem = balanceItem;
 }