Currency Tick History in Python

I am trying to obtain currency tick history, for example last 5 years of 1 minute Open, High,Low, Close for USDZAR. the documentaion seems to be fairly dated on how to set up the request (how do i obtain a token) and how do i structure the query to create a dataframe with DateTime Index, and the columns populated with values.

Best Answer

  • jolin.majmin
    Answer ✓

    There was an error in the pdf. The code block with error line, in bold, corrected below.

    timestamp = pd.Timestamp('now')
    today = timestamp.tz_localize('UTC').tz_convert(pytz.timezone('Africa/Johannesburg'))
    today_str = today.strftime('%Y-%m-%d')


    yesterday = (today - pd.Timedelta(1, "d")).normalize()
    yesterday_str = yesterday.strftime('%Y-%m-%d')


    start_date = pd.to_datetime('2010-01-01', format='%Y-%m-%d')
    start_date_str = start_date.strftime('%Y-%m-%d')


    filedate = (timestamp - pd.Timedelta(1, "d")).strftime('%Y%m%d')


    QueryStartDate = start_date.strftime("%Y-%m-%dT%H:%M:%S.000Z")
    QueryEndDate = yesterday.strftime("%Y-%m-%dT%H:%M:%S.000Z")


    print("QueryStartDate:", QueryStartDate)
    print("QueryEndDate:", QueryEndDate)

Answers

  • @jolin.majmin Thanks for your question - have you tried downloading the python sample jupyter notebook and .py files here. We also have some articles about using Tick History with Python here and here. I hope these can help.

  • I did try some of those files, they were fairly dated. Been used to xbbg from bloomberg which is easier to access data, and a bit faster, but after some fiddling. I created the script attached that takes account of proxy servers....glued some old bits together.Refinitiv Tick Summary Extraction.pdf