/// <summary> /// Calculate the margin requierd to sell 1 option of the given position data. /// It calculates considering the situation and relations of entire positions of the given UNL. /// </summary> /// <param name="positionData"></param> /// <returns></returns> public double OnePositionSellMargin(OptionsPositionData positionData) { var symbol = positionData.OptionData.Symbol; CalculateUNLRequierdMargin(symbol); var marginData = MarginDataDic[symbol]; //double unlRate = positionData.OptionData.LastPrice; var unlRate = _appManager.ManagedSecuritiesManager.Securities[symbol].LastPrice; double strike = positionData.OptionContract.Strike; EOptionType type = positionData.OptionType; bool mate = false; switch (marginData.PutCallPositionRelation) { case EPutCallPositionRelation.Equel: break; case EPutCallPositionRelation.PutGCall: if (type == EOptionType.Call) { mate = true; } break; case EPutCallPositionRelation.CallGPut: if (type == EOptionType.Put) { mate = true; } break; } var result = CalculateMargin(unlRate, strike, mate, type); return(result); }
private void CalculateATM_IV() { OptionsPositionData firstPosition = PositionDataDic.Values.FirstOrDefault(p => p.OptionType == EOptionType.Call); if (firstPosition != null) { PositionsSummaryData.ImVolOnCallATM = OptionsManager.GetImVolOnATMOption(firstPosition.OptionType, firstPosition.Expiry); } firstPosition = PositionDataDic.Values.FirstOrDefault(p => p.OptionType == EOptionType.Put); if (firstPosition != null) { PositionsSummaryData.ImVolOnPutATM = OptionsManager.GetImVolOnATMOption(firstPosition.OptionType, firstPosition.Expiry); } }
private Color GetCellColor(OptionsPositionData pData, out bool bold) { //the offset factor from unl for trading, to accomplished the algorithm of "Out of the money" (OTM) const double offsetFromUnl = 0.1; var unlPrice = pData.OptionData.UnderlinePrice; //We divide the offset to 3 step in order to paint the cell accordingly. var step = unlPrice * offsetFromUnl / 3; var isCall = pData.OptionType == EOptionType.Call; var strike = pData.OptionContract.Strike; //The offset (in points) from the underline. if the strike exceed this number => //turn the color to color that symbol the difference size. var diff = isCall ? strike - unlPrice : unlPrice - strike; bold = false; Color foreColor; if (diff <= step) { foreColor = Color.Red; bold = true; } else if (diff <= 1.5 * step) { foreColor = Color.Brown; } else if (diff <= 2.5 * step) { foreColor = Color.Blue; } else { foreColor = Color.DarkGreen; } return(foreColor); }
protected void HandleOptionsPositionData(OptionsPositionData data) { HandleSymbolData <OptionContract>(data, false); }