Profile Picture

Oanda plugin and accounts

Posted By Freolad 9 Years Ago
Message
Posted Tuesday November 25 2008
I'm not sure where else to post this.

I'm using the Oanda plugin developed Mark Loftis. BTW, great work Mark. It looks good. My only regret is that there's not a 64bit version of it availablen (not sure if there's anything you can do about that Tongue)

Anyway, I was wondering if there was any way to specify an account or sub-account to use for placing trades?
Posted Tuesday November 25 2008
Hi Freload,

Thanks for the compliment Smile You're more than welcome to discuss the plugin here if you like. The current version of the plugin uses the Symbol Exchange field to specify an account. You should be able to put any availale oanda account id there. By default, the plugin uses the first account returned by oanda. One thing to note, this functionality was not tested very much as it was always destined to be replaced. There is a better method of specifying default values (including accounts) coming in the very near future. I'd just like to work out the remaining SetAccountState() issues first, before I update the google project.

Cheers!
Mark


Posted Tuesday November 25 2008
Hi Mark,

Thanks for the quick response and informative post and I'll follow your advice and use use the exchange field for now. I look forward to playing around with the new release. There's an impressive amount of code there. Let me know if I can assist with testing.

Cheers.
Posted Wednesday February 18 2009
Hi -

So could one run multiple instances of RightEdge and assign a different Oanda subaccount to each instance's plugin?

Given sufficient RAM, will multiple RE instances run okay?

I did not see much in these forums searching for subaccount - and think it would be a very useful part of a future generation Multiple Systems architecture for RE.

I'll just add my own kudos to RE and to Mark for some great work...


Posted Wednesday February 18 2009
Hi hqfx,

Thanks for the compliments on the oanda plugin. You can certainly accomplish what your asking. The plugin's trade entities data file allows you to assign an account and execution bounds values on a per symbol/trade direction basis. You can also define a default fallback value for unspecified entities.

in other words you can specify :
- long eur/usd trades go to sub-account X
- short eur/usd trades go to sub-account Y
- long gbp/usd trade go to sub-account Z
- etc...

When instanced the plugin will read this data file and direct new orders accordingly. The plugin does not care what values they are and will let you trade any pair in any direction on any account. Be aware that oanda does not allow bi-direction trades to be active in the same sub-account. This can cause problems if you trade long/short on the same symbol in the same account with RE as the plugin can't handle order-to-order trading.

Given sufficient computing resources (cpu/ram), you can run as many instances of RE on the oanda plugin as you need. The limiting factor would most likely be your bandwidth. When running a system in live mode the plugin needs 3 connetions to the oanda servers, so multiply this by the number of instances you would want to create.

For subaccount specific MM you can also access the AccountValuesStore from your trading system which will let you get the subaccount specific margin and balance values after an IBroker.GetMargin() or IBroker.GetBuyingPower() call.

Cheers!
Mark
Posted Friday February 20 2009
mark0419 (2/18/2009)
The plugin's trade entities data file allows you to assign an account and execution bounds values on a per symbol/trade direction basis.


Thanks Mark, I understand your reply. But can you further clarify how best to handle using designated subaccounts for specific overall trade strategies?

In other words, RE currently doesn't handle running multiple systems/strategies (trend follow, bb, etc) unless one uses a "Multiple Systems" logic as in the posted samples. In the future RE3(?) will have such functionality, from what I've read. For the present though I could run separate instances of RE for each (set of) strategies. Is each instance of the plugin specific to the given instance of RE, such that a specific subaccount will be "assigned" to each specific instance of RE and its system/strategy?

Looks like I'll have to activate the API to try this myself so I'm trying to understand as much up front as possible.
Thanks!
Posted Friday February 20 2009
I'd be happy to clarify as much as you need. There is a ReadME with some more details on this, but it is still quite spotty.

When RightEdge is launched on a live trading system it creates an instance of the plugin to handle the broker functions. This instance of the plugin is unique, and it's bound to the instance of RightEdge from which it was created. When a plugin instance is being constructed it receives all of the service settings from RightEdge. These settings contain the file names of the trade entities and account values stores for the broker plugin to use. So, if you use the same file names you can get multiple instances of RightEdge to do the same thing, or use different file names and get different behavior. It's up to you how you want to set it up.

Design wise, to overcome the mono "global-account" there are two basic issues :

1) order routing - Since there are no facilities to directly specify an account number on an order, the broker module needs a lookup mechanism. This is where the trade entities data file comes in. You can specify the file name in your service setup inside RE. Note that there is toolbar button to edit this file on the custom service settings dialog. The contents of this file help the broker module decide what sub-account to use for each order request. (Note that there is a button on the service settings custom dialog toolbar to edit the entities file.)

2) position sizing - you can't really use the % allocations from the position manager since the balance reported to the RightEdge "global-account" reflects the sum of all detected sub-accounts. Every time an instance of the plugin receives a call from RE to check the account margin and balances, the plugin updates the AccountValuesStore data file specified in the startup options and reports the totals back to RightEdge. Thus to get a sub-account specific balance/margin for position sizing calculations a trading system must probe the account values store using code like this...

//create the avs in your system startup
FunctionObjectResult avres = AccountValuesStore.newFromSettings("your avs file name");
if (avres.Error)
{
// deal with the error
}
AccountValuesStore acct_data = avres.ResultObject;


//somewhere in your trading system (ie NewBar(), etc..)
//to get fresh data, force the broker to update the avs and re-parse the results like this...
FunctionResult fres = acct_data.RefreshFromBroker(SystemData);
if (fres.Error)
{
// deal with the error
}


Also, the standalone Monitor tool can be used to trace the contents of the AVS in real-time (polled).

Hope that helps!

Cheers!
Mark
Posted Friday May 08 2009
I've been reading with interest about the changes in RE Ed 2.  But we'll have to wait for Ed 3 until multiple strategies are integral to the app...

I've been looking to build a remote-machine based trading platform that handles multiple strategies across different sub-accounts. Ideally the live RE trading application would be run as a service using FireDaemon, allowing restarts after disconnects etc. So that means a single instance of RE.

RE currently can address multiple system strategies using the like named "sample" system. But is there a way for Mark's plug in to "switch" subaccounts based on the system code?

In other words, can the trade entities file be modified "on the fly" for each given order such that execution takes place in the specific sub-account desired? Maybe this would introduce other complications ... but I'd be curious about your thoughts

Posted Friday May 08 2009
Hi hqfx,

The trade entities can definitely be modified on the fly. There is a flag in the TradeEntites class 'RefreshOnLookup' which will cause the xml file to be re-read before any lookup values are returned. By default this is set to true in the oanda plugin so it will be aware of changes as they are made.

The plugin generally performs any needed lookups when it receives an order submission. Incoming responses from the broker are mapped against that response's specific account id, so no lookup is needed there.

Cheers!
Mark
Posted Monday November 02 2009
Hi Mark,

i don't know if you are aware of this, but Oanda has a new api version now with a few improvements (instant quote delivery, and it also doesn't disconnect on every exception anymore). It now uses a SOAP server to warp around their java api. I did some tests and it appears to work quite well.

Do you plan on updating your plugin? I think it would be a pretty painless job while improving the project quite a bit.

Regards,
P.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems