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.

Missed ticks during disconnection not in IHistory?
 Post subject: Missed ticks during disconnection not in IHistory? Post rating: 0   New post Posted: Fri 13 Mar, 2020, 13:44 

User rating: 0
Joined: Wed 15 Jun, 2016, 12:31
Posts: 2
Location: Malaysia,
When a strategy is disconnected and reconnected, would i be able to get the missed ticks from IHistory? logically i think yes but i cant. The code is below:

package singlejartest;

import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Period;

import static com.dukascopy.api.Instrument.EURUSD;
import java.util.List;
import java.util.Set;

public class ABC implements IStrategy{
    IConsole console;
    IHistory history;
    long BeginTime;

    @Override
    public void onStart(IContext context) throws JFException {
    history = context.getHistory();
    console = context.getConsole();
    context.setSubscribedInstruments(Set.of(EURUSD), true);
    BeginTime=-1;
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {
    if (instrument.equals(EURUSD)){
    long LastTime = history.getTimeOfLastTick(instrument);
    if (BeginTime!=-1){   
    List<ITick> ticks;
    try {
    ticks = history.getTicks(instrument, BeginTime, LastTime);
    int size = ticks.size();
    console.getOut().println(
    "Size,"+size     
    );
    } catch (JFException e) {
    }   
    }
    BeginTime = LastTime;   
    }   
    }

    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }

    @Override
    public void onMessage(IMessage message) throws JFException {   
    }

    @Override
    public void onAccount(IAccount account) throws JFException {
    }

    @Override
    public void onStop() throws JFException {
    }
}


If there is no disconnection, the size prints 2, which is correct.

But when i tried to turn off my internet and turn back on, the size would sometime also print 2 or 3, never the full number of the ticks i missed (of course i did check that the market indeed moved during the disconnection).


 
 Post subject: Re: Missed ticks during disconnection not in IHistory? Post rating: 0   New post Posted: Tue 24 Mar, 2020, 17:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Greetings

Intraperiod data (for ticks it is last hour) are deleted from cache after reconnect to server.
When next tick is arrived to strategy, ticks for last hour can be not reloaded yet.
Strategy should wait few seconds before loading ticks for disconnect time interval.

Best regards, API Support.


Attachments:
ABC.java [1.86 KiB]
Downloaded 121 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

Jump to:  

cron
  © 1998-2024 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