sonntagsgesicht/dcf

View on GitHub

Showing 148 of 148 total issues

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

    def _call_price(self, time, strike, forward, volatility):
        vol = volatility * sqrt(time)
        d = (forward - strike) / vol
        return normal_cdf(d)
Severity: Major
Found in dcf/models/bachelier.py and 1 other location - About 1 hr to fix
dcf/models/bachelier.py on lines 54..57

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

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 interest_rate_swap has 15 arguments (exceeds 4 allowed). Consider refactoring.
Open

def interest_rate_swap(start_date=TODAY,
Severity: Major
Found in dcf/cashflows/products.py - About 1 hr to fix

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

        def get_survival_prob(self, start, stop=None):
            r"""survival probability of credit curve
    
            :param start: start point in time $t_0$ of period
            :param stop: end point $t_1$ of period
    Severity: Major
    Found in dcf/curves/creditcurve.py and 3 other locations - About 1 hr to fix
    dcf/curves/creditcurve.py on lines 85..103
    dcf/curves/interestratecurve.py on lines 42..74
    dcf/curves/interestratecurve.py on lines 76..112

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

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

        def get_discount_factor(self, start, stop=None):
            r"""discounting factor for future cashflows
    
            :param start: date $t_0$ to discount to
            :param stop: date $t_1$ for discounting from
    Severity: Major
    Found in dcf/curves/interestratecurve.py and 3 other locations - About 1 hr to fix
    dcf/curves/creditcurve.py on lines 55..83
    dcf/curves/creditcurve.py on lines 85..103
    dcf/curves/interestratecurve.py on lines 76..112

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

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

        def get_zero_rate(self, start, stop=None):
            r"""curve of zero rates, i.e. yields of zero cupon bonds
    
            :param start: zero bond start date $t_0$
            :param stop: zero bond end date $t_1$
    Severity: Major
    Found in dcf/curves/interestratecurve.py and 3 other locations - About 1 hr to fix
    dcf/curves/creditcurve.py on lines 55..83
    dcf/curves/creditcurve.py on lines 85..103
    dcf/curves/interestratecurve.py on lines 42..74

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

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

        def get_flat_intensity(self, start, stop=None):
            r"""intensity value of credit curve
    
            :param start: start point in time $t_0$ of intensity
            :param stop: end point $t_1$  of intensity
    Severity: Major
    Found in dcf/curves/creditcurve.py and 3 other locations - About 1 hr to fix
    dcf/curves/creditcurve.py on lines 55..83
    dcf/curves/interestratecurve.py on lines 42..74
    dcf/curves/interestratecurve.py on lines 76..112

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

    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

            if not self.bump_greeks:
                vega = self._call_vega(time, strike, fwd, vol)
                if vega is not None:
                    return vega * scale
    Severity: Major
    Found in dcf/models/optionpricing.py and 2 other locations - About 1 hr to fix
    dcf/models/optionpricing.py on lines 293..296
    dcf/models/optionpricing.py on lines 424..427

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

    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 get_interest_accrued has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_interest_accrued(cashflow_list, valuation_date):
        r""" calculates interest accrued for rate cashflows
    
        :param cashflow_list: requires a `day_count` property
        :param valuation_date: calculation date
    Severity: Minor
    Found in dcf/pricer.py - About 1 hr 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

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

            if not self.bump_greeks:
                theta = self._call_theta(date, strike, fwd, vol)
                if theta is not None:
                    return theta * scale
    Severity: Major
    Found in dcf/models/optionpricing.py and 2 other locations - About 1 hr to fix
    dcf/models/optionpricing.py on lines 293..296
    dcf/models/optionpricing.py on lines 382..385

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

    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 make_grid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def make_grid(curve, step=None, nums=10):
        domain = curve.domain
        grid = list()
        for start, stop in zip(domain[:-1], domain[1:]):
            grid.append(start)
    Severity: Minor
    Found in dcf/curves/plot.py - About 1 hr 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

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

            if not self.bump_greeks:
                delta = self._call_delta(time, strike, fwd, vol)
                if delta is not None:
                    return delta * scale
    Severity: Major
    Found in dcf/models/optionpricing.py and 2 other locations - About 1 hr to fix
    dcf/models/optionpricing.py on lines 382..385
    dcf/models/optionpricing.py on lines 424..427

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

    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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, domain=(), data=(), interpolation=None, origin=None,
                     day_count=None, forward_tenor=None):
            if isinstance(domain, RateCurve):
                # if argument is a curve add extra curve points to domain
                # for better approximation
    Severity: Minor
    Found in dcf/curves/interestratecurve.py - About 1 hr 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 rate_table has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def rate_table(curve, x_grid=None, y_grid=None):
        r""" table of calculated rates
    
        :param curve: function $f$
        :param x_grid: vertical date axis $x_0, \dots, x_m$
    Severity: Minor
    Found in dcf/curves/curve.py - About 1 hr 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 details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def details(self, forward_curve=None):
            yf = self.day_count(self.start, self.end)
    
            details = {
                'cashflow': 0.0,
    Severity: Minor
    Found in dcf/cashflows/payoffs.py - About 1 hr 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 _interest_payment_dates has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _interest_payment_dates(
            start_date, end_date, period, convention, holidays):
        if bd and isinstance(start_date, bd.BusinessDate):
            start_date = bd.BusinessDate(start_date)
            if bd.BusinessPeriod.is_businessperiod(end_date):
    Severity: Minor
    Found in dcf/cashflows/products.py - About 1 hr 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 bond has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def bond(start_date=TODAY,
    Severity: Major
    Found in dcf/cashflows/products.py - About 1 hr to fix

      Function __call__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, _=None):
              flows = list()
              for item in self.domain:
                  payoff = self._flows.get(item, 0.)
                  if not isinstance(payoff, (int, float)):
      Severity: Minor
      Found in dcf/cashflows/cashflow.py - About 1 hr 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

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

              if stop is None:
                  stop = start + self.forward_tenor if step is None else start + step
      Severity: Major
      Found in dcf/curves/interestratecurve.py and 1 other location - About 1 hr to fix
      dcf/curves/interestratecurve.py on lines 437..438

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

      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 stop is None:
                  stop = start + self.forward_tenor if step is None else start + step
      Severity: Major
      Found in dcf/curves/interestratecurve.py and 1 other location - About 1 hr to fix
      dcf/curves/interestratecurve.py on lines 247..248

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

      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 get_bucketed_delta has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_bucketed_delta(cashflow_list, discount_curve, valuation_date=None,
                             delta_curve=None, delta_grid=None, shift=.0001):
          r""" list of bpv delta for partly shifted interest rate curve
      
          :param cashflow_list: list of cashflows
      Severity: Minor
      Found in dcf/pricer.py - About 1 hr 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

      Severity
      Category
      Status
      Source
      Language