Re: [amibroker] OLE Question

 


var AB = new ActiveXObject("Broker.Application");
var Stocks = AB.Stocks;
var Stock  = Stocks.Item ( "AAPL");
WScript.Echo ( "" + Stock.Quotations.Count );



On 2/5/2016 8:16 PM, 'Sean ONeill' oneillseanp@verizon.net [amibroker] wrote:
 

Hi Gents,

Happy Weekend.

Quick question regarding the best way, via OLE to get a specific "STOCK" object.  For example. Let's say I want to retrieve the Stock object for ticker AAPL  what is the fastest way to get it.  I could…

 

1.)     Loop over all stock objects in the current database like so…

 

var stockCount = stocks.Count;

 

For ( int i = 0; I < stockCount; i++)

{

   Var stock = stocks.item(i);

 

   If ( stock.Ticker == "AAPL" )

{

       //  Then I have it….do something with it.

 

}

}

 

 

2.)     Or is I use…

 

stock.Add("AAPL");

 

//  Then if already exists in the database (Stocks) , .Ass()  will  return that instance of APPL's stock object.  Problem is if it doesn't exist it will make one I believe.

 

So it would seem the fastest way to get APPL's stock object is to use the stock.Add() method, but I don't want to Add it to the database if it doesn't exist  !!

 

What should I do?  Is there an override so that it won't get added if it doesn't exist.

__._,_.___

Posted by: Aron Pipa <aron@myafl.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)

Check out the automatic photo album with 1 photo(s) from this topic.
Monthly m.a. on Daily.PNG

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv