API Support Forum
OEC API > API Support > Historical Data
Author Topic: Historical Data
(32 messages, Page 2 of 2)
Moderators: VPfau
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 01, 2011 @ 07:58 AM             Msg. 2 of 32
Beginning of the downloaded range
1332,75 30.05.2011 9:16:56

The end of the downloaded range
1341,5 31.05.2011 7:54:47
(2 packages of 4096 tics)

Current price and time
1341,25 31.05.2011 16:42:00

Function of subscription:
api.SubscribeTicks api.Contracts.Item("ESM1"), Datetime.time

Value of Datetime.time =
31.05.2011 08:42:00 EDT (or 16:42:00, 31.05.2011 Russia)

Procedure in the module "OECClass"

Private Sub c_OnTicksReceived(ByVal Subscription As OECAPICOM.ISubscription, ByVal Ticks As OECAPICOM.ITicks)
If Ticks.PriceList.Length > 0 Then

MsgBox count_y

For y = 1 To Ticks.PriceList.Length - 10
count_y = count_y + 1
Sheet4.Cells(count_y, 5).value = Ticks.PriceList.Item(y)
Sheet4.Cells(count_y, 6).value = Ticks.TimestampList.Item(y)

Next y

Alexander Barbarash
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 01, 2011 @ 08:29 AM             Msg. 4 of 32
Could you please make sure that you use UTC in StartDate parameter?

Victor Vins
Software Developer
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 06, 2011 @ 11:04 AM             Msg. 6 of 32
I used value of time in all possible formats. Including UTC.
I tried to enter different values of time in StartDate parameter, from current to two-day remoteness.
As a result in any type of inquiries (database query) it is downloading about 8000 tics, as before... But tics in last 1-2 hours do not loading at all.
?ould You please try to check up this function work, may be I do something wrong or this function works not correctly.
Send please the real sample of a code for historical data reception for last 10 seconds.

Alexander Barbarash
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 07, 2011 @ 09:35 AM             Msg. 8 of 32
void SubscribeTickChart(Contract contract)
{
WriteLine("SubscribeTickChart: {0}", contract);
client.SubscribeTicks(contract, DateTime.UtcNow.AddSeconds(-10));
}

void client_OnTicksReceived(Subscription Subscription, Ticks Ticks)
{
if (Ticks.Timestamps.Length > 0)
{
WriteLine("TICKS {0}, {3:s}: {1:s} - {2:s} ({4} ticks)",
Subscription.Contract,
Ticks.Timestamps[0],
Ticks.Timestamps[Ticks.Timestamps.Length-1],
DateTime.UtcNow,
Ticks.Timestamps.Length);
}
}

Results:
TICKS ESM1, 2011-06-07T13:33:51: 2011-06-07T13:33:41 - 2011-06-07T13:33:50
(327 ticks)
As you can see this functionality is working correctly.

Victor Vins
Software Developer
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 08, 2011 @ 11:54 AM             Msg. 10 of 32
VBA eject an error for such code:
api.SubscribeTicks api.Contracts.Item("ESM1"), DateTime.UtcNow.AddSeconds(-10)
compile error: "Method or data member not found"
It is about "UtcNow"

Besides that, VBA does not define element WriteLine.

{
WriteLine("TICKS {0}, {3:s}: {1:s} - {2:s} ({4} ticks)",
Subscription.Contract,
Ticks.Timestamps[0],
Ticks.Timestamps[Ticks.Timestamps.Length-1],
DateTime.UtcNow,
Ticks.Timestamps.Length);
}

Could you please send me a code written for VBA 6.5?

Alexander Barbarash
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 08, 2011 @ 11:59 AM             Msg. 12 of 32
You can replace DateTime.UtcNow to something similar in VB that will return the current UTC time and WriteLine to Print (or something like that)

Victor Vins
Software Developer
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 14, 2011 @ 10:52 AM             Msg. 14 of 32
Thank you very much for your help & time. I appreciate it.

Now I can receive the information about each finished transaction.

Is it possible to receive values of the price only after its change i.e. that there were no repeating of the same value.

Alexander Barbarash
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 14, 2011 @ 02:07 PM             Msg. 16 of 32
Alexander, we send a quote update if any value in the quote was changed. For example, Total Volume has been changed, but Last Price is still the same.

Victor Vins
Lead Software Developer
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 15, 2011 @ 12:50 PM             Msg. 18 of 32
Ok, I will cope with it

There is other problem.
I need to download tics for 5-10 contracts simultaneously.
But at subscription only to the third contract this error stands out:
"Run-time error '-2147467261(80004003)'. Automation error"
What should I do?

Alexander Barbarash
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 16, 2011 @ 10:12 AM             Msg. 20 of 32
Ok, I will cope with it

There is other problem.
I need to download tics for 5-10 contracts simultaneously.
But at subscription only to the third contract this error stands out:
"Run-time error '-2147467261(80004003)'. Automation error"
What should I do?

Alexander Barbarash
AAlexander39
Posts: 18
Joined: Dec 17, 2010


Posted: Jun 17, 2011 @ 12:45 PM             Msg. 22 of 32
Victor, where are you?

Alexander Barbarash
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 20, 2011 @ 11:35 AM             Msg. 24 of 32
You can subscribe as much tick subscriptions as it is configured for you by customer service.

Error message: could you please send me a sample code to reproduce it?

Victor Vins
Lead Software Developer