@chen-xu what is the reason not to implement this logic in a single strategy?

Posts made by vladisld
-
RE: Multiple strategies on single data
-
RE: Forum registration is broken
@run-out @run-out Just to keep this thread active in hope that Daniel will notice:
The registration seems still to be broken - just got another private email about it ( Dec`19 )
-
RE: Is anyone failed to use ibpy in new TWS on windows?
@tianjixuetu ok. One other thing that I've noticed in my experience is the default port number on linux and windows could be different.
So if your code assumes the same port on all platforms - this could be a source of the problem and it worth to check this out.
I
-
RE: Is anyone failed to use ibpy in new TWS on windows?
@tianjixuetu As the error said - you should check the "Enable ActiveX and Socket Clients" settings
-
RE: Forum registration is broken
@run-out Registration process seems not to be functioning once again ( returning 504 Timeout error ).
-
RE: Issue with custom indicator and 2 timeframes
@duni4i
timeframe
parameter may be specified duringPandasData
instantiation:data = bt.feeds.PandasData(dataname=df,timeframe=...
-
RE: strategy next() out of alginment
@adamb032 The next() method runs after a candle has been closed when all final ohlc data for that candle is available.
Does it answer your question?
-
RE: How to process data by quarter?
@jrothschild33 said in How to process data by quarter?:
You have to make sure the data is started on January,or the result will only compression by 3 continuous months, not by quarter.
AFAIU this is the only option right now. Properly solving this should involve extending Backtrader to support yet another TimeFrame with all the ensuing consequences.
Others may correct me of cause.
-
Forum registration is broken
I've got few emails from people wanted to register on the forum and getting errors while doing so.
Here the example:
I contact you because I can't finish my registration. Therefore I can't post in the forum but I would really like to join the community, maybe you can help or connect me with someone? ... ...It seems that a required javascript file for the registration process is not being loaded... I don't know if this is on purpose? The process fails when I try to consent to the data policies AFTER account creation. After buffering for a while I receive a 504 timeout after clicking on "Submit".
I've tried to verify it by registering some temporary account and I'm getting the same error right now (Oct'19 2021)
Hope Daniel will notice this forum post and could fix the issue.
-
RE: Rolling correlation matrix indicator
@adarakchian so in both your way and the way I've proposed - the main issue is to replace the array.array with other container.
Using the QBuffer mode seems to be less intrusive way, while in your case the container type is changed forcefully.
In both cases the target seems to be the same: the container type should not make an assumption about the value type used for line data.
One more note: there are some assumptions about the underlying container type inside the LineBuffer - and this is reflected in the LineBuffer.mode ( QBuffer or Unbounded).
Depending on this mode, different methods are used for slicing and other operations inside the LineBuffer methods
Given that, it is important to keep the container type compatible with what LineBuffer logic is expecting IMHO
-
RE: Rolling correlation matrix indicator
@adarakchian you're right regarding the array.array configured for holding double type only. However this is true for the default case.
Did you try to set the buffer to QBuffer mode instead. It seems that in QBuffer state the array.array is not used.
I've not tried it myself yet - but it seems it worth to check this path.
-
RE: Rolling correlation matrix indicator
@adarakchian said in Rolling correlation matrix indicator:
lines by design only store floats
Not all lines store floats, some store other types like datetime for example:
class TestStrategy(bt.Strategy): def log(self, txt, dt=None): ''' Logging function for this strategy''' dt = dt or self.datas[0].datetime.date(0) print('%s, %s' % (dt.isoformat(), txt))
Briefly looking at the source code of LineBuffer, I do not see where the assumption of the float value type is used. So just theoretically you may store values of any type inside the private lines of your indicator for example.
Please correct me if I'm wrong.
-
RE: If I add two strategies, how to manage the positions of each strategy
@the-world AFAIK position is maintained by a broker per data and there is just a single broker per Cerebro engine. So in order for multiple strategies to have an independent positions, either they need to work on different datas or they need to be run using different engine instances.
-
RE: Is backtrader event driven or vectorized?
@shaodaodao said in Is backtrader event driven or vectorized?:
Because I used bt.talib.BBands and customized some parameters, then after cerebro run the final value is huge different for runonce=true or false
That's interesting. As I've said above, it would be great if you could share some code sample + data (simplified as you wish) - so we could play with it and see what causes this discrepancy.
-
RE: Is backtrader event driven or vectorized?
@shaodaodao Changing the value of
runonce
parameter should have no influence on the back testing / optimizations results - it's purely a performance optimization ( at least in theory )There is a small chance that there is bug of cause - but I suspect there is something in your code that may interfere with the way the framework is supposed to work - however without seeing the full code - it is hard to tell.
If you could provide your code ( or just a sample of it that demonstrates the issue) + sample data - we'll be able to tell for sure.
-
RE: Sell a specific completed buy order
@bowguo You may think about the orders as instructions to change the current position. The order doesn't constitute the position itself.
The position is maintained by the broker per data ( not per order ). So if you buy order has completed - your position for particular data has increased and vice versa for sell order.
Regarding the multiple orders with different prices - once again the position is not maintained per order - so if you sell part of your position - the position will just decrease by the size of the sell order - regardless of any previous order history that brought your position to the current state.
Diving a little bit deeper however, the real broker maintains the base price for every single share/unit of the entity you are holding in your position - for various purposes ( tax calculation, average price calculation, margin requirements and so on ). Some brokers even allow you to select the tax calculation policy if multiple lots of the same entity with different prices are part of your position.
-
RE: Does the current close data already happen when invoking next method in backtest?
@bowguo said in Does the current close data already happen when invoking next method in backtest?:
does the current close data self.data.close[0] already happen when invoking next method of strategy?
That's right - the
next
method is invoked after the bar has closed - the close price has already happened. -
RE: How to optimize with a list of grouped parameters?
@jesseliu0 This topic was discussed few times on this forum ( try to search for
optstrategy parameters
). Here some of the related posts:https://community.backtrader.com/topic/390/how-to-check-the-legality-of-parameters-before-running-the-test
https://community.backtrader.com/topic/2227/optimization-sequence-multiple-combination-of-parameters
https://community.backtrader.com/topic/2837/how-to-pass-a-list-of-dicts-to-optstrategyNot directly related but interesting nevertheless:
https://community.backtrader.com/topic/186/genetic-optimization
-
RE: Call plot while cerebro is running
@longhngo AFAIR @vbs was working on real-time plotting using Bokeh framework.
take a look at his post here: https://community.backtrader.com/topic/813/bokeh-integration-interactive-webbrowser-plotting
-
RE: No trades executed. Only 1 buy.
@bt88 It seems the
self.order
is not set toNone
anywhere - probably need to reset it toNone
innotify_order
once the order is completed.