from datetime import datetime
import MetaTrader5 as mt5
import requests
import datetime as dt
import numpy as np
import json
from statistics import mean
import pandas as pd
import pytz
import os
import time
import math
#Im living in Singapore and the timing on MT5 is in a different timezone. I managed to find the code below to sync it to UTC
u = datetime.utcnow()
utc_from = u.replace(tzinfo=pytz.utc)
currency_pair = {"EURUSD": 2, "GBPUSD": 2, "USDJPY": 2, "USDCAD": 2, "USDCHF": 2, "NZDUSD": 2, "AUDUSD": 2, "AUDNZD": 2, "AUDCAD": 2}
for currency in currency_pair:
rates = mt5.copy_rates_from(currency, mt5.TIMEFRAME_M30, utc_from, 500)
rates_frame = pd.DataFrame(rates)
rates_frame['close_time'] = rates['time']
rates_frame['time'] = pd.to_datetime(rates_frame['time'], unit='s')
Hi All
I'm trying to get the historic price as well as the latest pricing, however, the last pricing that I got is different from what is showing on tradingview.
May I know what am I missing?
time open high low close tick_volume spread real_volume close_time
499 2020-07-06 13:00:00 0.94365 0.94386 0.94247 0.94258 1217 25 0 1594040400
asset is AUDCAD
the pricing on tradingview is 0.945 instead of my result of 0.94258.
there is a difference of 0.945 - 0.942 = 0.003