public void loadScenario(clsMAST_FP_INSTRUMENT_TB.FP_MASTER_TYP_Type? fi_type) { this.clstbList_.Clear(); clsSET_SCENARIO_TB clstb = new clsSET_SCENARIO_TB(); clstb.FP_MASTER_TYP = (int)(fi_type.Value); DataTable dt = clstb.Select(); foreach (DataRow dr in dt.Select() ) { this.clstbList_.Add(clsSET_SCENARIO_TB.Create(dr)); } }
public virtual void build_emptyResult(DateTime refDate) { clsHITM_FP_GREEKRESULT_TB clstb = new clsHITM_FP_GREEKRESULT_TB(); string refDateStr = refDate.ToString("yyyyMMdd"); List<string> underlyingList = new List<string>(); this.underlyingList(underlyingList); clstb.FP_GREEKRESULT_ID = IDGenerator.getNewGreekResultID(this.baseDAO_.INSTRUMENT_ID, refDateStr); clstb.CALC_DT = refDateStr; clstb.INSTRUMENT_ID = this.baseDAO_.INSTRUMENT_ID; clstb.INSTRUMENT_TYP = this.baseDAO_.FP_MASTER_TYP; int i = 1; foreach (string under in underlyingList) { clstb.UNDERLYING_ID = under; clstb.UNDERLYING_VALUE = 0.0; clstb.SEQ = i; clstb.DELTA = 0.0; clstb.GAMMA = 0.0; clstb.VEGA = 0.0; clstb.CALC_PRICE = 0.0; clstb.CALCULATED_FLAG = 0; clstb.CALCULATED_TIME = ""; clstb.CALCULATE_TYP = 0; clstb.Insert(); i += 1; } // SCENARIO 팀장 미친 개새끼 clsSET_SCENARIO_TB cls_scenario = new clsSET_SCENARIO_TB(); cls_scenario.FP_MASTER_TYP = this.baseDAO_.FP_MASTER_TYP; DataTable dt = cls_scenario.Select(); foreach (DataRow dr in dt.Select()) { clstb.UNDERLYING_ID = clsSET_SCENARIO_TB.Create(dr).SCENARIO_CD; clstb.SEQ = i; clstb.Insert(); i += 1; } // 지워 clsHITM_FP_CASHFLOWRESULT_TB clstb_cf = new clsHITM_FP_CASHFLOWRESULT_TB(); clstb_cf.CALC_DT = refDate.ToString("yyyyMMdd"); clstb_cf.INSTRUMENT_ID = this.baseDAO_.INSTRUMENT_ID; clstb_cf.DeleteInstDateCashFlow(); }
public clsSET_SCENARIO_TB Clone() { try { clsSET_SCENARIO_TB cloneTB = new clsSET_SCENARIO_TB(); cloneTB._FP_MASTER_TYP = this._FP_MASTER_TYP; cloneTB._SCENARIO_CD = this._SCENARIO_CD; cloneTB._CURVE_CD = this._CURVE_CD; cloneTB._PARALLEL_SHIFT_UNIT = this._PARALLEL_SHIFT_UNIT; cloneTB._HUMP_SHIFT_UNIT = this._HUMP_SHIFT_UNIT; cloneTB._HUMP_CENTER_T = this._HUMP_CENTER_T; cloneTB._STEEPEN_SHIFT_UNIT = this._STEEPEN_SHIFT_UNIT; cloneTB._STEEPEN_CENTER_T = this._STEEPEN_CENTER_T; return cloneTB; } catch(Exception ex) { throw new Exception(ex.Message); } }
public static clsSET_SCENARIO_TB Create(DataRow dr) { try { clsSET_SCENARIO_TB tb = new clsSET_SCENARIO_TB(); tb._FP_MASTER_TYP = Convert.ToInt32(dr[0]); tb._SCENARIO_CD = Convert.ToString(dr[1]); tb._CURVE_CD = Convert.ToString(dr[2]); tb._PARALLEL_SHIFT_UNIT = Convert.ToDouble(dr[3]); tb._HUMP_SHIFT_UNIT = Convert.ToDouble(dr[4]); tb._HUMP_CENTER_T = Convert.ToDouble(dr[5]); tb._STEEPEN_SHIFT_UNIT = Convert.ToDouble(dr[6]); tb._STEEPEN_CENTER_T = Convert.ToDouble(dr[7]); return tb; } catch(Exception ex) { throw new Exception(ex.Message); } }
public override void calculate(DateTime calcDate, FP_Parameter fp_parameter) { // 돌릴거에 대한 List를 가져옴. List<ScenarioInfo> scenarioInfoList = new List<ScenarioInfo>(); List<double> scenarioCalcList = new List<double>(); clsSET_SCENARIO_TB clstb_scenario = new clsSET_SCENARIO_TB(); // 이걸로 할건지 아니면 세부 swap 으로 할건지 clstb_scenario.FP_MASTER_TYP = this.baseDAO_.FP_MASTER_TYP; DataTable dt = clstb_scenario.Select(); foreach ( DataRow dr in dt.Select() ) { scenarioInfoList.Add(new ScenarioInfo() { DAO_ = clsSET_SCENARIO_TB.Create(dr) }); } foreach (ScenarioInfo sc_info in scenarioInfoList) { fp_parameter.ScenarioInfo_ = sc_info; //fp_parameter.CurveShift_ = new ParallelCurveShift(0.0); double v = this.calculateImpl(calcDate, fp_parameter); sc_info.CalcPrice_ = v; scenarioCalcList.Add(v); } fp_parameter.ScenarioInfo_ = ScenarioInfo.BaseParallelShift(); double value_up = this.calculateImpl(calcDate, fp_parameter); fp_parameter.ScenarioInfo_ = ScenarioInfo.NullScenario(); double value = this.calculateImpl(calcDate, fp_parameter); clsHITM_FP_GREEKRESULT_TB clstb_greekresult = new clsHITM_FP_GREEKRESULT_TB(); clsHDAT_MARKETDATA_TB clstb_market = new clsHDAT_MARKETDATA_TB(); clstb_market.REF_DT = calcDate.ToString("yyyyMMdd"); clstb_market.INDEX_CD = "CD91"; if (clstb_market.SelectOwn() == 0) { throw new Exception("market data does not exist : " + clstb_market.REF_DT + " " + clstb_market.INDEX_CD); } clstb_greekresult.CALC_DT = calcDate.ToString("yyyyMMdd"); clstb_greekresult.INSTRUMENT_ID = this.SwapDAO_.INSTRUMENT_ID; //clstb_greekresult.FP_GREEKRESULT_ID = ""; //clstb_greekresult.INSTRUMENT_TYP = 0; clstb_greekresult.UNDERLYING_ID = clstb_market.INDEX_CD; clstb_greekresult.UNDERLYING_VALUE = clstb_market.LAST; //clstb_greekresult.SEQ = 1; clstb_greekresult.DELTA = value_up - value; clstb_greekresult.GAMMA = 0.0; clstb_greekresult.VEGA = 0.0; clstb_greekresult.CALC_PRICE = value; clstb_greekresult.CALCULATED_FLAG = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATED_FLAG_Type.CALCULATED; clstb_greekresult.CALCULATED_TIME = DateTime.Now.ToString("HHmmss"); clstb_greekresult.CALCULATE_TYP = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATE_TYP_Type.ANALYTICS; // 패러럴 쉬푸투 or 그냥 구한거 머 등등.. clstb_greekresult.UpdateDateResult(); foreach (ScenarioInfo sc_info in scenarioInfoList) { //clstb_greekresult.FP_GREEKRESULT_ID = ""; //clstb_greekresult.INSTRUMENT_TYP = 0; //clstb_greekresult.UNDERLYING_ID = clstb_market.INDEX_CD; clstb_greekresult.UNDERLYING_ID = sc_info.ScenarioCode_; clstb_greekresult.UNDERLYING_VALUE = clstb_market.LAST; //clstb_greekresult.SEQ = 1; clstb_greekresult.DELTA = sc_info.CalcPrice_ - value; clstb_greekresult.GAMMA = 0.0; clstb_greekresult.VEGA = 0.0; // 시나리오의 경우 시나리오 value를 넣음. clstb_greekresult.CALC_PRICE = sc_info.CalcPrice_; clstb_greekresult.CALCULATED_FLAG = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATED_FLAG_Type.CALCULATED; clstb_greekresult.CALCULATED_TIME = DateTime.Now.ToString("HHmmss"); clstb_greekresult.CALCULATE_TYP = (int)clsHITM_FP_GREEKRESULT_TB.CALCULATE_TYP_Type.ANALYTICS; // 패러럴 쉬푸투 or 그냥 구한거 머 등등.. //clstb_greekresult.Insert(); clstb_greekresult.UpdateDateResult(); } #region CashFlow // db 지우는 거? int fixedPayRec = this.SwapDAO_.PAY_REC; int floatingPayRec = fixedPayRec * (-1); for (int i = 0; i < this.FixedLegInfo_.FP_CashFlowList_.Count; i++) { this.FixedLegInfo_.FP_CashFlowList_[i].cf_insert(calcDate, i + 1, this.SwapDAO_.INSTRUMENT_ID, this.SwapDAO_.INSTRUMENT_TYP, fixedPayRec); } for (int j = 0; j < this.FloatingLegInfo_.FP_CashFlowList_.Count; j++) { this.FloatingLegInfo_.FP_CashFlowList_[j].cf_insert(calcDate, j + 1, this.SwapDAO_.INSTRUMENT_ID, this.SwapDAO_.INSTRUMENT_TYP, floatingPayRec); } #endregion }
private static void install_db_initialize() { HITM_CALENDAR_TB calendar_tb = new HITM_CALENDAR_TB(); clsHITM_CALENDAR_TB.TableClear(); calendar_tb.buildTestData(); clsMAST_BOOKINFO_TB book_tb = new clsMAST_BOOKINFO_TB(); book_tb.BOOK_CD = "ROOTBOOK"; book_tb.BOOK_NM = "RootBook"; book_tb.PARENT_BOOK_CD = "ANCESTOR"; book_tb.OPEN_DT = DateTime.Now.ToString("yyyyMMdd"); book_tb.CLOSE_DT = "20991231"; book_tb.DESCRIPTION = ""; book_tb.Insert(); // ---------------------------------------------------- clsSET_SCENARIO_TB clstb_scenrio = new clsSET_SCENARIO_TB(); clstb_scenrio.FP_MASTER_TYP = 9999; clstb_scenrio.SCENARIO_CD = "DEFAULT_PARALLEL"; clstb_scenrio.CURVE_CD = "ALL"; clstb_scenrio.PARALLEL_SHIFT_UNIT = 1.0; clstb_scenrio.HUMP_SHIFT_UNIT = 0.0; clstb_scenrio.HUMP_CENTER_T = 0.0; clstb_scenrio.STEEPEN_SHIFT_UNIT = 0.0; clstb_scenrio.STEEPEN_CENTER_T = 0.0; clstb_scenrio.Insert(); clstb_scenrio.FP_MASTER_TYP = 2800; clstb_scenrio.SCENARIO_CD = "TEST_SC01"; clstb_scenrio.CURVE_CD = "IRSKRW"; clstb_scenrio.PARALLEL_SHIFT_UNIT = 1.0; clstb_scenrio.HUMP_SHIFT_UNIT = 0.0; clstb_scenrio.HUMP_CENTER_T = 0.0; clstb_scenrio.STEEPEN_SHIFT_UNIT = 0.1; clstb_scenrio.STEEPEN_CENTER_T = 3; clstb_scenrio.Insert(); clstb_scenrio.FP_MASTER_TYP = 2800; clstb_scenrio.SCENARIO_CD = "TEST_SC02"; clstb_scenrio.CURVE_CD = "IRSKRW"; clstb_scenrio.PARALLEL_SHIFT_UNIT = 0.5; clstb_scenrio.HUMP_SHIFT_UNIT = 0.0; clstb_scenrio.HUMP_CENTER_T = 0.0; clstb_scenrio.STEEPEN_SHIFT_UNIT = 0.3; clstb_scenrio.STEEPEN_CENTER_T = 3; clstb_scenrio.Insert(); }