i05nagai/mafipy

View on GitHub

Showing 1,119 of 1,119 total issues

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

    @pytest.mark.parametrize(
        "underlying, strike, gearing",
        [
            # underlying = strike
            (2.0, 2.0, 1.0),
Severity: Major
Found in mafipy/function/tests/test_payoff.py and 1 other location - About 5 hrs to fix
mafipy/function/tests/test_payoff.py on lines 32..47

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 89.

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

    @pytest.mark.parametrize(
        "underlying, strike, gearing",
        [
            # underlying = strike
            (2.0, 2.0, 1.0),
Severity: Major
Found in mafipy/function/tests/test_payoff.py and 1 other location - About 5 hrs to fix
mafipy/function/tests/test_payoff.py on lines 68..83

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 89.

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

Severity: Major
Found in mafipy/replication/error.py and 1 other location - About 4 hrs to fix
mafipy/function/error.py on lines 0..21

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 84.

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

Severity: Major
Found in mafipy/function/error.py and 1 other location - About 4 hrs to fix
mafipy/replication/error.py on lines 0..21

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 84.

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

Cyclomatic complexity is too high in method test_black_scholes_call_value. (24)
Open

    @pytest.mark.parametrize(
        "underlying, strike, rate, maturity, vol, today",
        [
            # maturity < 0
            (1.0, 1.0, 1.0, -1.0, 1.0, 0.0),

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

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

        elif init_swap_rate < 0.0 and option_strike > 0.0:
            expect = 0.0
        # max(S(T)-K,0) = max((-K)-(-S(T)),0)
        elif init_swap_rate < 0.0 and option_strike < 0.0:
            option_value = function.black_scholes_put_formula(
Severity: Major
Found in mafipy/function/tests/test_black.py and 1 other location - About 4 hrs to fix
mafipy/function/tests/test_black.py on lines 137..147

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 82.

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

        elif init_swap_rate < 0.0 and option_strike > 0.0:
            expect = swap_annuity * (option_strike - init_swap_rate)
        # max(K-S(T),0) = max((-S(T)) - (-K),0)
        elif init_swap_rate < 0.0 and option_strike < 0.0:
            option_value = function.black_scholes_call_formula(
Severity: Major
Found in mafipy/function/tests/test_black.py and 1 other location - About 4 hrs to fix
mafipy/function/tests/test_black.py on lines 77..87

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 82.

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 case5():
            self.payoff_lower_strike = (self.max_call_range
                                        + self.min_call_range) * 0.5
            self.payoff_upper_strike = self.max_call_range * 1.1
            self._set_target()
Severity: Major
Found in mafipy/replication/tests/test_pricer_quanto_cms.py and 1 other location - About 4 hrs to fix
mafipy/replication/tests/test_pricer_quanto_cms.py on lines 682..690

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 81.

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 case3():
            self.payoff_lower_strike = (self.max_put_range
                                        + self.min_put_range) * 0.5
            self.payoff_upper_strike = self.max_call_range * 1.1
            self._set_target()
Severity: Major
Found in mafipy/replication/tests/test_pricer_quanto_cms.py and 1 other location - About 4 hrs to fix
mafipy/replication/tests/test_pricer_quanto_cms.py on lines 710..718

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 81.

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 black_payers_swaption_value_fprime_by_strike(
        init_swap_rate,
        option_strike,
        swap_annuity,
        option_maturity,
Severity: Major
Found in mafipy/function/black.py and 1 other location - About 3 hrs to fix
mafipy/function/black.py on lines 212..261

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 73.

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 black_payers_swaption_value_third_by_strike(
        init_swap_rate,
        option_strike,
        swap_annuity,
        option_maturity,
Severity: Major
Found in mafipy/function/black.py and 1 other location - About 3 hrs to fix
mafipy/function/black.py on lines 113..164

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 73.

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

TestSabr has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

class TestSabr(object):

    # before all tests starts
    @classmethod
    def setup_class(cls):
Severity: Minor
Found in mafipy/function/tests/test_sabr.py - About 3 hrs to fix

    File black.py has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/bin/python
    # -*- coding: utf-8 -*-
    
    from __future__ import division, print_function, absolute_import
    import numpy as np
    Severity: Minor
    Found in mafipy/function/black.py - About 3 hrs to fix

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

      def time_vol_swap_rate():
          vol_swap_rate = 0.05
          params = gen_params("vol_swap_rate", vol_swap_rate)
          linear_annuity_bull_spread_pricer(**params)
          vol_swap_rate = 0.5
      Severity: Major
      Found in benchmarks/benchmarks/bull_spread_qunato_cms.py and 2 other locations - About 3 hrs to fix
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 133..142
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 145..154

      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 70.

      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 3 locations. Consider refactoring.
      Open

      def time_corr_forward_fx():
          corr_forward_fx = -1.0
          params = gen_params("corr_forward_fx", corr_forward_fx)
          linear_annuity_bull_spread_pricer(**params)
          corr_forward_fx = 0.0
      Severity: Major
      Found in benchmarks/benchmarks/bull_spread_qunato_cms.py and 2 other locations - About 3 hrs to fix
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 121..130
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 145..154

      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 70.

      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 3 locations. Consider refactoring.
      Open

      def time_vol_foward_fx():
          vol_forward_fx = 0.05
          params = gen_params("vol_forward_fx", vol_forward_fx)
          linear_annuity_bull_spread_pricer(**params)
          vol_forward_fx = 0.5
      Severity: Major
      Found in benchmarks/benchmarks/bull_spread_qunato_cms.py and 2 other locations - About 3 hrs to fix
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 121..130
      benchmarks/benchmarks/bull_spread_qunato_cms.py on lines 133..142

      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 70.

      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 _sabr_implied_vol_hagan_A3_fprime_by_strike(
              underlying, strike, maturity, alpha, beta, rho, nu):
          """_sabr_implied_vol_hagan_A3_fprime_by_strike
          See :py:func:`_sabr_implied_vol_hagan_A3`.
      
      
      Severity: Major
      Found in mafipy/function/sabr.py and 1 other location - About 3 hrs to fix
      mafipy/function/sabr.py on lines 1108..1130

      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 68.

      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 _sabr_implied_vol_hagan_A3_fprime_by_underlying(
              underlying, strike, maturity, alpha, beta, rho, nu):
          """_sabr_implied_vol_hagan_A3_fprime_by_underlying
          See :py:func:`_sabr_implied_vol_hagan_A3`.
      
      
      Severity: Major
      Found in mafipy/function/sabr.py and 1 other location - About 3 hrs to fix
      mafipy/function/sabr.py on lines 1056..1078

      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 68.

      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

      File _quanto_cms_forward_fx.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/bin/python
      # -*- coding: utf-8 -*-
      
      from __future__ import division, print_function, absolute_import
      import math
      Severity: Minor
      Found in mafipy/replication/_quanto_cms_forward_fx.py - About 3 hrs to fix

        File setup.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        # -*- coding: utf-8 -*-
        
        from setuptools import Command
        from setuptools.command.test import test as TestCommand
        Severity: Minor
        Found in setup.py - About 3 hrs to fix
          Severity
          Category
          Status
          Source
          Language