Coder Social home page Coder Social logo

q-fin's Issues

Backtesting code error - no 'modules.isolation_model' found

I'm enjoying your Medium article and have implemented the code but its giving errors.

Are these suppsed to be part of one huge class or is there a function not included? I've expanded upon your code in my repo here for reference since I didnt see it in yours. Thanks for writing these articles they are good reference material.

box/PycharmProjects/Financial_Backtrader/backtesting_b.py", line 3, in <module>
    from models.isolation_model import IsolationModel
ModuleNotFoundError: No module named 'models'

datatalking/Financial_Backtrader#1

Problem with the Geometric Brownian Motion Code from YT video

I get the following error:


TypeError Traceback (most recent call last)
Cell In [19], line 1
----> 1 sample_paths = geometric_Brownian_motion (S_0, mu, sigma, T, dt, n)

Cell In [17], line 13, in geometric_Brownian_motion(S_0, mu, sigma, T, dt, n)
10 prices.append( prices[-1]np.exp((mu - .5(sigma2))dt + sigmanp.random.normal(0, np.sqrt(dt))))
11 time += dt
---> 13 if T (time) > 0:
14 prices.append(prices[-1]np.exp((mu - .5(sigma
2))(T-time) + sigmanp.random.normal(0, np.sqrt(T-time))))
16 paths.append(prices)

TypeError: 'int' object is not callable

under the following code:
sample_paths = geometric_Brownian_motion (S_0, mu, sigma, T, dt, n)

Negative Put Prices

The library produces negative prices for put options having small delta. Calls don't have this behaviour (price tends to zero, as expected).

i.e compare:

BlackScholesCall(4600, 0.19, 4400, float(5)/365, 0.01).price # 201.4
BlackScholesPut(4600, 0.19, 4400, float(5)/365, 0.01).price # -190.6

or see (where price and delta columns are derived from q-fin BlackScholesPut)

image

I'm wondering what I should make of this -- whether there's an error with the library, or a quirk of BS model (in which case I can take a floor of zero of put price value).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.