API Support Forum
User Profile

Viewing User Profile for: CBarabucci


About

Mar 24, 2021 05:56 PM

May 06, 2021 02:03 PM

May 06, 2021 02:03 PM


CB



Post Statistics
CBarabucci has contributed to 4 posts out of 5232 total posts (0.08%) in 249 days (0.00 posts per day).

20 most recent posts:

API Support » Real Time capturing data May 06, 2021 @ 02:03 PM (Total replies: 7)

Yesss, understood....
My new code for start Subscribction:

private void butTicksEnabled_Click(object sender, EventArgs e)
{
// Request ticks for the last 1 sec
gfClient.Subscriptions.Ticks.TicksReceived += GFClient_OnTicksReceived;
gfClient.Subscriptions.Ticks.Subscribe(contratto.ID, Client.Subscriptions.Ticks.Duration.Create(DateTime.UtcNow.AddSeconds(-1)));
}


and the code when received data:

private void GFClient_OnTicksReceived(IGFClient client, GF.Api.Subscriptions.Ticks.TicksReceivedEventArgs e)
{
lista.Clear();
foreach (var tick in e.Ticks)
{
DateTime data = tick.Timestamp.ToLocalTime();
StringBuilder record = new StringBuilder(data.Year.ToString());
record.Append("/");
record.Append(data.Month.ToString("00"));
record.Append("/");
record.Append(data.Day.ToString("00"));
record.Append(" ");
record.Append(data.ToLongTimeString());
record.Append(";");
record.Append(tick.Price.ToString("0.00").Replace(",","."));
record.Append(";");
record.Append(tick.Volume);
lista.Add(record.ToString());
}
System.IO.File.AppendAllLines("G:\\nql\\tiks.txt", lista);
}


For stopping reading I used:

private void butTicksDisabled_Click(object sender, EventArgs e)
{
gfClient.Subscriptions.Ticks.TicksReceived -= GFClient_OnTicksReceived;
}


I don't know if there is another way for stop it, perhaps the property .Unsubscribe() is supported...

But the more important thing is that now working fine, my data are perfect and I don't need Timer, because every second I receive data, thanks you very much!!!

API Support » Real Time capturing data May 04, 2021 @ 12:43 PM (Total replies: 7)

Great, I've readed Ticks documentation.

I tried to read every 10 seconds with timer, the last 90seconds Ticks, I don't need more data, I need small updates, but every seconds.


private void timer1_Tick(object sender, EventArgs e)
{
// Request ticks for the last 90 seconds
gfClient.Subscriptions.Ticks.Subscribe(contratto.ID, gfClient.Subscriptions.Ticks.Duration.Create(DateTime.UtcNow.AddSeconds(-90), DateTime.UtcNow));

}


and when the data are received, I load there in lista:


private void GFClient_OnTicksReceived(IGFClient client, GF.Api.Subscriptions.Ticks.TicksReceivedEventArgs e)
{

lista.Clear();

foreach (var tick in e.Ticks)
{
DateTime data = tick.Timestamp.ToLocalTime();
StringBuilder record = new StringBuilder(data.Year.ToString());
record.Append("/");
record.Append(data.Month.ToString("00"));
record.Append("/");
record.Append(data.Day.ToString("00"));
record.Append(" ");
record.Append(data.ToLongTimeString());
record.Append(";");
record.Append(tick.Price.ToString("0.00").Replace(",","."));
record.Append(";");
record.Append(tick.Volume);

lista.Add(record.ToString());
// ....
//....
}
}


But in lista for 29 seconds, I receive every time the same Ticks, and after 30 seconds the Ticks are update with the new Ticks, now the list are perfect, bat the update is too slow every 30 second...

Are there something wrong in my code?
Could I receive the possible 20 Ticks per second every 1 or 2 seconds?
The GAIN Trader Developer 4.0, it do.

Thanks a lot
Edited by CBarabucci on May 04, 2021 01:23 PM

API Support » Real Time capturing data May 03, 2021 @ 05:13 PM (Total replies: 7)

In the GAIN Trader Developer software, I set the contract of my interest NQM21
In Select period I chose: Tick
Indicator1: NQM21 History
Indicator2: Vol(NQM21) Volume
in the Data/ShowTable I can see the History and Volume, and with the right click a can save the archive in .csv file

I discovered that the LastPrice and the LastVol are not the same things of History and Volume, and my software working fine.
The problem is that I don't want LastPrice and LastVol, but I want closed price (History) and Volume.

Is it possible? How can I do this?

Thanks in advance to Jason and to anybody can help me
Edited by CBarabucci on May 03, 2021 05:26 PM

API Support » Real Time capturing data Mar 25, 2021 @ 08:17 AM (Total replies: 7)

Hi, I've developed a Real Time capturing data software.
After Connection, Symbol Lookup and Contract choose, I subscribe the PriceChanged Event:

Client.Subscriptions.Price.PriceChanged += OnPriceChanged;

and in the:

private void OnPriceChanged(IGFClient client, PriceChangedEventArgs e)
{
StringBuilder data = new StringBuilder(e.Price.LastDateTime.ToLocalTime().ToString(), 30);
data.Append(";");
data.Append(e.Contract.PriceToString(e.Price.LastPrice));
data.Append(";");
data.Append(e.Price.LastVol);

lista.Add(data.ToString());
}


I add in a list named lista, my interesting data.

The program working fine, the data are correct more or less, if I check the captured data from my software, with the downloaded data from the GAIN Trader archive, some few data are missing, wich other are duplicated.

Naturally I check the same values of the same contract in the same interval of time, and they correspond for about 90%.

Are there possible to capture real time data with api, without differences, with the Gain Trader archive?
Thanks for answer.

CB
Edited by CBarabucci on Mar 25, 2021 08:30 AM
Edited by CBarabucci on Mar 25, 2021 03:52 PM