6 registered members (TipmyPip, Niels, dBc, Ed_Love, 3run, 1 invisible),
17,577
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Developing an Oanda API and having issues
#453999
08/23/15 22:41
08/23/15 22:41
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
I have started to develop an API for Oanda that can benefit the Zorro community. I have looked at the FXCMplugin.cpp file to have a template to start from. I understand that I have to make a .dll in c++, the problem is that Oanda offers four types of APIs: Rest, Java, FIX and MT4 From what I understand, Rest would be the way to go because I can use a c++ library that implements it. But Oanda uses OAuth to manage the authentication to their Rest API http://developer.oanda.com/rest-live/api-comparison/#6which implies redirecting the user to a webpage to make him/her enter credentials and then receiving an access token. How can I reconcile BrokerLogin (char* User, char* Pwd, char* Type, char* Accounts): int with OAuth?? The other alternative would be using Java API but is there a way to call a Java API function from C++? I appreciate any help/guidance!!
|
|
|
Re: Developing an Oanda API and having issues
[Re: jcl]
#454012
08/24/15 13:45
08/24/15 13:45
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
You mean making the user input his/her access token in the name field in Zorro UI? That would definitely work if the access token is forever which I think it is. However I don't know if that is a practice that would be approved by Oanda...you see there are 2 kinds of access tokens, personal access tokens that you get when you develop an application for yourself and third party access tokens which you get when developing an application for many users. In the latter case, the application has to be approved by Oanda. Here is the documentation for that http://developer.oanda.com/rest-live/authentication/
Last edited by Mithrandir77; 08/24/15 13:47.
|
|
|
Re: Developing an Oanda API and having issues
[Re: jcl]
#454018
08/24/15 15:27
08/24/15 15:27
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
It's personal use here. The user is responsible to get his access token. It would be third party access when I handle authentication on my server, and generate access tokens for distribution to multiple users. Many many many thanks jcl! That simplifies things a lot! So I think the user could enter the access token in the username field in Zorro UI or better, make an auxiliary application that stores the token in an encrypted file that is encrypted using username and password. Obviously, after accesing the token for the first time of running a 'Zorro session' the token is kept in memory so that I overcome the overhead of accesing a file. Are both approaches ok for Zorro BrokerLogin?
|
|
|
Re: Developing an Oanda API and having issues
[Re: Mithrandir77]
#458291
03/03/16 06:56
03/03/16 06:56
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
I got down to continue with this project but now I found another issue: For implementing BrokerTrade (int nTradeID, double *pOpen, double *pClose, double *pRoll, double *pProfit): int The documentations says: Number of contracts of the given trade ID number, or 0 when no trade with this ID could be found, or a negative number when the trade was recently closed. When the returned value is nonzero, the output pointers must be filled. The problem in the case of an open trade is that Oanda rest api offers two endpoints for this as far as I researched, Trades http://developer.oanda.com/rest-live/trades/#getInformationSpecificTradeand Transactions http://developer.oanda.com/rest-live/transaction-history/#getTransactionHistoryFor a closed trade I would have to iterate over all the transactions and found the one associated with the close (close order, stop close, etc) of that trade and there it is the rollover (interest in oanda's terms) But how can I retrieve the interest so far of an open trade? The closest is a transaction which is the daily interest payment for all the account for the open trades with an asset not for an specific trade with an asset. Is there a way to derive it? Wild guessing I could assign proportionally the interest of one day to the different trades according to the lots each have but it is difficult because a trade can reduce maybe their lots due to lock profit...  Is it really necessary to fill that output or Zorro can handle it? Thanks for your help!
Last edited by Mithrandir77; 03/03/16 07:10.
|
|
|
Re: Developing an Oanda API and having issues
[Re: jcl]
#458334
03/05/16 01:49
03/05/16 01:49
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
Zorro can handle missing values. So you don't need to fill it when it is not easily available. - We will probably be contracted in the next time to produce an Oanda Rest API plugin, so maybe better wait a couple weeks with continuing for not inventing the wheel twice. Ok, I asked because in the manual it says that when BrokerTrade returns a value different to zero -ie an open or closed trade- the output parameters have to be filled. How is that Zorro handles the absence of the rollover? Does it take from AssetsFix? In that case wouldn't Zorro miscalculate the account balance/equity since rollover changes from time to time?
|
|
|
Re: Developing an Oanda API and having issues
[Re: jcl]
#458347
03/05/16 18:46
03/05/16 18:46
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
Yes, it takes it from the asset list. There are two hurdles against miscalculation: the final trade result is returned from the API, and the current balance/equity is also returned from the API. Only when both are also missing, the wrong rollover can affect the balance or equity. All right, that is clever! So I won't worry about not getting the rollover, that also happens in dukascopy api, it does not have a function that returns the rollover/swap/interest of a position. The closest is https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IOrder.html#getCommission%28%29 but I think it refers to the commision that dukascopy charges as an ECN, I have asked them and I am waiting for their response... Thanks jcl for your answer!
|
|
|
|