Jump to content
atomboy

Keep getting invalid request for historical data

Recommended Posts

I can get latest tick data when I don't supply from_ts or to_ts. But when I supply either timestamps I keep getting 'invalid request'. I'm testing my code in demo account. I also tried multiplying new_ts with 1000 to get milliseconds but still got the same result. I need help here as I can't do anything without historical data.

Code:

resp = client.client.get_market_info('AUD/USD')
market_id = resp['Markets'][0]['MarketId']
bid_resp = client.client.get_prices(market_id=market_id, num_ticks=2,price_type='bid')
for bid in bid_resp['PriceTicks']:
    bid_ts = re.findall('\((.+)\)',bid['TickDate'])[0]
    print('received ts:',bid_ts)
    new_ts = convert_date(convert_date(bid_ts) - datetime.timedelta(hours=1))
    print('new ts:', new_ts)
    new_bid_resp = client.client.get_prices(market_id=market_id,num_ticks=2,to_ts=int(new_ts),price_type='bid')
    print(new_bid_resp)

 

output:

received ts: 1608328799510
new ts: 1608325199
{'Message': 'The request is invalid.'}
received ts: 1608328799761
new ts: 1608325199
{'Message': 'The request is invalid.'}

Process finished with exit code 0

Share this post


Link to post

Hi,

I presume you are using the GetPriceTicksBetweenDates call? 

What are the "From" and "To" dates you are using? Depending upon market, we only store about 1-2 days worth of tick data on a rolling basis. If your dates are outside the data we have available, it would explain the invalid request error messages.

Kind Regards, PM

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×