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.

Standalone API Multiple Strategy shutdown
 Post subject: Standalone API Multiple Strategy shutdown Post rating: 0   New post Posted: Fri 25 Apr, 2014, 19:51 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
Hi,

I'm seeking some clarity on just how I should handle
Strategy termination.

So if I ask a Strategy to terminate itself, by queueing
an IContext.stop() onto its callback thread using
Callable through IContext.executeTask(...)

When the Strategy terminates, what is the responsibility
of IClient? Should it fetch the Map on some
notification using
IClient.getStartedStrategies() and then explicitly
remove the IStrategy instance value from
that Map? (Or does it disappear automatically
when the Strategy instance is acknowledged
as terminated?)

I'm seeing the Strategy terminate, but then "resurrect"
itself. I don't think I have anything doing that, so I'm
speculating that the runtime system might do that, if
I haven't removed the Strategy from the Map which
is accessible through IClient.getStartedStrategies() ...
Probably just a wild guess on my part which is incorrect .........

I have a Strategy termination notification mechanism,
but is there a built-in callback for that event to the IClient?
Yep, looks like IClient.setSystemListener supplies these events
to the client, so I'll use that for the notifications.

Thanks for clarifying this for me !
HyperScalper


 
 Post subject: Re: Standalone API Multiple Strategy shutdown Post rating: 0   New post Posted: Sun 27 Apr, 2014, 20:48 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
I notice that when my API client launches 2 instances
of the same strategy (not from .jfx file, but just Java class object
instantiation from within a jar file), that a given class file gets an
identical Strategy ID. This seems to be a checksum calculated
from the class file's byte pattern, that's my guess:


Instance #1
Strategy "HyperBotDCSMgr" Strategy ID: F6648214B47FF11F9BF33F6076369C91
Select Instrument"=[EUR/JPY]

Instance #2
Strategy "HyperBotDCSMgr" Strategy ID: F6648214B47FF11F9BF33F6076369C91
Select Instrument"=[GBP/JPY]




What is the purpose of the Hex looking Strategy ID value?

Since we get ISystemListener.onStart processId for example, 37 for one
instance #1, and 131 for another instance #2. These are our
Strategy "instance id's" (aka "processIds").

I see that IClient.stopStrategy (processId) can be used to forcibly
terminate an IStrategy instance. I assume that's the same processId which
is delivered in ISystemListener.onStart, is that correct?

If I can get a reference to a Strategy instance by using the processId,
then I won't have to maintain a separate HashMap to my running
Strategy instances, and it seems that can be done as follows:

I see that IClient.getStartedStrategies returns Map<Long,IStrategy>
and the Long entry appears to be the "processId". So this means
I won't have to maintain a separate Map to individually address my
Strategy instances.

And so long as I do not maintain a persistent reference to my
Strategy instances when they either terminate or are forcibly
shut down, then they WILL BE garbage collected, is that correct?

I guess I could verify that by implementing a finalization
callback......

HyperScalper


 
 Post subject: Re: Standalone API Multiple Strategy shutdown Post rating: 0   New post Posted: Tue 06 May, 2014, 14:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
hyperscalper wrote:
Should it fetch the Map on some
notification using
IClient.getStartedStrategies() and then explicitly
remove the IStrategy instance value from
that Map? (Or does it disappear automatically
when the Strategy instance is acknowledged
as terminated?)
The latter.
hyperscalper wrote:
What is the purpose of the Hex looking Strategy ID value?
This is just an info parameter.
hyperscalper wrote:
I see that IClient.stopStrategy (processId) can be used to forcibly
terminate an IStrategy instance. I assume that's the same processId which
is delivered in ISystemListener.onStart, is that correct?
Yes, and the same one returned by the IClient.startStrategy method.
hyperscalper wrote:
And so long as I do not maintain a persistent reference to my
Strategy instances when they either terminate or are forcibly
shut down, then they WILL BE garbage collected, is that correct?
They should be eligible for garbage collection if your code does not hold any non-null references to them.


 

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