Coder Social home page Coder Social logo

Comments (2)

polakowo avatar polakowo commented on July 27, 2024

Target value requires group value to determine the amount of shares to buy/sell. By default, Portfolio.from_order_func uses previous close for valuation, and since there is no data point prior to the first one, the order is softly rejected.

If you use Portfolio.from_signals and Portfolio.from_orders you can see your example working, because they have access to every order in the group and thus they can valuate each group instantly with the current order price. But Portfolio.from_order_func cannot do the same, because orders are created dynamically, and so the function has no access to all orders to come within each group. Even if columns are not grouped, vectorbt treats each column as a single group and applies the same logic for consistency.

If you know your order prices beforehand, you can define a segment_prep_func_nb function and overwrite sc.last_val_price[col] to your order price. See example under vectorbt.portfolio.nb.simulate_nb

from vectorbt.

untoreh avatar untoreh commented on July 27, 2024

I see, but I think I overlooked the fact that TargetValue targets the total holdings for the asset and not the would-be current order value, so it needs the previous price

from vectorbt.

Related Issues (20)

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.