@backtrader thank you for the guidance. I read the documentation but I struggle to implement it.
Why it seems pointless and illogical? In fact many brokers give you a choice what to include in the bracket order (stop only, limit only, or stop/limit). What is wrong in having a stop to prevent you from excessive loss while working your own logic about the closing conditions.
After doing more investigation on this, I understand that an indicator cannot be instantiated/modified during a strategy's life (i.e. in next() for instance).
But is there a way, I can enable/disable an indicator (when indicator not needed) to save CPU during backtesting?
Thanks and regards
What is your particular concern? It seems an approach is straight forward - in for loop add daily data feed, then resample it to weekly data feed. Now all odd data feeds are daily, all even data feeds are weekly. In the for loop apply signal indicators to even data feeds, apply confirmation indicators to odd data feeds. Check the signals and then issue the orders against odd data feeds.
@backtrader OK thanks for response :) It has nothing to do with me expecting an AI to have belief in other AI entities or any of whatever you're trying to imply.
It has to do with the simple expectation--of a framework--that a BUY order executed for a given symbol will have a position size reflected in any query on that same symbol, regardless of whatever timeframe the orders or queries are being executed on. It is counter-intuitive to operate in any other way.
I will work around that, and I will see what Alpaca has to say and post back here if its relevant. Cheers!
The resampler filter wouldn't know what to do with extra lines (add, max, min, sub, multiply, take the 3rd one, take the last ...) and works only with the fields for which it has a rule, the standard ones.
You can create a 2nd data feed, assign your desired fields to open (keep 1st), high/low (keep max/min), close (keep last), volume (add) and use that resampled to match the timeframe of your master data feed.
Or create your own resampling filter.
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.