Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 819 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Developing an Oanda API and having issues #453999
08/23/15 22:41
08/23/15 22:41
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline 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/#6

which 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: Mithrandir77] #454009
08/24/15 09:43
08/24/15 09:43
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I also think Rest is definitely the way to go. I'm not familiar with Oandas authentication method, but I assume the access token is a text string that can be copied in the user name field?

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 Offline OP
Member
Mithrandir77  Offline 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: Mithrandir77] #454014
08/24/15 14:12
08/24/15 14:12
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
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.

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 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Originally Posted By: jcl
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 Offline OP
Member
Mithrandir77  Offline 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/#getInformationSpecificTrade

and Transactions http://developer.oanda.com/rest-live/transaction-history/#getTransactionHistory

For 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... frown

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: Mithrandir77] #458293
03/03/16 07:52
03/03/16 07:52
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
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.

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 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Originally Posted By: jcl
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: Mithrandir77] #458346
03/05/16 18:22
03/05/16 18:22
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
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.

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 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Originally Posted By: jcl
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!


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1