Example #1
0
        // set last hold krw using API
        public int setLastKrw()
        {
            JArray retData = apiData.getAsset();

            if (retData == null)
            {
                return(-1);
            }

            for (int i = 0; i < retData.Count; i++)
            {
                if (retData[i]["currency"].ToString() == "KRW")
                {
                    holdKRW = (double)retData[i]["balance"];
                    return(0);
                }
            }

            return(-2);
        }
        public Profit(ApiData apiData, string coinName, double startKrw)
        {
            var asset     = apiData.getAsset();
            var krwAsset  = asset.Where(x => "KRW".Equals(x.Value <string>("currency"))).FirstOrDefault();
            var coinAsset = asset.Where(x => coinName.Equals(x.Value <string>("currency"))).FirstOrDefault();

            if (krwAsset != null)
            {
                KRWBalance = krwAsset.Value <double>("balance");
            }

            if (coinAsset != null)
            {
                CoinBalance  = krwAsset.Value <double>("balance");
                CoinAvgPrice = krwAsset.Value <double>("avg_buy_price");
                CoinAmount   = CoinBalance * CoinAvgPrice;
            }

            TotalKrw      = KRWBalance + CoinAmount;
            KrwProfit     = TotalKrw - startKrw;
            KrwProfitRate = KrwProfit / startKrw * 100;
        }
Example #3
0
        private int updateAccount()
        {
            JArray jArray = apiData.getAsset();

            if (jArray == null)
            {
                return(-1);
            }

            account.Clear();
            for (int i = 0; i < jArray.Count; i++)
            {
                if (!"USDT".Equals(jArray[i]["currency"].ToString().ToUpper()))
                {
                    account.Add(new Account(
                                    jArray[i]["currency"].ToString(),
                                    (double)jArray[i]["locked"],
                                    (double)jArray[i]["balance"])
                                );
                }
            }

            return(0);
        }