Skip to content

Commit

Permalink
Fixes OverflowException in FuturesOptionsMarginModel (QuantConnect#5629)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCatarino authored Jun 5, 2021
1 parent 6776617 commit 37473c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static int GetMarginRequirement(Option option, decimal underlyingRequirem
return (int) maximumValue;
}

return (int) (maximumValue / (1 + denominator.SafeDecimalCast()));
return (int) (maximumValue / (1 + denominator).SafeDecimalCast());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public void MarginRequirementsAreSetCorrectly()
[TestCase(87, 3700, OptionRight.Call, PositionSide.Long, 59375)]
[TestCase(108.5, 1000, OptionRight.Call, PositionSide.Long, 59375)]
[TestCase(125, 570, OptionRight.Call, PositionSide.Long, 59375)]
[TestCase(1000, 0, OptionRight.Call, PositionSide.Long, 59375)]

// Long Call maintenance
[TestCase(10, 56000, OptionRight.Call, PositionSide.Long, 47500)]
Expand All @@ -252,6 +253,7 @@ public void MarginRequirementsAreSetCorrectly()
[TestCase(87, 3600, OptionRight.Call, PositionSide.Long, 47500)]
[TestCase(108.5, 1000, OptionRight.Call, PositionSide.Long, 47500)]
[TestCase(125, 540, OptionRight.Call, PositionSide.Long, 47500)]
[TestCase(1000, 0, OptionRight.Call, PositionSide.Long, 47500)]

// Short Call initial
[TestCase(10, 59400, OptionRight.Call, PositionSide.Short, 59375)]
Expand All @@ -263,6 +265,7 @@ public void MarginRequirementsAreSetCorrectly()
[TestCase(87, 28960, OptionRight.Call, PositionSide.Short, 59375)]
[TestCase(108.5, 11373, OptionRight.Call, PositionSide.Short, 59375)]
[TestCase(125, 3900, OptionRight.Call, PositionSide.Short, 59375)]
[TestCase(1000, 0, OptionRight.Call, PositionSide.Short, 59375)]

// Long Put initial
[TestCase(10, 45, OptionRight.Put, PositionSide.Long, 59375)]
Expand Down

0 comments on commit 37473c4

Please sign in to comment.