|
Remote Run. onStart tick is NULL |
velldes
|
Post subject: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 18:32
|
|
User rating: 1
Joined: Sun 20 May, 2012, 09:29 Posts: 22 Location: Czech Republic, programmer
|
Dear support team, When starting strategy using "Remote Run", in onStart method can not get TICK from history. @Override public void onStart(IContext context) throws JFException {
ITick tick = context.getHistory().getTick(instrument, 0); }
In this case TICK is NULL. Please, can you check it?
|
|
|
|
|
jlongo
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 18:35
|
|
User rating: 94
Joined: Mon 06 Feb, 2012, 12:22 Posts: 357 Location: Portugal, Castelo Branco
|
Hi:
Try to get tick information after the strategy has subscribed the instrument. If done forget this post.
Trade well
JL
|
|
|
|
|
velldes
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 18:46
|
|
User rating: 1
Joined: Sun 20 May, 2012, 09:29 Posts: 22 Location: Czech Republic, programmer
|
jlongo wrote: Hi:
Try to get tick information after the strategy has subscribed the instrument. If done forget this post.
Trade well
JL Thanks for quick reply. In real strategy I try to get tick after subscribing to instruments.
|
|
|
|
|
jlongo
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 18:49
|
|
User rating: 94
Joined: Mon 06 Feb, 2012, 12:22 Posts: 357 Location: Portugal, Castelo Branco
|
Hi:
Sometimes subscribing can take some time... You can try to see if instrument is subscribed before try to get tick information.
Trade well
JL
|
|
|
|
|
velldes
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 19:00
|
|
User rating: 1
Joined: Sun 20 May, 2012, 09:29 Posts: 22 Location: Czech Republic, programmer
|
jlongo wrote: Hi:
Sometimes subscribing can take some time... You can try to see if instrument is subscribed before try to get tick information.
Trade well
JL I use code below to subscribe to instruments context.setSubscribedInstruments(instruments);
// wait max 1 second for the instruments to get subscribed int i = 10; while (!context.getSubscribedInstruments().containsAll(instruments) && i >= 0) { try { console.getOut().println("Instruments not subscribed yet " + i); Thread.sleep(1000); } catch (InterruptedException e) { console.getOut().println(e.getMessage()); } i--; }
|
|
|
|
|
jlongo
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Thu 26 Sep, 2013, 19:06
|
|
User rating: 94
Joined: Mon 06 Feb, 2012, 12:22 Posts: 357 Location: Portugal, Castelo Branco
|
I do not see any reasonable explication to be unable to get tick information if you try to get it after that code... lets see if support has anything to say.
Trade well
JL
EDIT: instead of context.getHistory().getTick(instrument, 0); try with context.getHistory().getLastTick(instrument); it gets last tick received by the strategy. current tick (shift 0) sounds a litle ambiguos to me as at that time the method is called exist the possibility of no existing tick.
|
|
|
|
|
velldes
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 0
|
Posted: Fri 27 Sep, 2013, 07:31
|
|
User rating: 1
Joined: Sun 20 May, 2012, 09:29 Posts: 22 Location: Czech Republic, programmer
|
jlongo wrote: EDIT: instead of context.getHistory().getTick(instrument, 0); try with context.getHistory().getLastTick(instrument); it gets last tick received by the strategy. current tick (shift 0) sounds a litle ambiguos to me as at that time the method is called exist the possibility of no existing tick.
Both methods return NULL. Ticks in History available only after onTick method execution.
|
|
|
|
|
hebasto
|
Post subject: Re: Remote Run. onStart tick is NULL |
Post rating: 1
|
Posted: Wed 16 Oct, 2013, 22:25
|
|
User rating: 96
Joined: Mon 09 Sep, 2013, 07:09 Posts: 287 Location: Ukraine, SHostka
|
Try this snippet for your onStart() method: //wait max 10 secs for (int i = 10; i > 0; i--) { try { Thread.sleep(1000); } catch (InterruptedException e) { context.getConsole().getOut().println(e.getMessage()); } if (context.getHistory().getLastTick(instrument) != null) break; }
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|