PDA

View Full Version : Client API - Clarification Regarding Account



Edakad
02-08-2016, 09:01 AM
Hello,

I am developing with Client API. Please clear this subject.

I have successfully logged in with client API. Now it is said in the documentation that You have to select an account before sending new orders etc. I think this is because a single login id can have more than one account with the broker. Right ?

In the sample project with API shows a text box to enter account number. Can I get the account number from the API itself, if more than one account is available for the login, all those account. Then the client does not have to enter the account number, rather he can pick an account from a list box/combo box.

What is the proper way to do this. Is the All Data Are Loaded event handler is the best place to populate the accounts. How can I get the accounts for a login id. I see properties like Account By Index, Client By Index etc, but did not get it to pick the Account Number

Thanking You,

Hassan-HS
02-08-2016, 03:59 PM
Hello Edakad :cool:,


I have successfully logged in with client API. Now it is said in the documentation that You have to select an account before sending new orders etc. I think this is because a single login id can have more than one account with the broker. Right ?

Single login can has one client or more (if you login with group/office) and each client can has one or more than one account.



In the sample project with API shows a text box to enter account number. Can I get the account number from the API itself, if more than one account is available for the login, all those account. Then the client does not have to enter the account number, rather he can pick an account from a list box/combo box.

In this way you can fill the combo box. (don't forget, don't use this code before the API raise AllDataAreLoaded (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1995) event)



Dim Client As COClient
Dim Account As COAccount
For i As Integer = 1 To BOAPI.ClientsCount ' loop over all clients you have.
Client = BOAPI.ClientByIndex(i)
If Client IsNot Nothing Then
For j As Integer = 1 To BOAPI.AccountsCount(Client.ClientID) ' loop over all accounts that belong to the selected client
Account = BOAPI.AccountByIndex(Client.ClientID, j)
MsgBox(" Account: " & Account.AccountID)
Next
End If
Next



What is the proper way to do this. Is the All Data Are Loaded event handler is the best place to populate the accounts. How can I get the accounts for a login id. I see properties like Account By Index, Client By Index etc, but did not get it to pick the Account Number



Totally right. the proper time to do this is when AllDataAreLoaded (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1995) is fired.

Edakad
02-08-2016, 05:52 PM
Hello Hassan

As always you are very helpful. I think the sample code above is regarding the backoffice API, try with Client API and get back to you if needed

Thanks

Hassan-HS
02-09-2016, 07:48 AM
Hi,


As always you are very helpful. I think the sample code above is regarding the backoffice API, try with Client API and get back to you if needed

You are welcome anytime :cool:, it works 100% on client API