-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I tried to use the following code to subscribe to the latest market data each time the 5-min MGC K-bar updates:
class Strategy:
def __init__(self, trading_suite: TradingSuite, symbol: str):
self.suite = trading_suite
self.data_manager = trading_suite[symbol].data
async def _on_new_bar(self, event: Any):
await self._calculate_and_trade()
async def _calculate_and_trade_macd(self):
current_data = await self.data_manager.get_data("5min")
print(current_data)
async def main():
suite = await TradingSuite.create(
"MGC",
timeframes=["5min"],
initial_days=3,
)
strategy = Strategy(suite, "MGC")
if __name__ == "__main__":
asyncio.run(main())but it seems that every piece of K-bar data obtained after the program starts executing is inaccurate(circled in the picture), while the data before the program executing is accurate:
Is my use of event mechanism incorrect? Is there any way to solve it?
Metadata
Metadata
Assignees
Labels
No labels