Code Monkey home page Code Monkey logo

Comments (6)

TheSnowGuru avatar TheSnowGuru commented on August 11, 2024 3

from vectorbt.

polakowo avatar polakowo commented on August 11, 2024

Margin trading is currently difficult to integrate as the whole portfolio simulation logic is built around cash accounts. It would require some memory of previous actions and tracking their status at each data point, which in turn would negatively impact performance. It certainly can be done, and I will mark this as an enhancement for future releases.

In the meantime I can make some sort of "flexible cash" where you set init_capital to np.inf, run your simulation, and the initial funds will be automatically set to the highest amount of cash you spent during this simulation. The only problem with this is that different columns will have different initial funds -> portfolio value -> returns, and thus less comparable, and vectorbt is all about comparing different configurations.

Right now I'm working on combined portfolios and already made more options for calculating returns. One of them is "active returns", which are not calculated from portfolio value but from holding value and cash flows of transactions. This way, returns will be the same as if you invested all your cash into the security and thus you can set initial capital to infinity and still be able to compare columns.

from vectorbt.

Ziink avatar Ziink commented on August 11, 2024

"Active returns" sounds like it'll be quite useful. Any idea when you might be able to release it?

from vectorbt.

polakowo avatar polakowo commented on August 11, 2024

I will try to release v0.14 by the end of the next week..

from vectorbt.

guzuomuse avatar guzuomuse commented on August 11, 2024

@polakowo thanks for your effort on this elegant framework. i want to know ,is there any plane on this feature .margin with hedge support.

from vectorbt.

polakowo avatar polakowo commented on August 11, 2024

@guzuomuse I have currently no plans on implementing this feature as I have less time for open-source projects and I don't use margin trading very much, but it may be implemented somewhere in the near future. Contributions are very welcome.

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.