Skip to content

Commit ca877a3

Browse files
committed
Add precomputed len to history
1 parent 5c3cd7c commit ca877a3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Trading/model/history.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class History(BaseModel):
2121
high: Optional[List[float]] = None
2222
low: Optional[List[float]] = None
2323
close: Optional[List[float]] = None
24+
len: Optional[int] = None
2425

2526
open_np: Optional[np.ndarray] | Any = None
2627
high_np: Optional[np.ndarray] | Any = None
@@ -31,6 +32,7 @@ class History(BaseModel):
3132
# post init
3233
def model_post_init(self, __context):
3334
self.to_numpy()
35+
self.len = len(self.date)
3436

3537
def get_range_ratio(self):
3638
return self.high_np.max() / self.low_np.min()

0 commit comments

Comments
 (0)