Description
What happened?
When passing a datetime
object with set timezone, the timezone information is gone when using the Quote.date
property, leading to "unexpected" results.
I guess this is due to the fact that Quote
uses the C# variant internally and this information is then lost somehow.
I still consider it a bug (likely easily fixable), since I don't expect information passed to be suddenly missing afterwards.
Code usage
from stock_indicators.indicators.common.quote import Quote
from decimal import Decimal
from datetime import datetime, timezone
dt = datetime.fromisoformat('2000-03-26 23:00+0000')
print(str(dt.tzinfo)) # UTC
print(str(dt.time())) # 23:00:00
q = Quote(
date=datetime.fromisoformat('2000-03-26 23:00+0000'),
open=Decimal('23'),
high=Decimal('26'),
low=Decimal('20'),
close=Decimal('25'),
volume=Decimal('323')
)
print(str(q.date.tzinfo)) # None
print(str(q.date.time())) # 01:00:00
Log output
UTC
23:00:00
None
01:00:00
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
🏗 In progress