Jump to content
Ramana

Tradehistory not returning any results

Recommended Posts

Hi,

I tried to call the tradehistory but it's not returning any results. I tried from date as "2018.06.15 00:00:00" in both in seconds (1529038800) and milliseconds (1529038800000). I appreciate if anyone can help. Thanks in advance.

image.thumb.png.30b6e962e41ea342a1cf443ba6db0310.png

Share this post


Link to post

Hi,

Aside from Username and Session, the parameters for GET calls must be supplied in the query string, and NOT the header. See the following example where the call executes successfully.

Note: the time should be in seconds (1529038800).

image.png

Share this post


Link to post

Thanks for your help. Per your suggestion, I tried the same way with new session Id. But I am getting 'Session is not valid' error. Did I miss anything? 

image.thumb.png.24363610ba718b02dfd30d4af379a93b.png

Share this post


Link to post

Hi,

It looks as though your session has expired. Try logging in again and obtaina new Session. Use that new session in your TradeHistory call and see if that resolves the issue.

Kind Regards, PM! 

Share this post


Link to post

Hi,

Yes. I tried several times with new sessions. But it didn't resolve the issue. It's giving the same 401 unauthorized and session not valid error. I appreciate your help.

Thank you,
Ramana

Share this post


Link to post

Hi Ramana,

If you are using a demo/test account, then please send me via a private message your account credentials. I'll try using it to Login and retrieve a session and then attempt to get the tradehistory and see what happens.

Your assistance is much appreciated.

Kind Regards, PM

Share this post


Link to post

Hi Ramana,

Thanks for sending across your demo account credentials. I'ved used your account to test out the calls successfully in the following manner. 

1) Used your account credentials to perform a login operation and obtain a valid session ID.

image.png

 

2) I then used the SessionID from the Login response and your Username to make a ClientAndTradingAccount call to obtain your ClientAccountID.

3) Finally, I used the ClientAccountID, SessionID and Username to request your trade history, which was successful and returned the tradehistory result. I double checked your account and see no test trades have been placed on this account. Hence the empty list in the returned result. 

image.png

Please try the same process as above and see if you can make a successful call.

To save you a bit of effort for step 2, I'm going to send your ClientAccountID in a private message so you can simply put that value into the query string when you come to step 3. 

Kind Regards, PM

Share this post


Link to post

Thanks PM. Now I am able to get 200 OK status, but no data was returned in the results. How did you get the client account id? I have only my trading account id.

Share this post


Link to post

Hi,

When you say no data was returned in the results, do you mean you received the same as shown in the following screenshot, or just a blank response?

If it is the aame as the screenshot then that is the correct response. As I mentioned in my previous reply: "I double checked your account and see no test trades have been placed on this account. Hence the empty list in the returned result."

I checked this account a few minutes ago and no trades have been placed yet, so the trade history will be empty until trades have been transacted on this account.

Kind Regards, PM

image.png

Share this post


Link to post

I forgot to answer the second part of your query. Using the TradingAccountId or Client AccountId can both work, the documentatoin specifies the difference.

"ClientAccountId - this can be passed in order to retrieve all information on all trading accounts for which it is the parent. TradingAccountId - this can be passed to retrieve information specific to a certain trading account (the child of ClientAccount).

If neither ClientAccountId nor TradingAccountId is passed, then the information returned by default from the API is ClientAccount."

To obtain the ClientAccountID, use the GetClientandTradingAccount call.

Share this post


Link to post

How do I query another account id? I want to query my another Demo account and Live accounts. If use these account ids, it gives 401 unauthorized error.

Share this post


Link to post

When using the GetClientAndTradingAccount call, in the Headers, you'll need to use a valid Session ID and the Username for the account you are querying. In other words, you have to login with the account you want to query so you have a valid Session ID for the following GetClientAndTradingAccount call.

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
×