简体   繁体   English

在 Backtrader 中开设多个头寸

[英]Open multiple positions in Backtrader

Does someone know if it's possible to open multiple positions with only a single data feed?有人知道是否可以只用一个数据源就可以开多个头寸吗? I am trying to do a second buy whilst in a position, which doesn't seem to be possible.我试图在处于某个位置时进行第二次购买,这似乎是不可能的。

Nobody seems to adress this issue.似乎没有人解决这个问题。 Does anyone have any experience with Backtrader and have any input?有没有人对 Backtrader 有任何经验并有任何意见?

If you are just trying to buy more stock to add to your position, then yes, you should be able to do this and if you cannot recheck your strategy code in next.如果您只是想购买更多股票以增加您的头寸,那么是的,您应该可以这样做,并且如果您接下来无法重新检查您的策略代码。

If you are trying to track two separate positions of the same data...如果您尝试跟踪相同数据的两个不同位置...

One cannot have two separate positions in the same data feed.在同一个数据馈送中不能有两个不同的位置。 You may trade additional positions if you like but they will be combined in Backtrader.如果您愿意,您可以交易额外的头寸,但它们将在 Backtrader 中合并。 Even if you use two strategies you will still have one combined broker.即使您使用两种策略,您仍将拥有一个组合经纪人。

The reason for this is to simulate as near as possible real world conditions.这样做的原因是模拟尽可能接近真实世界的条件。 If you have a brokerage account you most likely would have just one postion.如果你有一个经纪账户,你很可能只有一个职位。 (I know there are exceptions) (我知道有例外)

One solution would be to track your trading manually in a dictionary trades that result from different signals/sub-strategies.一种解决方案是在由不同信号/子策略产生的字典交易中手动跟踪您的交易。 It's a bit more tedious to develop but very doable.开发起来有点乏味,但非常可行。 jk jk

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pyinstaller - 没有名为“Backtrader”的模块 - pyinstaller - No module named 'Backtrader' 如何在Python流中维护多个流位置 - How to maintain multiple stream positions in a Python stream Matplotlib 中同一轴的多个 label 位置 - Multiple label positions for same axis in Matplotlib 基于多个位置删除 numpy 数组中的项目 - removing item in numpy array based on multiple positions 在多个位置使用find_elements_by_xpath - Using find_elements_by_xpath with multiple positions Python不会从字符串打印唯一单词的多个位置 - Python does not print unique word's multiple positions from string 如何将多个字符插入字符串中的随机非相邻位置 - How to Insert a Multiple Characters into Random Non-Adjacent Positions in a String ValueError:日期超出了 backtrader 中发生的月份的范围 - ValueError: day is out of range for month occuring in backtrader 比较具有相同结构的多个列表与在最低位置具有较小整数的列表 - Compare multiple lists with same structure for the one with smaller integers at lowest positions Python Backtrader 错误:FileNotFoundError:[Errno 2] 没有这样的文件或目录:'AAPL' - Python Backtrader Error: FileNotFoundError: [Errno 2] No such file or directory: 'AAPL'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM