static void RequestTxS() { List <StockDb> dbS = GetAllDbS(); txS.Clear(); sumSZ = 0; sumYK = 0; allLastSZ = 0; todayYK = 0; sumCB = 0; foreach (var db in dbS) { StockTx tx = GetStock(db.id); tx.sz = db.count * float.Parse(tx.nowPri); tx.todayYingkui = tx.increase * db.count;//这样计算,当天买卖,盈利是有问题的。 tx.cbPri = db.cbPrice; tx.sumYK = db.count * float.Parse(tx.nowPri) - db.cb; tx.allYingkuiRate = tx.sumYK / db.cb * 100; tx.ratio = db.ratio; sumSZ += tx.sz; sumYK += tx.sumYK; allLastSZ += float.Parse(tx.lastDayPri) * db.count; todayYK += tx.todayYingkui; sumCB += db.cb; //txS.Add txS.Add(tx); } sumYK += GetSelledIncrease(); toadyYKRate = todayYK / allLastSZ; }
public static void Debug_SumYK() { U_Console.ClearDenbug(); DebugTitle("e累计盈亏↓"); RequestTxS(); txS.Sort((a, b) => - a.sumYK.CompareTo(b.sumYK)); StockTx.DebugList(txS); DebugSum(todayYK, toadyYKRate, sumYK, sumCB, sumSZ); }
static string GetStrZhishu() { StockTx sh = GetStock("000001"); StockTx sz = GetStock("399001"); StockTx cy = GetStock("399006"); string res = ""; if (is显示指数的数值) { res = "| 上" + float.Parse(sh.nowPri).ToStringF0() + " " + sh.increPer.ToStringF2() + "%" + " 创" + float.Parse(cy.nowPri).ToStringF0() + " " + cy.increPer.ToStringF2() + "%" + " 深" + float.Parse(sz.nowPri).ToStringF0() + " " + sz.increPer.ToStringF2() + "%\t|"; } else { res = "| 上" + sh.increPer.ToStringF2() + "% 创" + cy.increPer.ToStringF2() + "% 深" + sz.increPer.ToStringF2() + "%\t|"; } return(res); }
void InsertData(StockDb stock) { StockTx stockWeb = U_Stock.GetStock(id.ToString()); if (stockWeb == null) { Debug.Log("查不到该编号"); return; } if (count < 0) { Debug.Log("并没有持有,无法为负数"); return; } stock.cbPrice = price; stock.name = stockWeb.name; stock.count = count; stock.cb = count * price; stock.cbK = stock.cb / 1000f; sumCB += stock.cb; stock.ratio = stock.cb / sumCB * 100; stockS.Add(stock); OpenSql(); sql.Insert( holdStocks, new string[] { "id", "name", "cbPrice", "count", "cb", "cbK", "ratio" }, new string[] { stock.id.ToString(), stock.name, stock.cbPrice.ToStringF3(), stock.count.ToString(), stock.cb.ToStringF2(), stock.cbK.ToStringF2(), stock.ratio.ToStringF2() } ); UpdateEveryRatio(); CloseSql(); Debug.Log("买入:" + stock.name + "\tprice" + price + "\tcount" + count); }
IEnumerator RequestTx(SortType sortType) { List <StockTx> stockTxS = new List <StockTx>(); float sumSZ = 0; float sumYK = 0; float allLastSZ = 0; float todayAllYK = 0; float sumCB = 0; float toadyAllYKRate = 0; List <StockDb> dbS = GetAllDbS(enShowType); foreach (StockDb db in dbS) { string url = 拼接Url(db.id); WWW www = new WWW(url); yield return(www); StockTx tx = new StockTx(www.text); tx.sz = db.count * float.Parse(tx.nowPri); tx.todayYingkui = tx.increase * db.count;//这样计算,当天买卖,盈利是有问题的。 tx.cbPri = db.cbPrice; tx.sumYK = db.count * float.Parse(tx.nowPri) - db.cb; tx.allYingkuiRate = tx.sumYK / db.cb * 100; tx.ratio = db.ratio; sumSZ += tx.sz; sumYK += tx.sumYK; sumCB += db.cb; stockTxS.Add(tx); allLastSZ += float.Parse(tx.lastDayPri) * db.count; todayAllYK += tx.todayYingkui; } float allSelledYK = GetSelledIncrease(enShowType); if (!isOnlyShowChiCang) { sumYK += allSelledYK; } string total = ""; if (stockTxS.Count == dbS.Count) { toadyAllYKRate = todayAllYK / allLastSZ; total = DebugSum_WithoutZhishu(todayAllYK, toadyAllYKRate, sumYK, sumCB, sumSZ) + "|"; } #region Zhishu List <string> zhishuS = new List <string>() { "000001", "399001", "399006" }; List <StockTx> zhishuTx = new List <StockTx>(); foreach (var item in zhishuS) { string url = 拼接Url(item); WWW www = new WWW(url); yield return(www); if (www.error != null) { Debug.LogError("获取地址错误"); yield break; } string res = www.text; StockTx tx = new StockTx(res); zhishuTx.Add(tx); } string strZhishuInfo; if (zhishuTx.Count == 3) { StockTx sh = zhishuTx.FirstOrDefault(s => s.id == "000001"); StockTx sz = zhishuTx.FirstOrDefault(s => s.id == "399001"); StockTx cy = zhishuTx.FirstOrDefault(s => s.id == "399006"); if (show指数数值) { strZhishuInfo = "上" + float.Parse(sh.nowPri).ToStringF0() + " " + sh.increPer.ToStringF2() + "%" + " 创" + float.Parse(cy.nowPri).ToStringF0() + " " + cy.increPer.ToStringF2() + "%" + " 深" + float.Parse(sz.nowPri).ToStringF0() + " " + sz.increPer.ToStringF2() + "%\t|"; } else { strZhishuInfo = "上" + cy.increPer.ToStringF2() + "% 创" + sz.increPer.ToStringF2() + "% 深" + sz.increPer.ToStringF2() + "%\t|"; } if (isDebugStock) { U_Console.ClearDenbug(); //最终是在此处打印的,是为了让他同一时间闪出来,控制台刷新感更小 DebugStockS(stockTxS, sortType); if (isShowSelledYK) { if (allSelledYK > 0) { Debug.Log("清仓累计:\t+" + allSelledYK); } else { Debug.Log("清仓累计:\t" + allSelledYK); } } if (isIndexAndTotalSameLine) { Debug.Log(total + " " + strZhishuInfo); } else { Debug.Log(total); Debug.Log(strZhishuInfo); } } } #endregion }