Author |
Topic: example of implementation of subscribeticks in excel (6 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
SSylvia Posts: 3 Joined: Sep 09, 2009 |
Hi,
I have been trying to implement a subscribeticks with onticksreceived method in excel by looking at the examples of the DOM and quotes sheet in OEC's samplecom but so far haven't been able to work it out. Would someone have a working subscribeticks implementation they would be willing to share to get me unstuck please? Thank you Sylvia Sylvia Herbaut |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Hi,
could you please specify - what kind of trouble do you have? I can advise to use SubscribeBars as a sample, because it is very similar. |
||||
SSylvia Posts: 3 Joined: Sep 09, 2009 |
I tried many things but kept getting an "object required" error against the function I put in the initializing login function in the samplecom. just haven't been able to make it work yet and was hoping someone here may have a working example of either SubscribeBars or SubscribeTicks.
Otherwise I will go back and continue to read the API documentation and the sample code to try to work it out. :( It is just that I am both green with the API and with VBA so it is a bit of an uphill battle. :) Also is there further documentation that expands more on the implementation methods somewhere or is the documentation at http://www.openecry.com/api/api/index.html it? thank you! Sylvia Sylvia Herbaut |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
You need to implement the next things:
1. Subscribe to ticks: Set Subscription = api.SubscribeTicks(newContract, Now) 2. Hook the next events: OnTicksReceived(ByVal Subscription As OECAPICOM.ISubscription, ByVal IncomingTicks As OECAPICOM.ITicks) and OnPriceTick(ByVal Contract As OECAPICOM.IContract, ByVal Price As OECAPICOM.IPrice) 3. Process OnPriceTick: If Not (Subscription Is Nothing) And Subscription.Contract = Contract Then Range("A" & CountRows).value = Price.LastDateTime Range("B" & CountRows).value = Price.LastPrice Range("C" & CountRows).value = Price.LastVol CountRows = CountRows + 1 End If 4. Process OnTicksReceived For i = 0 To Ticks.PriceList.Length - 1 Dim Vol As Integer Dim Price As Double Price = Ticks.PriceList.Item(i) Vol = Ticks.VolumeList.Item(i) Range("A" & CountRows).value = Ticks.TimestampList.Item(i) Range("B" & CountRows).value = Price Range("C" & CountRows).value = Vol CountRows = CountRows + 1 Next 5. And cancel subscription, when you don't need it any more If Not (Subscription Is Nothing) Then api.CancelSubscription Subscription Set Subscription = Nothing End If This sample code will be available in the next build of OECAPICOM installation. Please let me know, if you have questions. |
||||
VictorV Posts: 746 Joined: May 08, 2007 |
Correction: you don't need to use OnPriceTick event, if you use tick subscription and OnTicksReceived event.
|
||||
SSylvia Posts: 3 Joined: Sep 09, 2009 |
thank you so much for sending the sample code, that has helped me tremendously. :)
Cheers Sylvia Edited by SSylvia on Oct 14, 2009 at 02:27:41 |
||||