After further check - it seems the problem was caused by my own changes. The warning messages were pushed by mistake to the same message queue that was used by 'reqContractDetails'.
My apologies. Please ignore this topic.
Thank you for your answer.
I am used to MT4. The operation habit of order affects my understanding.
After understanding, I can think of an application: Calculate used margin
if order.status in [order.Completed]:
for bit in order.executed.exbits:
self.marginUsed += bit.openedvalue - bit.closedvalue
If this is not right, please give me suggestions and thank you again for your reply
@Ross-Coates said in TypeError: __init__() got an unexpected keyword argument 'size':
In any case let me point out that those three ticks (i.e ' vertical) are not backticks as in `
You may want to directly copy the ticks from the announcement at the top of the forum
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
@Yury-Tsar said in Multiple strategies on single data:
In case as you described, Cerebro will share same position across multiple strategies.
What @vladisld pointed you to won't share the same position across multiple strategies. You may want to read the articles in detail. It doesn't in case apply to your single stop-loss optimization goal.
Just enumerate through the datas in a pythonic way by referencing d. if len(d) > self.lenofdata....
If you reference self.datas you'll only ever access self.datas. Each timeframe and datafeed will have its own data in datas. datas datas datas... datas[n]. Also self.len has the potential for a keyword conflict. I suggest following backtraders example above.
Have you reviewed the multiple datas example? You might want to search that out.
I don't think that this is the only thing you are missing. To initialize the value is very easy:
self.l.f1 = 0.0
But here is couple other items to correct:
you call undefined variables such as self.f1 or self.pf - this is the main reason of the error returned
this in the next()
self.v3 = bt.ind.Lowest(self.pf, period=self.p.length)
self.v4 = bt.ind.Highest(self.pf, period=self.p.length) - self.v3
.... self.v3 ....
.... self.v4 ....
Interesting. In your script you apply the indicator to the self.data0 ie 5 min data feed, but indicator itself works with the self.data1 which is daily bars. I would assume that self.addminperiod is also applied to minutes data feed, so you need lot to get 5 bars of daily data feed.
Try this (didn' run it by myself):
lines = ('dayHigh',)
params = (('period', 5),)
self.dayHigh = self.data.high[-self.p.period]
call in the strategy:
self.dayHigh = dummyIndicator(self.data1)
Hi, it should be compresssion = 15. Note: if your data is large, you may want to consider bt.feed.PandasDataDirect that seems to be faster than PandasData. Someone has conducted a perf analysis on this forum. you should be able to find easily. Cheers