Right. We might be talking of the same thing but to be sure, the only case you cannot do column-wise operations is when the position depends on the previously taken position. "Single case" means something else to me, you can have many cases of entry and exit points and not require looping. The typical method of backtesting tends to be "if indicator X is above Y and time is less than T and previous position is FALSE". If you meant that at a row in data which cannot be predetermined the conditions change, then yes, of course looping is the only path.
Hey! Nice to see you on here. I am a huge fan of backtrader. If I can give my practical experience using BT and eventually settling on writing my own thing, here are the bullet points: - BT API is a thing of beauty - Great documentation, blog posts incredibly helpful As to why I decided to not use BT anymore (this is not a problem with BT, just my particular preferences): - I only needed IB - I wanted to understand all the code. My Python is not advanced enough to really be comfortable with the innards of BT. I tried to make it work but was uncomfortable making changes to the IB connection for example. - I wanted the entire flow to be managed from storing/retrieving market data to trade. - Edit: also, Python 3. I can't remember if that was ever an issue for BT but that was a personal preference. Almost 10 months after I went my own route, I can still see using backtrader in the future, wrapped in the filth of my own code. But I would only do this IF I was comfortable that I would not need to peek inside backtrader.
Sorry but this is not "right". It is wrong. And your description of the *typical* backtesting case shows that you are targeting only a single case, the one that you consider to be *typical*. A very typical scenario may include bracket orders which mix the execution of Limit orders, Limit orders and Stop (Limit or not orders), with the brackets being activated/canceled only if the Limit is of course executed/expires. The simulation of a Market order with a vectorized approach is easy. Now let me know how you put the bracketing orders in a vector and get them executed somewhere in the range of the bar, including gaps from bar to bar and adding time constraints (some people have the bad habit of placing limit order with time constraints) If you think that bracket orders are not common in backtesting, well ...
I know you were a user of backtrader, and have read your posts with regards to it. *backtrader* doesn't have to everyone's cup of tea and cannot actually be. It has a way of doing things which may not fit the taste and way of doing things the programmer has. And it may not fit the workflow that someone wants to work with. It does support many things, but it cannot support every conceivable scenario. Like people asking for order book depth (or bid/ask) but failing to realize the complexity of supporting that scenario in combination with timeframes above `Tick`. For some people, actually writing a backtesting engine should be a prerequisite, because the trading background is ZERO (I of course don't know if this is your case, although I guess it is not) and fail to realize simple things such as ... *"a Limit order may actually never execute"* ..., or ... stating things like ... "the platform is wrong, my orders are not matched against the closing price" (I wish I could execute orders against known past prices, but the exchanges deny me that option) As I have said in the past, I would encourage you to share your code with the world. It may help others (may match the taste, workflow, ...) and you may benefit from the feedback. As you probably benefited from having a look at existing frameworks (not only backtrader) even if it was for little details. NOTE: > - - Edit: also, Python 3. I can't remember if that was ever an issue for BT but that was a personal preference. Not it was for sure **NOT** an issue. *backtrader* is Python3 capable from day 1.
Difficult to follow your example. I'm not sure what "limit or not orders" are. Time based exits are too difficult or impossible to vectorize if dependent on previous executions. I'm unsure why gaps would be an issue and exiting in range seems to depend on the exit prices. I will see how this goes as I'm in process of implementing some of these ideas. In any case with vectors, the idea is to minimize the frame at each step because it's typically cheap to reapply the conditions. Memory consumption is always a much bigger worry rather than speed from what I've seen. The story is different with a loop approach. The best way seems to be to mix methods depending on the requirements. Eventually this should be seamless from the users perspective. Backtrader attempts to do it all and that's not what I'm attempting. Execution will always be a separate project and I feel there's no need to mix it with live trading.
I disagree that writing a framework is important at all. It is the last task one should try unless very certain that you need automation and have good strategies. Here is a post from reddit with the arguments that I won't replicate Some final words I am a professional quantitative portfolio manager, who has been in the industry for a very long time, and works on the bleeding edge of ML and applied mathematics with focus on the capital markets - I manage $100mn+ these days. I created this account to write on r/algotrading so that I can interact with a few people on this sub, but as I have seen, this sub is filled with amateurs and it is just annoying reading the feeds most days. I am going to delete my account and I wanted to leave a few points that I hope with help a few people here, BTC and other crypto-coins are nothing more than another asset. Stop putting it on a pedestal or thinking its anything different. ML is super hard when applying to financial markets, and its not something anyone can figure out very easily. Most amateurs can play around with RNNs and have a descent strategy, but don't think its going to give you anything extraordinary. It's just another tool in your toolbox to create a strategy. ML can be used to make some amazing automated trading systems, but it won't be possible for 99.999% of people. People have been doing ML for trading for a very very very very very very long time. You are being exposed to it just now because there are lots of tools and lots of resource that wasn't accessible before. Do not think taking tensorflow, sklearn, <insert library name here> and it will magically make you money. It takes a very long time, ie. decades to get anything automated to the level most of your dreamers think. Most of you are software engineers here. Stop thinking like one. Writing a new shiny backtesting tool or trading framework is not going to do anything than waste your time. Stop talking about languages, it really doesn't matter. Work on your alpha. Yea, its the thing that you don't know how to build, work on that. Trading frameworks come after. Anything that works on the intraday time-frame is considered HFT. Stop thinking that its only low-latency stuff, its basically what timeframe most of you are trying to make money in. People can do this, but, you need to find that thing that most of you avoid - alpha. Most people can't succeed here, so most of you, do yourselves a favor, trade daily+ timeframes, it will save you some frustration. If you have capital, make a portfolio of a few nice assets. Start with management accounting principals and work from there to figure out what makes one asset worth more than another. Stop asking people where to begin, how their stuff works. MONEY is involved here, no one will help you with anything. No one is going to tell you anything more than what I have said in the few points above. And the people who tell you things, are usually negative such as TA is bullshit or ML won't work or HFT is only latency sensitive stuff - well, most them are idiots who don't know what they are talking about. Let me tell you clear and simple here - TA is not bullshit, it's just mathematical transforms and features that MIGHT contain predictive power, ML can be used very well to make a lot of money, and HFT is anything on the sub-daily timeframe and a lot of strategies are not latency sensitive. Lastly, there are VERY smart people in the world, who have spent their entire lives studying, building and creating technological and scientific advances more than most of the people here can fathom. These people work in this industry and make a ton of money. I am happy that you saw some documentary of how a lot of people made money in the 70-80s trading and you want to be like them. Sorry, the world is different, with the availability of information and higher education standards, the bar to be good in this industry is very very very very high. So, you need to be a good scientist or have that mentality today to be good in this industry. Its great you want to be like the best of this industry, so start with being humble. Anyways. Good luck and goodbye. - xxzam
No. It doesn't. It offers vectorization where it makes sense (indicators) and doesn't where it makes no sense: trading logic and execution. With the ability to also run indicators in non-vectorized mode to be able to handle non-preloadable data feeds (such as a live data feed) and other scenarios (and the ability to switch from pre-loaded full data length buffers to ring buffers) And the execution is completely separate from the trading logic and the indicators. Your actual problem in the discussion: You are implementing and have not yet thought it through (and are focused on a goal which is vectorization)
You have taken that out of context. It was meant for people who have no trading experience, don't go to the market to have trading experience and fail to understand how a Limit (for example) order is executed, which can be bridged by having to think several times how things are executed. My personal recommendation (this thread was about a framework, hence the previous recommendation) is to actually gather real trading experience. In any case I am still awaiting your answers with regards as to how to implement the use cases for order book depth (you were eager to ask for its support, and I am eager to know how you propose to overcome the simple problems I have presented with simple questions) And with regards to that r/algotrading post (which I had already read)... it is full of good points, except for the point which apparently makes him/her write the post: "the reddit sub is full of amateurs". It he poster had any other expectation, it was really a very foolish expectation. And the poster has for sure also forgotten that he/she was also a beginner.
I don't understand your comments perfectly but I try my best limit order book will be the bids and asks input by all traders bars are an artificial construct that aren't the gold standard. It's just an artifact from the days of manual trading. You don't need OHLC and that is not the best way to compress data. Even quantopian made this mistake Depending on granularity needed by strategies you can downsample/upsample the data as much as you wish provided you have the finest granularity