/// <summary> /// Get input data - S&P 500 Index, Prime Interest Rate, Dow index, Nasdaq index /// </summary> /// <param name="offset">Start index of input data</param> /// <param name="input">Array to be populated</param> /// <remarks> /// According to the <c>offset</c> parameter, first <c>_inputSize</c> values are drawn from the dataset /// </remarks> public void GetInputData(int offset, double[] input) { int total = 0; int k = 0; // get OHLCVI *_pointCount for (int i = 0; i < _pointCount; i++) { PredicInput sample = _samples[offset + i]; k = 0; foreach (PredicInputIndexe index in Enum.GetValues(typeof(PredicInputIndexe))) { if (sample.IsSetValue((int)index)) { input[i * total + k] = sample.GetValue((int)index); k++; } } if (total < 1) { total = k; } //input[i*4] = sample.Open; //input[i*4 + 1] = sample.H; //input[i*4 + 2] = sample.L; //input[i*4 + 3] = sample.C; } }
/// <summary> /// Get output data - S&P 500 Index, Prime Interest Rate, Dow index, Nasdaq index /// </summary> /// <param name="offset">Start index of output data</param> /// <param name="output">Output array to be populated</param> /// <remarks> /// The value of <c>offset + _inputSize</c> indexes value are drawn from the samples data set. /// E.g. Consider the <c>offset</c> parameter equal to 12581. Input parameters to the network will be /// values from [12581..12590]. The actual values will be equal to the parameters stored in the <code>12581 + _inputSize</code> /// place => 12591 index. /// </remarks> public void GetOutputData(int offset, double[] output) { PredicInput sample = _samples[offset + _pointCount + _predictDayplus]; output[0] = sample.GetValue((int)PredicInputIndexe.CloseIndex); //output[1] = sample.PrimeInterestRate; //output[2] = sample.Commodity; //output[3] = sample.VolumeCommo; }
//Load data Ticker private void Button1_Click(object sender, EventArgs e) { //load dl ticker string connstring = String.Format("Server={0};Port={1};" + "User Id={2};Password={3};Database={4};", "127.0.0.1", "5433", "lemon", "admin", "DailyTrading"); var tickerbase = txtTicker.Text; var dao = new TickerDAO(connstring, tickerbase); listPredicInput.Clear(); _maxDate = new DateTime(2000, 01, 01); _minDate = DateTime.Now.Date; //check db da tao chua var isexistticker = dao.IsTableExisted(tickerbase); if (isexistticker) { var listdata = dao.SelectALL(tickerbase); foreach (var data in listdata) { var predicInput = new PredicInput(); predicInput.Date = data.Day; predicInput.SetValue((int)PredicInputIndexe.OpenIndex, data.Open); predicInput.SetValue((int)PredicInputIndexe.HighIndex, data.Hight); predicInput.SetValue((int)PredicInputIndexe.LowIndex, data.Low); predicInput.SetValue((int)PredicInputIndexe.CloseIndex, data.Close); predicInput.SetValue((int)PredicInputIndexe.VolumeIndex, data.Volume); predicInput.SetValue((int)PredicInputIndexe.VNIndex, 0); listPredicInput.Add(predicInput); if (_maxDate.Date < data.Day) { _maxDate = data.Day; } if (_minDate.Date > data.Day) { _minDate = data.Day; } } } else { MessageBox.Show("Load dl ticker khong thanh cong"); return; } dao.Dispose(); //load dl vnindex var daoindex = new TickerDAO(connstring, txtVNIndex.Text); isexistticker = daoindex.IsTableExisted(txtVNIndex.Text); if (isexistticker) { var listdata = daoindex.SelectALL(txtVNIndex.Text); foreach (var data in listPredicInput) { foreach (TickerBase index in from index in listdata where index.Day == data.Date select index) { data.SetValue((int)PredicInputIndexe.VNIndex, index.Close); } } } else { MessageBox.Show("Load dl ticker VNIndex khong thanh cong"); return; } daoindex.Dispose(); //set value to txtbox txtstartDate.Text = _minDate.Date.ToShortDateString(); _dtpTrainFrom.Value = _minDate.Date; txtEndDate.Text = _maxDate.Date.ToShortDateString(); _dtpTrainUntil.Value = _maxDate.Date.AddDays(-10); _dtpPredictFrom.Value = _maxDate.Date.AddDays(-9); _dtpPredictTo.Value = _maxDate.Date; }
public DateTime GetDateTime(int offset) { PredicInput sample = _samples[offset]; return(sample.Date); }
/* public double GetIndex(DateTime date, int index) * { * double currentAmount = 0; * * foreach (PData data in _dictionary[index]) * { * if (data.Date.CompareTo(date) >= 0) * { * return currentAmount; * } * currentAmount = data.Amount; * } * return currentAmount; * } */ public string GetDate(int offset) { PredicInput sample = _samples[offset]; return(sample.Date.ToShortDateString()); }