无法删除backtrader中datetime格式的错误

2024-05-08 21:48:59 发布

您现在位置:Python中文网/ 问答频道 /正文

class dataFeed(btfeed.GenericCSVData):
    params = (
        ('dtformat', '%m%d%Y %H:%M:%S'),
        ('datetime', 0),
        ('open', 1),
        ('high', 2),
        ('low', 3),
        ('close', 4),
        ('volume', 5),
        ('openinterest', -1)
    )
    
ValueError: time data '12/24/2020 10:00' does not match format '%m%d%Y %H:%M:%S'

这就是他的时间戳的样子-12/24/2020 10:00:00 AM


Tags: closedatetimetimeparamsopenclasslowhigh
1条回答
网友
1楼 · 发布于 2024-05-08 21:48:59

从字符串中删除斜杠:

dt_string = dt_string.replace("/", "")

或更改'dtformat'

('dtformat', '%m/%d/%Y %H:%M'),

相关问题 更多 >