i05nagai/mafipy

View on GitHub

Showing 1,119 of 1,119 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        expect = math.sqrt(2.0 * math.pi / maturity) * option_value / strike
Severity: Minor
Found in mafipy/function/tests/test_analytic_formula.py and 1 other location - About 35 mins to fix
mafipy/function/analytic_formula.py on lines 41..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        forward_fx_factor = math.exp(0.5
                                     * (self.forward_fx_vol ** 2)
                                     * self.maturity)
Severity: Minor
Found in mafipy/replication/tests/test_pricer_quanto_cms.py and 1 other location - About 35 mins to fix
mafipy/replication/tests/test_pricer_quanto_cms.py on lines 738..740

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        factor2 = 1.0 if (abs(x - z) < 1E-10) else z / x
Severity: Minor
Found in mafipy/function/sabr.py and 1 other location - About 35 mins to fix
mafipy/function/sabr.py on lines 207..207

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    return math.sqrt(2.0 * math.pi / maturity) * option_value / strike
Severity: Minor
Found in mafipy/function/analytic_formula.py and 1 other location - About 35 mins to fix
mafipy/function/tests/test_analytic_formula.py on lines 41..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def payoff_put(underlying, strike, gearing=1.0):
    """payoff_put
    Payoff of put option.

    :param float underlying:
Severity: Minor
Found in mafipy/function/payoff.py and 1 other location - About 35 mins to fix
mafipy/function/payoff.py on lines 12..22

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        factor2 = 1.0 if (abs(x - z) < 1E-10) else z / x
Severity: Minor
Found in mafipy/function/sabr.py and 1 other location - About 35 mins to fix
mafipy/function/sabr.py on lines 204..204

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            forward_fx_factor = math.exp(0.5
                                         * (self.forward_fx_vol ** 2)
                                         * self.maturity)
Severity: Minor
Found in mafipy/replication/tests/test_pricer_quanto_cms.py and 1 other location - About 35 mins to fix
mafipy/replication/tests/test_pricer_quanto_cms.py on lines 773..775

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def payoff_call(underlying, strike, gearing=1.0):
    """payoff_call
    Payoff of call option.

    :param float underlying:
Severity: Minor
Found in mafipy/function/payoff.py and 1 other location - About 35 mins to fix
mafipy/function/payoff.py on lines 41..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

        return (underlying - strike) + value
Severity: Major
Found in mafipy/function/black_scholes.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return 0.0
    Severity: Major
    Found in mafipy/function/black_scholes.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return black_scholes_call_formula(
      Severity: Major
      Found in mafipy/function/black_scholes.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return underlying - math.exp(-rate * time) * strike
        Severity: Major
        Found in mafipy/function/black_scholes.py - About 30 mins to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  if (time < 0.0
                          or -1.0 > corr
                          or 1.0 < corr
                          or vol < 0.0):
          Severity: Minor
          Found in mafipy/replication/tests/test__quanto_cms_forward_fx.py and 1 other location - About 30 mins to fix
          mafipy/replication/tests/test__quanto_cms_forward_fx.py on lines 351..354

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  if (time < 0.0
                          or -1.0 > corr
                          or 1.0 < corr
                          or vol < 0.0):
          Severity: Minor
          Found in mafipy/replication/tests/test__quanto_cms_forward_fx.py and 1 other location - About 30 mins to fix
          mafipy/replication/tests/test__quanto_cms_forward_fx.py on lines 428..431

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function black_scholes_call_value_fhess_by_strike has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def black_scholes_call_value_fhess_by_strike(
                  underlying, strike, rate, maturity, vol):
              """black_scholes_call_value_fhess_by_strike
              Second derivative of value of call option with respect to strike
              under black scholes model.
          Severity: Minor
          Found in mafipy/function/black_scholes.py - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function replicate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def replicate(init_swap_rate,
                        discount_factor,
                        call_pricer,
                        put_pricer,
                        payoff_type,
          Severity: Minor
          Found in mafipy/replication/pricer_quanto_cms.py - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Line too long (81 > 79 characters)
          Open

                  initial_number = template_initial_number.format(variable, initial_number)
          Severity: Minor
          Found in scripts/qmc_sobol_parameter.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Invalid escape sequence '\p'
          Open

              :math:`\Phi^{-1}(\cdot)` is inverse function of standard gaussian c.d.f,

          Invalid escape sequences are deprecated in Python 3.6.

          Okay: regex = r'\.png$'
          W605: regex = '\.png$'

          Invalid escape sequence '\p'
          Open

                      - \psi^{A}(s) \phi^{\prime}(h(s)) h^{\prime}(s)

          Invalid escape sequences are deprecated in Python 3.6.

          Okay: regex = r'\.png$'
          W605: regex = '\.png$'

          Invalid escape sequence '\p'
          Open

                          \\rho_{XS}\sigma_{X}\sqrt{T}\Phi^{-1}(\Psi^{A}(s))

          Invalid escape sequences are deprecated in Python 3.6.

          Okay: regex = r'\.png$'
          W605: regex = '\.png$'
          Severity
          Category
          Status
          Source
          Language