public void SaveHistoryTrend(HistoryCount data) { SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd = new SqlCommand("INSERT INTO [lottery].[dbo].[HistoryTrend] ([Date],[WinNumber]," + "[WanDa],[WanXiao],[QianDa],[QianXiao],[BaiDa],[BaiXiao],[ShiDa],[ShiXiao],[GeDa],[GeXiao])" + "VALUES (@Date, @WinNumber, " + "@WanDa,@WanXiao, @QianDa,@QianXiao,@BaiDa,@BaiXiao,@ShiDa,@ShiXiao,@GeDa,@GeXiao)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Date", data.Date); cmd.Parameters.AddWithValue("@WinNumber", data.WinNumber); cmd.Parameters.AddWithValue("@WanDa", data.WanDa); cmd.Parameters.AddWithValue("@WanXiao", data.WanXiao); cmd.Parameters.AddWithValue("@QianDa", data.QianDa); cmd.Parameters.AddWithValue("@QianXiao", data.QianXiao); cmd.Parameters.AddWithValue("@BaiDa", data.BaiDa); cmd.Parameters.AddWithValue("@BaiXiao", data.BaiXiao); cmd.Parameters.AddWithValue("@ShiDa", data.ShiDa); cmd.Parameters.AddWithValue("@ShiXiao", data.ShiXiao); cmd.Parameters.AddWithValue("@GeDa", data.GeDa); cmd.Parameters.AddWithValue("@GeXiao", data.GeXiao); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
public static HistoryCount bigorsmall(HistoryCount history) { // ge if (history.Single < 5) { history.GeDa++; history.GeXiao = 0; } else if (history.Single >= 5) { history.GeXiao++; history.GeDa = 0; } return(history); }
public HistoryCount GetHistoryTrend(string date) { HistoryCount data = new HistoryCount(); SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd = new SqlCommand("SELECT * from [lottery].[dbo].[HistoryTrend] Where [Date] = @Date", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Date", date); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { data.ID = (int)dr["ID"]; data.Date = dr["Date"].ToString(); data.WinNumber = dr["WinNumber"].ToString(); data.GeDa = (int)dr["GeDa"]; data.GeXiao = (int)dr["GeXiao"]; } con.Close(); return(data); }
// Only bet on wan big public void StatisticalBig(decimal balance, int times, int initialBet, int increment, string note, Guid testId) { AccountBalance = balance; Bet = initialBet; bool GameOver = false; Database db = new Database(); List <History> data = new List <History>(); data = db.GetHistoryList(); DateTime testDate = DateTime.Now; HistoryCount history = new HistoryCount(); bool trade = false; string showList = ""; foreach (var i in data) { if (TotalCount <= times) { int winning = Convert.ToInt32(i.Single); if (!GameOver && trade) { if (PickedNumber.Contains(winning)) { WinCount++; AccountBalance = BalanceCalculation(AccountBalance, Bet, true); Console.WriteLine("{0} 期开奖, 中奖号码:{1}, 投注号码:{2}, 购买金额:{3}, 中奖! 可用资金: {4}", i.ID, winning, showList, Bet, AccountBalance); db.SaveStatistics(i, AccountBalance, testId, testDate, Bet, showList, false, true, note); // Bet for next time Bet = initialBet; } else { LossCount++; AccountBalance = BalanceCalculation(AccountBalance, Bet, false); Console.WriteLine("{0} 期开奖, 中奖号码:{1}, 投注号码:{2}, 购买金额:{3}, 未中奖! 可用资金: {4}", i.ID, winning, showList, Bet, AccountBalance); // Bet for next time int lastBet = Bet; // Strategy Testing Bet = ConstantInc(Bet, increment, AccountBalance, initialBet); bool stopLoss = Bet < lastBet ? true : false; db.SaveStatistics(i, AccountBalance, testId, testDate, lastBet, showList, stopLoss, false, note); } TotalCount++; } // get from db history = db.GetHistoryTrend(i.Date); // Pick Number for next round if (history.GeDa >= 7) { PickedNumber = new List <int> { 5, 6, 7, 8, 9 }; trade = true; showList = string.Join(" ", PickedNumber.ToArray()); } else if (history.GeXiao >= 7) { PickedNumber = new List <int> { 0, 1, 2, 3, 4 }; trade = true; showList = string.Join(" ", PickedNumber.ToArray()); } else { trade = false; Bet = initialBet; } if (AccountBalance <= 0) { GameOver = true; Console.WriteLine("本金不足, 爆仓!!!"); break; } } } }