private void repair(ref MinuteLine ml, double _range, int _len) { ml.open = Math.Round((ml.open / _range), _len); ml.close = Math.Round((ml.close / _range), _len); ml.low = Math.Round((ml.low / _range), _len); ml.high = Math.Round((ml.high / _range), _len); }
private void fillMinuteBar(double val, ref MinuteLine ml) { double lowRng = MyRandom.getRandom(0, 32) / 100.0; double higthRng = MyRandom.getRandom(0, 46) / 100.0; double lowVal = val * lowRng; double higthVal = val * higthRng; ml.close = ml.open + val; ml.low = ml.open - lowVal; ml.high = ml.close + higthVal; }
public bool toMinute(string _symbol, double _range, int _len) { if (dayLines.Count == 0) { Console.WriteLine("没有日线,无法转换"); return(false); } foreach (DayLine yml in dayLines) { double openPrice = yml.open; int curCount = 1440; int maxCount = curCount; double curVal = yml.close - yml.open; double maxVal = curVal; for (int i = 0; i <= 1439; i++) { MinuteLine vk = new MinuteLine(); vk.symbol = _symbol; vk.year = yml.year; vk.month = yml.month; vk.day = yml.day; vk.hour = i / 60; vk.minute = i % 60; double val = getUpMinute(curCount, curVal, maxCount, maxVal); curVal -= val; curCount--; vk.open = openPrice; vk.type = "default"; // 填充K线 fillMinuteBar(val, ref vk); //记录下一次开盘价 openPrice = vk.close + minPrice; // 完善K线 repair(ref vk, _range, _len); // 添加到队列 minuteLines.Add(vk); Console.WriteLine("开:" + vk.open + ", 收:" + vk.close + ", 高:" + vk.high + ", 低:" + vk.low); } } return(true); }