public Boolean dealStopRatioRule(string appDir, string fileName)//讀取逆勢動態停利規則檔 { try { strategyFileName = fileName; strategyFilePath = appDir + "\\" + Config_Dir + "\\" + fileName; strategyFile = new TradeFile(strategyFilePath); strategyFile.prepareReader(); stopRatio = new Dictionary <int, int>(); int checkRange; //最高點與最低點的範圍 int ratio; //停利或是停損的計算百分比 String tmpLine = ""; String[] tmpData = new String[2]; while (strategyFile.hasNext()) { tmpLine = strategyFile.getLine(); tmpData = tmpLine.Split(','); checkRange = int.Parse(tmpData[0]); ratio = int.Parse(tmpData[1]); stopRatio.Add(checkRange, ratio); } Console.WriteLine(stopRatio.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return(false); } return(true); }
public List<OriginalRecord> prepareRecordList() { recordList = new List<OriginalRecord>(); try { for (int i = 0; i < sourceFileList.Count; i++) { sourceFile = sourceFileList[i]; sourceFile.prepareReader(); while (sourceFile.hasNext()) { nowLine = sourceFile.getLine(); record = OriginalRecordConverter.getOriginalRecord(nowLine); recordList.Add(record); }//end while sourceFile.close(); }//end for return recordList; } catch (Exception e) { Console.WriteLine(e.StackTrace); return null; } }
public Boolean dealStopRatioRule(string appDir, string fileName)//讀取逆勢動態停利規則檔 { try { strategyFileName = fileName; strategyFilePath = appDir + "\\" + Config_Dir + "\\" + fileName; strategyFile = new TradeFile(strategyFilePath); strategyFile.prepareReader(); stopRatio = new Dictionary<int, int>(); int checkRange;//最高點與最低點的範圍 int ratio;//停利或是停損的計算百分比 String tmpLine = ""; String[] tmpData = new String[2]; while (strategyFile.hasNext()) { tmpLine = strategyFile.getLine(); tmpData = tmpLine.Split(','); checkRange = int.Parse(tmpData[0]); ratio = int.Parse(tmpData[1]); stopRatio.Add(checkRange, ratio); } Console.WriteLine(stopRatio.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return false; } return true; }
public Boolean dealStrategyRule(string appDir, string fileName)//讀取停損停利規則檔 { try { strategyFileName = fileName; strategyFilePath = appDir + "\\" + Config_Dir + "\\" + fileName; strategyFile = new TradeFile(strategyFilePath); strategyFile.prepareReader(); loseLine = new Dictionary <int, int>(); winLine = new Dictionary <int, int>(); reverseLine = new Dictionary <int, double>(); int strategyCount = 1; //讀取停損停利規則檔案的行數 int losePoint; //停損點範圍 int winPoint; //停利點範圍 double reversePoint; //動態停利反轉範圍 String tmpLine = ""; String[] tmpData = new String[3]; while (strategyFile.hasNext()) { tmpLine = strategyFile.getLine(); if (tmpLine.StartsWith("#") || tmpLine.Trim().Equals("")) { continue; } tmpData = tmpLine.Split(','); losePoint = int.Parse(tmpData[0]); winPoint = int.Parse(tmpData[1]); try { reversePoint = double.Parse(tmpData[2]); } catch (Exception) { reversePoint = 1; } loseLine.Add(strategyCount, losePoint); winLine.Add(strategyCount, winPoint); reverseLine.Add(strategyCount, reversePoint); strategyCount++; } maxStrategyCount = --strategyCount; for (int i = 1; i <= maxStrategyCount; i++) { Console.WriteLine("loseLine[" + i + "] : " + loseLine[i]); Console.WriteLine("winLine[" + i + "] : " + winLine[i]); Console.WriteLine("reverseLine[" + i + "] : " + reverseLine[i]); } } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return(false); } return(true); }
public Boolean dealStrategyRule(string appDir, string fileName)//讀取停損停利規則檔 { try { strategyFileName = fileName; strategyFilePath = appDir + "\\" + Config_Dir + "\\" + fileName; strategyFile = new TradeFile(strategyFilePath); strategyFile.prepareReader(); loseLine = new Dictionary<int, int>(); winLine = new Dictionary<int, int>(); reverseLine = new Dictionary<int, double>(); int strategyCount = 1;//讀取停損停利規則檔案的行數 int losePoint;//停損點範圍 int winPoint;//停利點範圍 double reversePoint;//動態停利反轉範圍 String tmpLine = ""; String[] tmpData = new String[3]; while (strategyFile.hasNext()) { tmpLine = strategyFile.getLine(); if (tmpLine.StartsWith("#") || tmpLine.Trim().Equals("")) { continue; } tmpData = tmpLine.Split(','); losePoint = int.Parse(tmpData[0]); winPoint = int.Parse(tmpData[1]); try { reversePoint = double.Parse(tmpData[2]); } catch (Exception ) { reversePoint = 1; } loseLine.Add(strategyCount, losePoint); winLine.Add(strategyCount, winPoint); reverseLine.Add(strategyCount, reversePoint); strategyCount++; } maxStrategyCount = --strategyCount; for (int i = 1; i <= maxStrategyCount; i++) { Console.WriteLine("loseLine[" + i + "] : " + loseLine[i]); Console.WriteLine("winLine[" + i + "] : " + winLine[i]); Console.WriteLine("reverseLine[" + i + "] : " + reverseLine[i]); } } catch (Exception ex) { Console.WriteLine(ex.Source); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); return false; } return true; }