Skip to content

Commit 5690bd3

Browse files
committed
Add datetime formatting
1 parent 65e82f2 commit 5690bd3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

investing_algorithm_framework/domain/backtesting/backtest_run.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
33
from pathlib import Path
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55
from dataclasses import dataclass, field
66
from logging import getLogger
77
from typing import Union, List, Optional
@@ -167,6 +167,12 @@ def open(directory_path: Union[str, Path]) -> 'BacktestRun':
167167
data["created_at"] = datetime.strptime(
168168
data["created_at"], "%Y-%m-%d %H:%M:%S"
169169
)
170+
# Convert all to utc timezone
171+
data["backtest_start_date"] = data[
172+
"backtest_start_date"].replace(tzinfo=timezone.utc)
173+
data["backtest_end_date"] = data[
174+
"backtest_end_date"].replace(tzinfo=timezone.utc)
175+
data["created_at"] = data["created_at"].replace(tzinfo=timezone.utc)
170176

171177
# Parse orders
172178
data["orders"] = [

0 commit comments

Comments
 (0)