public VanillaIRS_TradeViewModel(HedgeTradingViewModel htvm)
 : base(htvm)
 {
     this.TradeName_ = "VanillaIRS";
     this.AvailableInstList_ = new List<clsTRADABLE_OTC_VANILLA_IRS_TB>();
     this.FP_MASTER_TYP_LEVEL_ = 2800;
 }
 public KOSPI200Futures_TradeViewModel(HedgeTradingViewModel htvm)
 : base(htvm)
 {
     this.TradeName_ = "KOSPI200_Futures";
     this.AvailableInstList_ = new List<clsTRADABLE_KRX_INDEXFUTURES_TB>();
     this.FP_MASTER_TYP_LEVEL_ = 400;
 }
        public KOSPI200Option_TradeViewModel(HedgeTradingViewModel htvm)
        : base(htvm)
        {
            this.TradeName_ = "KOSPI200_Option";
            this.AvailableInstList_ = new List<clsTRADABLE_KRX_INDEXOPTION_TB>();

        }
        public void tradeBooking_check(TradeInfo ti,DateTime tradingDate)
        { 
            // trade 함

            HedgeTradingViewModel htvm = new HedgeTradingViewModel();

            htvm.FinanceBook_ = FinanceBook.CreateBookFromUI("RootBook");
            htvm.TradeMaker_.TradingDate_ = tradingDate;
            htvm.FinancialMasterManager_ = new FinancialMasterManager();
            htvm.ProfitLossCalculator_ = new ProfitLossCalculator();

            htvm.doTrade(ti);
        }
Example #5
0
        private void MainHedgeUI_Load(object sender, RibbonUIEventArgs e)
        {
            DatabaseLayer.DataBaseConnection.SqlConnection_.Open();
            //ProgramVariable.Initialize();
            this.HedgeTradingViewModel_ = new HedgeTradingViewModel();
            
            // base data가 잘 생성 되면 그 날짜를 가져옴.
            this.RefDate_ = DateTime.Now;

            // 이건 배치로 돌려야함..
            this._dataGen();

            this._BookListDropDown_Initialize();
            
            this._BookLoad(this.BookListDropDown.Items[0].Label);

            this._buildRefDatePosition();

        }
 public VanillaSwap_TradeViewModel(HedgeTradingViewModel htvm)
 : base(htvm)
 {
     this.TradeName_ = "VanillaSwap";
     this.AvailableInstList_ = new List<clsTRADABLE_OTC_VANILLA_IRS_TB>();
 }
Example #7
0
 public TradeViewModel(HedgeTradingViewModel htvm)
 {
     this.HedgeTradingViewModel_ = htvm;
 }
 public KTBFutures_TradeViewModel(HedgeTradingViewModel htvm)
 : base(htvm)
 {
     this.TradeName_ = "KTB_Futures";
 }
Example #9
0
        // ----------------------- Test ---------------------
        //public void doTest()
        //{
        //    // setting program variable
        //    ProgramVariable.Initialize();

        //    // input -----------------------------------------------------------------

        //    DateTime startDate = new DateTime();
        //    //DateTime endDate = new DateTime();

        //    // -----------------------------------------------------------------------

        //    // 북을 로드함.
           
        //    string bookCode = "testHedgeBook";
        //    //HedgeBook hedgeBook = HedgeBook.CreateBook(bookCode);
        //    //FinanceBook hedgeBook = FinanceBook.LoadBook(bookCode);

        //    // 이놈은 이제 그냥 C# ? Quantlib에서 가져오자.
        //    Financial_instrumentPricerManager financial_instrumentPricer = new Financial_instrumentPricerManager();
        //    //hedgeBook.Pricer_ = financial_instrumentPricer;

        //    string insuranceCode = "insuranceCode";
        //    InsuranceBook insuranceBook = InsuranceBook.CreateBook(insuranceCode,"bookName");
        //    Insurance_policyPricer insurance_policyPricer = new Insurance_policyPricer();
        //    insuranceBook.Pricer_ = insurance_policyPricer;

        //    // 헤지 전략
        //    HedgeStrategy hedgeStrategy = new HedgeStrategy();

        //    HedgePositionCalculator hedgePositionCalc = new HedgePositionCalculator();
        //    HedgePositionCalculator.HedgeSetting hedgeSetting = new HedgePositionCalculator.HedgeSetting();

        //    hedgePositionCalc.Setting_ = hedgeSetting;

        //    // hedge mapping load
        //    hedgePositionCalc.load_map_hedgeInst();

        //    // 시나리오.. test

        //    // 북이 아직 Open인가..? Close면
        //    if ( hedgeBook.isOpen(startDate) )
        //    {
        //        // book load with refDate ----------------------------------------------
        //        hedgeBook.loadPosition(startDate);
        //        insuranceBook.loadPolicy(startDate);
        //        // ---------------------------------------------------------------------

        //        DateTime next_hedge_t = startDate;

        //        while (next_hedge_t != null)
        //        {
        //            // Greek 의 존재 유무 계산 됬는지 검사? -------------------------------- 
        //            insuranceBook.evaluate(next_hedge_t);

        //            // 보증옵션 Position 이 있음.
        //            DayPolicyPositions dayPolicyPosition = insuranceBook.DayPolicyPositions_;

        //            // 장중 Greek...?
        //            GreekPositions greeks = dayPolicyPosition.greekPositions();
                    
        //            List<TradeInfo> hedgeTradeList = hedgePositionCalc.getHedgeTradeInfoList(greeks);

        //            //
        //            //hedgeBook.doTrade(hedgeTradeList);

        //            // 그동안 한걸 booking 함. history clear ?
        //            hedgeBook.doBooking();

        //            // 손익 마감 평가
        //            hedgeBook.evaluate(next_hedge_t);

        //            //
        //            next_hedge_t = hedgeStrategy.hedgeNextTime();

        //        }

        //        DayPositions end_hedgePosition = hedgeBook.getPosition();

        //        Console.WriteLine(end_hedgePosition);

        //    }
        //    else
        //    {
        //        // unable to hedge trade. book close.
        //    }

        //    //     
        //}

        public void doTest2()
        {
            DatabaseLayer.DataBaseConnection.SqlConnection_.Open();

            clsHITM_FP_GREEKRESULT_TB.TableClear();

            //bool dailyCloseFlag = false;

            // setting program variable
            ProgramVariable.Initialize();

            // input -----------------------------------------------------------------
            DateTime startDate = new DateTime(2014,1,5);
            DateTime endDate = startDate.AddYears(1);

            MockTradeGenerator mockTradeGenerator = new MockTradeGenerator();
            mockTradeGenerator.makeMockTrading(startDate, endDate);
            
            // -----------------------------------------------------------------------

            // 북을 로드함.

            string bookCode = "testHedgeBook";

            DatabaseLayer.clsHITM_FP_POSITION_TB.TableClear();
            DatabaseLayer.clsHITM_TRADEINFO_TB.TableClear();
            DatabaseLayer.clsMAST_CF_VANILLA_FLOATING_TB.TableClear();
            DatabaseLayer.clsMAST_CF_FIXED_TB.TableClear();
            DatabaseLayer.clsMAST_SWAP_TB.TableClear();

            HedgeTradingViewModel hedgeTradingVM = new HedgeTradingViewModel();

            hedgeTradingVM.TradingDate_ = startDate;

            hedgeTradingVM.FinancialMasterManager_ = new FinancialMasterManager();
            hedgeTradingVM.ProfitLossCalculator_ = new ProfitLossCalculator();
            
            hedgeTradingVM.FinanceBook_ = new FinanceBook(bookCode);

            int count = mockTradeGenerator.DailyTrades_.Count;

            DateTime roopDate;

            for (int i = 0; i < mockTradeGenerator.DailyTrades_.Count ; i++)
            {
                roopDate = mockTradeGenerator.DailyTrades_[i].refDate;

                //전일자로 부터 복사함.
                hedgeTradingVM.FinanceBook_.makePositionFromPreDate(roopDate.AddDays(-1), roopDate);

                // 기준일자를 로드함.
                hedgeTradingVM.FinanceBook_.loadPosition(roopDate);

                // --------------------- 거래의 Group -----------------------------------
                // 거래를 실행함.
                hedgeTradingVM.doTrades(mockTradeGenerator.DailyTrades_[i].trades);
                //hedgeTradingVM.futuresTrade();
                //hedgeTradingVM.irsTrade();
                // ----------------------------------------------------------------------

                // 부킹함.
                hedgeTradingVM.booking();


                //// 중간평가
                //hedgeTradingVM.liveEvaluate();

                //// 최종 마감함 ----------------------------------------------------------

                //if ( dailyCloseFlag )
                //{ 
                    // 마감평가.

                hedgeTradingVM.FinancialMasterManager_.calculatePrice(roopDate);

                hedgeTradingVM.evaluate();
                //}

                Console.WriteLine(roopDate.ToString("yyyyMMdd") + " : ..................................");

            }
        }