股票trueDate方法

/**
    * 簡稱:trueDate<br/>
    * 名稱:返回指定Bar的真正交易日期<br/>
    * 類別: 用戶函數<br/>
    * 類型: 內建函數<br/>
    * @param list
    * @param bar
    * @param length
    * @return
    * @throws ParseException     */    public static int trueDate(int length) throws ParseException {          type=5;     int newDate, dayOffset, dow;      //    if (barType(bar) == 0 || barType(bar) == 4 || barType(bar) == 5) { //     newDate = backDate2(list, length).date; //    } //    else { //     dayOffset = 0; //     dow = weekDay(backDate2(list, length)); //     if (hour(backDate2(list, length)) >= 18) { //      if (dow == 5) // 週五晚上 //      { //       dayOffset = 3; //      } else if (dow == 6) // 週六晚上 //      { //       dayOffset = 2; //      } else { //       dayOffset = 1; //      } //     } else { //      if (dow == 6) // 週六 //      { //       dayOffset = 2; //      } else if (dow == 0) // 週日 //      { //       dayOffset = 1; //      } //     } //     newDate = dateAdd(backDate2(list, length).date, dayOffset); //    }          //另改寫了該方法     Bar bar1=new Bar();     bar1.date=20140629;      bar1.time=1030;     Bar bar2=new Bar();     bar2.date=20140701;     bar2.time=1830;     Bar bar3=new Bar();     bar3.date=20140702;     bar3.time=1930;     Bar bar4=new Bar();     bar4.date=20140705;     bar4.time=930;     List<Bar> list=new ArrayList<Bar>();     list.add(bar1);     list.add(bar2);     list.add(bar3);     list.add(bar4);     type=5;     if (type == 24 || type == 7 || type == 31) {      newDate = backDate2(list, length).date;     }     else {      dayOffset = 0;      dow = weekDay(backDate2(list, length));      if (hour(backDate2(list, length)) >= 18) {       if (dow == 5) // 週五晚上       {        dayOffset = 3;       } else if (dow == 6) // 週六晚上       {        dayOffset = 2;       } else {        dayOffset = 1;       }      } else {       if (dow == 6) // 週六       {        dayOffset = 2;       } else if (dow == 0) // 週日       {        dayOffset = 1;       }      }      newDate = dateAdd(backDate2(list, length).date, dayOffset);     }     System.out.println("真正交易日"+newDate);     return newDate;    }
相關文章
相關標籤/搜索