Imacros for reading stock prices

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
nldeshpande
Posts: 5
Joined: Sat Jul 08, 2017 4:27 am

Imacros for reading stock prices

Post by nldeshpande » Sat Jul 08, 2017 12:56 pm

Hello,

I am wondering whether imacros can be used to read live streaming prices from a webpage (e.g kite.zerodha.com)

If it is possible, I am planning to create a alerting system when a predetermined price appears on the screen.

Any help in these regards appreciated.

Thanks
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Sat Jul 08, 2017 1:32 pm

nldeshpande wrote:Hello,

I am wondering whether imacros can be used to read live streaming prices from a webpage (e.g kite.zerodha.com)

If it is possible, I am planning to create a alerting system when a predetermined price appears on the screen.

Any help in these regards appreciated.

Thanks
Yep of course it can be done with iMacros...! Everything you "do" or "see" in your Browser with HTML Pages being displayed can be automated with iMacros... 8)

"Any help" is vague...! What is your Problem...?, we can help you if you get stuck somewhere but you need to create your Script yourself...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nldeshpande
Posts: 5
Joined: Sat Jul 08, 2017 4:27 am

Re: Imacros for reading stock prices

Post by nldeshpande » Sat Jul 08, 2017 1:54 pm

Well, here is the problem.

The webpage of kite.zerodha.com is designed in such a way that the prices are visible to the human eye. But once you get your mouse over the price, it turns into a action bar with buy sell and a few other buttons. The text of the price is actually not selectable, and hence i am unable to record a macro to read the prices. And since I am not able to record the macro, i am also unable to get the script and edit it.

However, I am able to record a macro of placing a order with clicking the Buy button that appears on the mouseover of the price. But I want imacros to read the price before deciding to click the button.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Sat Jul 08, 2017 2:31 pm

nldeshpande wrote:Well, here is the problem.

The webpage of kite.zerodha.com is designed in such a way that the prices are visible to the human eye. But once you get your mouse over the price, it turns into a action bar with buy sell and a few other buttons. The text of the price is actually not selectable, and hence i am unable to record a macro to read the prices. And since I am not able to record the macro, i am also unable to get the script and edit it.

However, I am able to record a macro of placing a order with clicking the Buy button that appears on the mouseover of the price. But I want imacros to read the price before deciding to click the button.
Oh...!, but if "... and hence i am unable to record a macro to read the prices." and "... However, I am able to record a macro...", then we start by the "Beginning" for me to follow up...!:
=> CIM...! :mrgreen: (Read my Sig...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nldeshpande
Posts: 5
Joined: Sat Jul 08, 2017 4:27 am

Re: Imacros for reading stock prices

Post by nldeshpande » Sat Jul 08, 2017 2:39 pm

IMacros : VERSION BUILD=9030808 RECORDER=FX

Browser : Firefox 54.0.1 (32-bit)

OS : Windows 7
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Sat Jul 08, 2017 3:57 pm

nldeshpande wrote:

Code: Select all

IMacros : VERSION BUILD=9030808 RECORDER=FX

Browser : Firefox 54.0.1 (32-bit)

OS : Windows 7
OK, good, now we can talk... Always include your FCI when you open a Thread (or post for the first time in some existing Thread), many Commands are not implemented for all Browsers/Versions and I usually don't even read when this Info is not mentioned... :idea:

v9.0.3 for FF is btw a bit buggy and limited compared to v8.9.7 for FF which is still "the" stable and recommended Version for FF... (And it still works on FF54.)

I can't access your Site to have a look by myself as it is behind Login&Password, but hum..., yeah..., "... the prices are visible to the human eye..." and "... The text of the price is actually not selectable...", if that Field/Data is visible on the Page, then it must be "somewhere" in the HTML Source of the Page, either directly "hard-coded" in the HTML Source or computed from some embedded or external (JavaScript) Scrip and iMacros can "see" it...
But tja.., I can only give you some "generic" Advice as I cannot play with the Page itself...
=> Things you can try:
1- Locate that Data in the Source Code and extract ('=TXT' or '=HTM') some (Higher Level maybe) Element containing it and then use 'EVAL()' to "isolate" it from your Extract.

2- Try using Relative Positioning with as Anchor some Field located as close as possible before or after it and then use 'POS=R{{!LOOP}}' on 'TYPE=*' to try to find such Element(s) containing your Price.

3- If the 'TAG' Mode really doesn't work, try using the 'EVENT' Mode with or without ID's, to access it. Without ID's, you should always be able to manage to access it, but you may have to try quite a few different "Combinations" with 'nth-of-xx' at each Level of Nested Elements, so the Nb of Combinations quickly increases arithmetically... And you should then be able to select your Price with a Double Click or Keyboard Actions.

4- Try to identify the JavaScript (external...?) Script triggering the Action Bar upon a MouseOver and to "temporarily" block it, using 'ABP/ABE/uBlock' for example or by manually saving your Page as 'HTML' or 'Full HTML', but hum 'HTML Only' might be better as you will get rid of the Script if it is external, and by editing the Source of the Page if it is internal/embedded, and maybe trying this Operation on a PC which is Offline. Once the Action Bar is not triggered anymore, iMacros in 'TAG' Mode should be able to record "stg" when tagging your Price. But hum, this Method might be a bit cumbersome in your case, compared to Methods '1' and '2' which should be more straightforward for the same Result, I would think...

5- The Price Info is maybe/probably contained or referred to as well in the HTML of the Action Bar.

Well, that should keep you busy for a while already, ah-ah...! :wink:
If you don't come out by yourself, you can upload an 'HTML Saveas' (from the Browser) to your Thread (zipped, max 256Kb) and I could have a look at it...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Mon Jul 10, 2017 8:06 pm

And...?, any Update on this Thread...? :?:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nldeshpande
Posts: 5
Joined: Sat Jul 08, 2017 4:27 am

Re: Imacros for reading stock prices

Post by nldeshpande » Tue Jul 11, 2017 10:16 am

Hello,

As per your guidance, i dug deep into the scripts that displayed the data on the webpage.

Now here are the steps I need to take

1) Read text within the "<div class="row instrument-data">" and identify whether the text matches to my requirement.

if yes then,

2) Read the text within the nested "<div class="price-block text-right">" and select and store that text in a variable

if not then repeat step 1 and 2 till the text matches.

I have to repeat the cycle every 30 seconds as the prices keep changing and I have to note the prices and take action when a certain price point appears. The subsequent actions, I have already recorded in imacros.

I need help so as to acheive the above 2 steps.

Thanks
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Tue Jul 11, 2017 2:56 pm

nldeshpande wrote:Hello,

As per your guidance, i dug deep into the scripts that displayed the data on the webpage.

Now here are the steps I need to take

1) Read text within the "<div class="row instrument-data">" and identify whether the text matches to my requirement.

if yes then,

2) Read the text within the nested "<div class="price-block text-right">" and select and store that text in a variable

if not then repeat step 1 and 2 till the text matches.

I have to repeat the cycle every 30 seconds as the prices keep changing and I have to note the prices and take action when a certain price point appears. The subsequent actions, I have already recorded in imacros.

I need help so as to acheive the above 2 steps.

Thanks
Ah OK, then it means that the 1st Option I had mentioned in my previous Reply is working... Good, as it is the easiest...

Well, a "typical" TAG/EXTRACT on a 'DIV' Element with a "<div class="row instrument-data">" Attribute would be:

Code: Select all

TAG POS=1 TYPE=DIV ATTR=CLASS:"row instrument-data" EXTRACT=TXT
Depending on what you get in the 'EXTRACT', you may have to try with 'EXTRACT=HTM' instead...
And you may have to adapt the 'POS=1' to 'POS=2/3/4...' if there are several Elements on the Page with the same Class until you find the one you want... Or using Relative Positioning is a good Technique to try to keep the 'POS' Nb as low as possible...

... And then like I said, isolate the Data you want to keep with 'EVAL()'... Well..., unless you already get it "clean" from the 'EXTRACT=TXT'...

Once you do the Compare, with 'EVAL()' again, you could then spit out a "1"/"0" to reuse on the conditional next Step for 'POS=n', "POS=0" won't do anything...! (with '!ERRORIGNORE' activated..., and a low Value for '!TIMEOUT_STEP'...)

But hum, depending on what your "Input" is for your Script to take a Decision, maybe that whole conditional "Process" can be done with a simple Relative Positioning... :idea:
Have a look at the following Thread where I explained a bit all those Methods...: :idea:
- Workarounds for Conditional Logic in Macro Code
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nldeshpande
Posts: 5
Joined: Sat Jul 08, 2017 4:27 am

Re: Imacros for reading stock prices

Post by nldeshpande » Wed Jul 12, 2017 1:45 am

Hi,

Thank you so much. Your suggestions have been very helpful and I have now written the following script

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=4 TYPE=DIV ATTR=CLASS:"symbol ng-binding"
TAG POS=4 TYPE=SPAN ATTR=CLASS:"price" EXTRACT=TXT
PROMPT {{!EXTRACT}}

and it is doing its job.

Now further I will be looping this script in a timer, and when the price match appears i will be running the "action" macro.

I guess that these tasks are within my reach. If I come across any roadblocks, I will post them here.

Thank you once again.

Nilesh Deshpande
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Imacros for reading stock prices

Post by chivracq » Wed Jul 12, 2017 3:41 am

nldeshpande wrote:Hi,

Thank you so much. Your suggestions have been very helpful and I have now written the following script

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
TAG POS=4 TYPE=DIV ATTR=CLASS:"symbol ng-binding"
TAG POS=4 TYPE=SPAN ATTR=CLASS:"price" EXTRACT=TXT
PROMPT {{!EXTRACT}}
and it is doing its job.

Now further I will be looping this script in a timer, and when the price match appears i will be running the "action" macro.

I guess that these tasks are within my reach. If I come across any roadblocks, I will post them here.

Thank you once again.

Nilesh Deshpande
Okaaayy, I don't see any a bit "difficult" Technique in your Script, it just looks completely straightforward, no Difficulty at all, not sure why you needed the Forum to be honest... :? (Oh yeah, to identify some Element containing your Data, Okay..., yep... Hum, but still, nothing very complicated... OK, I'm a bit puzzled, ah-ah...!)
But Thanks for the Update of course... :D
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply