static double GetOptionMaturityMarketValue(Datum datum, double strike) { KospiOptionInfo koi = OptionUtil.GetKOI(datum.Code); double option_count = datum.Count; if (koi.CallPut == CallPutFlag.Call) { double market_value = Math.Max(strike - koi.Strike, 0) * option_count * Const._100_000; return market_value; } else { double market_value = Math.Max(koi.Strike - strike, 0) * option_count * Const._100_000; return market_value; } }
static double GetElwMaturityMarketValue(Datum datum, double strike) { ElwInfo ei = ElwUtil.GetElwInfo(datum.Code); double option_count = ElwOptionUtil.ConvertElwCountToOptionCount_Double(ei, datum.Count); if (ei.CallPut == CallPutFlag.Call) { double market_value = Math.Max(strike - ei.Strike, 0) * option_count * Const._100_000; return market_value; } else { double market_value = Math.Max(ei.Strike - strike, 0) * option_count * Const._100_000; return market_value; } }
static Dictionary<String, Datum> GetOptionDict(double strike, ExcelData option_data) { Excel.Worksheet ws = option_data.xlWorkSheet; Dictionary<String, Datum> dict = new Dictionary<string, Datum>(); //loop without header row. for (int i = 2; i <= ws.Rows.Count; ++i) { Excel.Range rngTicker = ws.Cells[i, 2] as Excel.Range; if (rngTicker.Value2 == null || rngTicker.Count == 0) { break; } String ticker = rngTicker.Value2.ToString(); Excel.Range rngCount = ws.Cells[i, 4] as Excel.Range; long count = Convert.ToInt64(rngCount.Value2); Excel.Range rngClose = ws.Cells[i, 7] as Excel.Range; double close = Convert.ToDouble(rngClose.Value2); Excel.Range rngMarketValue = ws.Cells[i, 9] as Excel.Range; double market_value = Convert.ToInt64(rngMarketValue.Value2); Excel.Range rngCurPnL = ws.Cells[i, 10] as Excel.Range; double cur_pnl = Convert.ToInt64(rngCurPnL.Value2); Excel.Range rngLongShort = ws.Cells[i, 8] as Excel.Range; String longShortKorean = rngLongShort.Value2.ToString(); TradingDirection long_short = TradingDirection.Short; if (longShortKorean.CompareTo("매수") == 0) { long_short = TradingDirection.Long; } double book_value = market_value + cur_pnl; KospiOptionInfo koi = OptionUtil.GetKOI(ticker); Datum datum = new Datum(); datum.Code = ticker; datum.Close = close; datum.Count = count; datum.BookValue = book_value; datum.MarketValue = market_value; datum.CallPut = koi.CallPut; datum.MaturityMarketValue = GetOptionMaturityMarketValue(datum, strike); datum.LongShort = long_short; dict.Add(ticker, datum); } return dict; }
static Dictionary<String, Datum> GetElwDict(double strike, ExcelData elw_data) { Excel.Worksheet ws = elw_data.xlWorkSheet; Dictionary<String, Datum> dict = new Dictionary<string, Datum>(); //loop without header row. for (int i = 2; i <= ws.Rows.Count; ++i) { Excel.Range rng1 = ws.Cells[i, 1] as Excel.Range; if (rng1.Value2 == null || rng1.Count == 0) { break; } String ticker = rng1.Value2.ToString(); Excel.Range rngCount = ws.Cells[i, 4] as Excel.Range; long count = Convert.ToInt64(rngCount.Value2); Excel.Range rngBookValue = ws.Cells[i, 12] as Excel.Range; long book_value = Convert.ToInt64(rngBookValue.Value2); Excel.Range rngClose = ws.Cells[i, 21] as Excel.Range; double close = Convert.ToDouble(rngClose.Value2); Excel.Range rngMarketValue = ws.Cells[i, 25] as Excel.Range; double market_value = Convert.ToInt64(rngMarketValue.Value2); ElwInfo ei = ElwUtil.GetElwInfo(ticker); Datum datum = new Datum(); datum.Code = ticker; datum.Close = close; datum.Count = count; datum.BookValue = book_value; datum.MarketValue = market_value; datum.CallPut = ei.CallPut; datum.MaturityMarketValue = GetElwMaturityMarketValue(datum, strike); datum.LongShort = TradingDirection.Long; dict.Add(ticker, datum); } return dict; }