Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different Time Zone Support #25

Open
shashi1006 opened this issue Nov 25, 2024 · 0 comments
Open

Different Time Zone Support #25

shashi1006 opened this issue Nov 25, 2024 · 0 comments

Comments

@shashi1006
Copy link

Im trying to integrate 5ers prop account to fetch ticks from mt5 terminal which is running in GMT+2 when i tried to get tick im not getting latest tick

For Ex:
Current GMT+2 time is 6:17
Current UTC time is 4:17

my request to get tick is
current_time = datetime.now(pytz.timezone("Etc/GMT-2"))
start_time = current_time - timedelta(minutes=interval)

logging.info("Candle Request From : "+ str(start_time)+ ", To: "+str(current_time))
Candle Request From : 2024-11-25 06:15:00.005051+02:00 , To: 2024-11-25 06:16:00.005051+02:00
candles = self.mt5.copy_rates_range(self.symbol, self.get_mt5_time_format(interval), start_time, current_time)
if candles is not None and len(candles) > 0:
candles_frame = pd.DataFrame(candles)
logging.info("Recieved Tick "+ str(pd.to_datetime(candles_frame['time'], unit='s', utc=True)))
candles_frame['time'] = pd.to_datetime(candles_frame['time'], unit='s', utc=True).dt.tz_convert(pytz.timezone("Etc/GMT-2")
logging.info("After Candle Converted to GMT+2 "+ str(candles_frame['time']))
latest_candle = candles_frame.iloc[-1]
self.process_ticks_to_ohlc(latest_candle, candles_frame['time'], interval)

i should receive 6:15 candle but im getting 4:16 candle

LOGS
Recieved Tick 0 2024-11-25 04:15:00+00:00
1 2024-11-25 04:16:00+00:00
Name: time, dtype: datetime64[ns, UTC]
2024-11-25 06:16:00,075 - INFO - After Candle Converted to GMT+2 0 2024-11-25 06:15:00+02:00
1 2024-11-25 06:16:00+02:00
Name: time, dtype: datetime64[ns, Etc/GMT-2]
2024-11-25 06:17:00,076 - INFO - OHLC {'Open': 2701.85, 'High': 2702.27, 'Low': 2701.56, 'Close': 2702.22, 'trading_symbol': 'XAUUSD', 'Volume': 343, 'timestamp': '2024-11-25T06:17:00Z', 'time_frame': 1, 'is_last': False}
2024-11-25 06:17:00,085 - INFO - 1 Sleep Until 2024-11-25 06:17:00+02:00

that received tick is matching with GMT+2 2024-11-25 04:16:00+00:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant