@@ -154,7 +154,7 @@ def __init__(self) -> None:
154
154
self .db .connect ()
155
155
self .db .create_tables ([DbBarData , DbTickData , DbBarOverview , DbTickOverview ])
156
156
157
- def save_bar_data (self , bars : List [BarData ]) -> bool :
157
+ def save_bar_data (self , bars : List [BarData ], stream : bool = False ) -> bool :
158
158
"""保存K线数据"""
159
159
# 读取主键参数
160
160
bar = bars [0 ]
@@ -203,6 +203,9 @@ def save_bar_data(self, bars: List[BarData]) -> bool:
203
203
overview .start = bars [0 ].datetime
204
204
overview .end = bars [- 1 ].datetime
205
205
overview .count = len (bars )
206
+ elif stream :
207
+ overview .end = bars [- 1 ].datetime
208
+ overview .count += len (bars )
206
209
else :
207
210
overview .start = min (bars [0 ].datetime , overview .start )
208
211
overview .end = max (bars [- 1 ].datetime , overview .end )
@@ -218,7 +221,7 @@ def save_bar_data(self, bars: List[BarData]) -> bool:
218
221
219
222
return True
220
223
221
- def save_tick_data (self , ticks : List [TickData ]) -> bool :
224
+ def save_tick_data (self , ticks : List [TickData ], stream : bool = False ) -> bool :
222
225
"""保存TICK数据"""
223
226
# 读取主键参数
224
227
tick : TickData = ticks [0 ]
@@ -262,6 +265,9 @@ def save_tick_data(self, ticks: List[TickData]) -> bool:
262
265
overview .start = ticks [0 ].datetime
263
266
overview .end = ticks [- 1 ].datetime
264
267
overview .count = len (ticks )
268
+ elif stream :
269
+ overview .end = ticks [- 1 ].datetime
270
+ overview .count += len (ticks )
265
271
else :
266
272
overview .start = min (ticks [0 ].datetime , overview .start )
267
273
overview .end = max (ticks [- 1 ].datetime , overview .end )
0 commit comments