Skip to content

importing orders from backtesting.py strategy to create a vbt.Portfolio #334

Answered by polakowo
eervin123 asked this question in Q&A
Discussion options

You must be logged in to vote

@eervin123 the notebook was created by one of the users, I can't really answer the design decisions that were made. Regarding your dataframe with trades, there is an issue you need to solve. If you want to use either from_orders or from_signals, you need to make sure that there is at most one order per bar. At bar 949 you exited at 283.98 and entered at 283.41204, which isn't possible to do with one order. But you can go another way - without simulation at all. Portfolio constructor takes close and order records that were generated during the simulation. Since you already have this info, you need to convert your dataframe into an array of order records and just pass to the Portfolio class…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@eervin123
Comment options

@polakowo
Comment options

@eervin123
Comment options

Answer selected by eervin123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants