Announcement

Collapse
No announcement yet.

RequestHistory on daily basis : IsHistoryReady always false

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RequestHistory on daily basis : IsHistoryReady always false

    HI!


    Am developing software to obtain histories of futures, interval '1' (minute) and 'D' (daily).
    Im principle, I start with 'RequestHistory', collect data in 'OnBarsChanged', and poll with 'IsHistoryReady' to finish with 'Release History'.
    For the minute interval, everything works fine. If there are no entries for a specific contract, or even if the symbol is not written correctly, then 'IsHistoryReady' is immedeatly true.

    However, for daily data, requests of the history of some contracts are never reported to be ready. This is the case if the symbol does not exist, or if no data is available. This is true for example for BR N2005, C N2005 or S N2005, with RequestHistory Parameters 'D',btDays,10,-1,-1.

    There is only one way to fire an event:
    With the request sent and waiting for an event to fire (OnBarsChanged, OnBarsReceived), I load the history manually with the eSignal-Application. Then the OnBarsReceived event is fired and IsHistoryReady switches to true in my own application.

    So I suppose, I miss something when requesting the history.
    Or at least I have to release the history before isHistoryReady switches to true, e.g. after timeout-limit.

    So my questions are:
    Is it save to use 'ReleaseHistory' before isHistoryReady is true, or is somthing wrong with my way to obtain a history on daily time base?

    Thanks for any help,

    Martin

  • #2
    Hi Martin,

    Can you post the code in question so we can take a look at it?

    Thanks!
    StarrM
    eSignal Developer Support

    Comment


    • #3
      Delphi Code

      Ok, here is the complete Delphi-code for a small test program that shows the problem posted before.

      Pressing Button2 sets parameters for RequestHistory and shows the corresponding command line in the Memo.
      Here, with intv='1', everything works. By pressing Button3, isHistoryReady is checked and the result (in this case true) is shown in the memo. As there are no entries for 'BR N2005', the number of data read in GetData is zero.

      If intv is changed to 'D', then isHistoryReady never switches to true.


      _____________________

      unit eSigTestMain;

      interface

      uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleServer, IESignal_TLB;

      type
      TForm1 = class(TForm)
      Hooks1: THooks;
      Button1: TButton;
      Memo1: TMemo;
      Button2: TButton;
      Button3: TButton;
      Memo2: TMemo;
      procedure Button1Click(Sender: TObject);
      procedure Hooks1EntitledValid(Sender: TObject);
      procedure Button2Click(Sender: TObject);
      procedure Hooks1BarsChanged(ASender: TObject; lHandle: Integer);
      procedure Hooks1BarsReceived(ASender: TObject; lHandle: Integer);
      procedure Button3Click(Sender: TObject);
      procedure FormCreate(Sender: TObject);
      procedure FormActivate(Sender: TObject);
      procedure GetData(handle : integer);
      private
      hhandle : integer;
      { Private declarations }
      public
      firstrun : boolean;
      { Public declarations }
      end;

      var
      Form1: TForm1;

      implementation

      {$R *.dfm}

      procedure TForm1.Button1Click(Sender: TObject);
      begin
      Hooks1.SetApplication('iuvaris');
      end;


      procedure TForm1.Button2Click(Sender: TObject);
      var s,sy,intv,bt : string;
      nbars,bti : integer;

      begin
      sy := 'BR N2005';
      intv := 'D';
      nbars := 20;
      bt := 'btDays';

      if AnsiCompareText(bt,'btDays')=0 then bti:=btDays
      else if AnsiCompareText(bt,'btBars')=0 then bti:=btBars
      else begin Application.MessageBox('Bar Type undefined','Error',MB_OK); Exit; end;

      Hooks1.ClearSymbolCache;

      hhandle:=Hooks1.RequestHistory[sy,intv,bti,nbars,-1,-1];
      s:='Request for '+ sy + ' ' + intv +' '+ bt + ' ' + IntToStr(nbars)+' ' + '-1 '+'-1 ';
      Memo1.Lines.Add(s);
      end;


      procedure TForm1.Button3Click(Sender: TObject);
      var s : string;
      begin
      if Hooks1.IsHistoryReady[hhandle]=0 then
      Memo1.Lines.Add('History not ready')
      else begin
      Memo1.Lines.Add('History is ready');
      GetData(hhandle);
      end;
      end;



      procedure TForm1.GetData(handle : integer);
      var iBar, nbars : Integer;
      barItem : BarData;
      s : string;
      begin

      nBars:=Hooks1.GetNumbars[Handle];
      for iBar := -(nBars-1) to 0 do
      begin
      baritem := Hooks1.GetBar[Handle,iBar];

      With baritem do
      begin
      DateTimeToString(s,'yyyy.mm.dd hh:nn:ss',dtTime);
      s := s + format(' %.4f %.4f %.4f %.4f %.4f %.4f',[dopen,dhigh,dlow,dclose,dVolume,dOI]);
      end;
      Memo2.Lines.Add(s);

      end;

      end;



      procedure TForm1.Hooks1BarsChanged(ASender: TObject; lHandle: Integer);
      begin
      Memo1.Lines.Add('OnBarsChanges');
      end;

      procedure TForm1.Hooks1BarsReceived(ASender: TObject; lHandle: Integer);
      begin
      Memo1.Lines.Add('OnBarsReceived - ' +
      format('Numbars = %d',[Hooks1.GetNumbars[lHandle]]) );

      end;


      procedure TForm1.Hooks1EntitledValid(Sender: TObject);
      begin
      Memo1.Lines.Add('EntitledValid');
      end;





      procedure TForm1.FormCreate(Sender: TObject);
      begin
      firstrun:=true;
      end;

      procedure TForm1.FormActivate(Sender: TObject);
      begin
      if firstrun=true then
      begin
      Memo1.Clear;
      firstrun:=false;
      end;
      end;


      end.

      Comment

      Working...
      X