Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Running Multiple Strategies in Parallel
 Post subject: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Mon 26 Nov, 2012, 21:24 
User avatar

User rating: 1
Joined: Fri 14 Sep, 2012, 02:25
Posts: 57
Location: New Zealand, Christchurch
A recent thread in the Support Forum suggested that it was extremely
dangerous to run multiple Strategies in parallel on the same account,
and that the best solution if this was needed was to have multiple accounts.

This doesn't match with the Wiki information which says:

In Strategies tab it is rather straightforward to run multiple
strategy instances in parallel. It is also possible to run multiple
instances of the same strategy both with the same parameters and
different presets of parameters.


suggesting in fact that it's fine to run the multiple Strategies in
parallel - or even the same Strategy multiple times with the same or
different parameter presets.


So I hope you can understand my confusion.
I want to parallel run multiple Strategies, and do not want to have (and
fund) multiple Dukascopy live accounts to achieve this.

Can you please advise me how I should therefore code my Strategy(s) to
only 'see' trades that it 'owns' and to never modify stop-losses etc. on
orders it has not created itself.


I understand that order Labels have to be unique - and I have been using
my Strategy name + instrument + a counter for all my Labels.

Do I also need to put a 'thread id', or something that uniquely
identifies the preset that I'm using, or the Strategy run start-time
perhaps (?) - so that I can check each order is actually 'mine' before I
update it?


I notice that none of the example Strategies provided on the Support
Forum (JForex Support Board > Automated Trading > Code Base >
Strategies) include any code that performs this sort of ownership
checking - so I have been assuming that the JForex platform
automatically synchronizes threads & associated data.

If indeed I need to specifically code in order to parallel run multiple
instances, then some guidance and/or an example of best practice Java
code would be extremely useful please.


 
 Post subject: Re: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Tue 27 Nov, 2012, 08:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
fprophet wrote:
I understand that order Labels have to be unique - and I have been using
my Strategy name + instrument + a counter for all my Labels.
Yes that is one option, however, it won't help if you will call the same strategy on the same instrument (or instrument set). For such case consider adding an java.util.UUID which will guarantee the label uniqueness (i.e. Strategy name + instrument + a counter + UUID.randomUUID().toString().replaceAll("-", "")). In fact using the UUID alone will also guarantee the uniqueness, but will make the order difficult to distinguish in logs and on chart.

Another option is maintaining all strategy-created orders in a java.util.List or java.util.Set, see:
https://www.dukascopy.com/wiki/#Order_Management/Maintain_order_list
Actually there are two things to be aware of:
  1. Label uniqueness among all orders. Order opening attempt with the same label on the same account will result in a JFException.
  2. Making sure the strategy works only with its own orders (if that is required by the strategy logic).
fprophet wrote:
Do I also need to put a 'thread id', or something that uniquely
identifies the preset that I'm using, or the Strategy run start-time
perhaps (?) - so that I can check each order is actually 'mine' before I
update it?
It is up to you, however, we find the previously mentioned approach the least tedious.
fprophet wrote:
I notice that none of the example Strategies provided on the Support
Forum (JForex Support Board > Automated Trading > Code Base >
Strategies) include any code that performs this sort of ownership
checking - so I have been assuming that the JForex platform
automatically synchronizes threads & associated data.
Each strategy works in its own thread, but the platform does not prevent strategy from modifying a not-its-own order, thus, depending on the strategy, they might need to get updated such that they don't modify/close orders of other strategies.
fprophet wrote:
If indeed I need to specifically code in order to parallel run multiple
instances, then some guidance and/or an example of best practice Java
code would be extremely useful please.
See our previously given example.


 
 Post subject: Re: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Wed 28 Nov, 2012, 01:00 
User avatar

User rating: 1
Joined: Fri 14 Sep, 2012, 02:25
Posts: 57
Location: New Zealand, Christchurch
Thank you - I appreciate your comprehensive answer :)


 
 Post subject: Re: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Tue 17 Sep, 2013, 21:49 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Dear Support,

I hope it is not a problem to bring up and old topic, but there is useful information in here that I would like to refer to.
Is there anything new available (in latest API releases) on the subject? I want a strategy (or multiple strategies) to run on the same instrument with different periods and I want to uniquely identify which order was created by which strategy. But this should be working if the strategy has stopped/restarted, so a List within the strategy is not an option.

Still a unique label, which contains the strategy identifier is the best approach for this?

Thanks,
tcsabina


 
 Post subject: Re: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Wed 18 Sep, 2013, 08:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
tcsabina wrote:
Still a unique label, which contains the strategy identifier is the best approach for this?
For the persistance between the strategy runs - yes, but you may also use the comment parameter for the same purpose.


 
 Post subject: Re: Running Multiple Strategies in Parallel Post rating: 0   New post Posted: Wed 18 Sep, 2013, 11:37 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
API Support wrote:
...you may also use the comment parameter for the same purpose.

Even better, as comment is not visible on the chart like label.
Thanks!


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com