It is currently May 8th, 2024, 10:09 am

Market Prices

RSS, ATOM and other feeds, GMail, Stocks, any information retrieved from the internet
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Market Prices

Post by Mordasius »

eclectic-tech wrote: January 23rd, 2024, 2:12 pmWhen debugging a Webparser measure I always set Debug=2 in the Webparser measure, refresh the skin once. This creates a WebparserDump.txt file in the same folder as the skin which is an exact copy of what the Webparser returns.
Nice one Eclectic-Tech I've never tried that method. What happens if you are downloading five or more pages from the same site as in the case with MarketPrices.ini and many news feed readers. Do you have to download the pages one by one and then rename the WebparserDump.txt file after each one?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Market Prices

Post by eclectic-tech »

Mordasius wrote: January 23rd, 2024, 2:37 pm Nice one Eclectic-Tech I've never tried that method. What happens if you are downloading five or more pages from the same site as in the case with MarketPrices.ini and many news feed readers. Do you have to download the pages one by one and then rename the WebparserDump.txt file after each one?
You have to look at each Webparser measure individually; each time the measure with Debug=2 on it updates, it will create an updated WebparserDump.txt file in the current skin folder and overwrite the previous file.

I can't envision troubleshooting multiple issues all at the same time... Fix one issue then move on to the next... :confused:
User avatar
Yincognito
Rainmeter Sage
Posts: 7207
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Market Prices

Post by Yincognito »

Mordasius wrote: January 23rd, 2024, 2:26 pm This is exactly what I and I expect most other people normally do when developing skins that rely Webparser measures. For this particular tweak to the MarketPrices.ini skin however, I was more concerned with getting the thousands coma and the decimal places right and this depends on the lua script rather than the price returned by the Webparser measures. Hence the use of quickly changeable variables rather than downloading stacks of pages from CNBC.com.
Yeah, I was just saying - I'm not normally obsessed like others by "good practices" when doing stuff, but in WebParser cases, it really is, until you get things right and overpolling isn't necessary anymore. After all, nobody wants to get his IP blocked or banned when building or using skins. No need to save a thousand versions of the page, I always managed to do my thing with around 3 of them, if they showcased various possibilities well enough. ;-)

By the way, you can use Debug=2 with a (potentially dynamic, if desired) DebugToFile to save with different names. If you're bothered by renaming the WebParserDump.txt that is, though I don't think two clicks on its name and an 1, 2, or 3 index added to it in a few separate cases is that annoying to do.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: Market Prices

Post by emp00 »

Mordasius wrote: January 23rd, 2024, 3:54 am [cIndex1_PriceCalc] was yielding a Calc Extra Operation error because the string value of [mIndex1_Price] was null until the WebParser had sucked the value from CNBC.com. I suspect that all you need to do is add DynamicVariables=1 so that value changes when [mIndex1_Price] does, comme ci

Code: Select all

[cIndex1_PriceCalc]
Measure=Calc
Formula=[mIndex1_Price]
DynamicVariables=1
I expect your suggestions to add Disabled=1 to [cIndex1_PriceCalc] and then add FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] to [mIndex1_Price] would have also worked but I didn't test it for the "IP Banned" reason above.
Option 1:
- DynamicVariables=1 does the job!
- I modified MetMeaTemplate.inc accordingly and now I get exactly what I wanted - THANK YOU!
- However, one caveat remains: With my 6 stocks watchlist now I still get 6 times Calc: Extra operation in the error log!
- Probably, this happens only once at initial startup before WebParser has not yet sucked the values from CNBC.com
- Still, I'd prefer a more clean solution avoiding such errors (even though they are only found in the log)

Option2:
- Therefore I gave it a shot adding Disabled=1 to [cIndex1_PriceCalc] and also FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] to [mIndex1_Price] as discussed above
- The DynamicVariables=1 trick from Option 1 I commented out and refreshed the skin ...
- Result: No more Calc: Extra operation errors in the log, so far so good but:
- Now all price displays are again 0.00 (as per my decimals settings) -> but unfortunately all price data = ZERO again !!
- I also tried enabling DynamicVariables=1 to either measures and also the meter [LabelPrice1] but this does not change the outcome, damnit ... :-(

The other webparser calls and displays are working fine, just the price is not shown anymore with Option 2. What's the remaining problem here?

I think I'm almost at the finish line! Here a snipped of my revision -> I removed two columns that I don't need and changed the colors (red makes me nervous, so negative values are yellow for me), added rounded corners and adjusted the font and general design to a maximum compact display. That's just how I need it - max information at min space, all visible with a blink of an eye. Sorry for removing the icon and skin name, my screen is too packed for that. Overall, great work and much appreciate your help, Mordasius!

Image
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Market Prices

Post by Mordasius »

emp00 wrote: January 23rd, 2024, 9:04 pm With my 6 stocks watchlist now I still get 6 times Calc: Extra operation in the error log!
I can't stand nasty niggling error messages in the log either.

So as Syd Barret wrote for The Piper at the Gates of Dawn "Let’s try it another way..."

1) In StockSymbols.inc

Code: Select all

Label-1="-"
Symbol1=.DJI
DecPlaces1=1

Label-2="-"
Symbol2=.FTSE
DecPlaces2=2

Label-3="-"
Symbol3=1CG-AU
DecPlaces3=3

etc. etc.
2) In MarketPrices.ini

Code: Select all

[mIndex1_Price]
Measure=WebParser
Url=[InfoIndex1]
StringIndex=2
;-- set the Decimal Places
RegExpSubstitute=1
Substitute="(.*\.\d{#DecPlaces1#})\d*":"\1" , "\.$":""
...

[LabelPrice1]
Meter=STRING
MeasureName=mIndex1_Price
MeterStyle= sTextRight | sColorSetGray
x=#Col2XPos#
3) In MetMeaTemplate.inc

Code: Select all

[mIndex^1^_Price]
Measure=WebParser
Url=[InfoIndex^1^]
StringIndex=2
;-- set the Decimal Places
RegExpSubstitute=1
Substitute="(.*\.\d{#DecPlaces^1^#})\d*":"\1" , "\.$":""
...

[LabelPrice_^1^]
Meter=STRING
MeasureName=mIndex^1^_Price
MeterStyle= sTextRight | sColorSetGray
x=#Col2XPos#
Much simpler and no more error messages. However, the Substitute will not round the price up correctly as the lua script did.

"...Free games for May, See Emily play"
User avatar
SilverAzide
Rainmeter Sage
Posts: 2618
Joined: March 23rd, 2015, 5:26 pm

Re: Market Prices

Post by SilverAzide »

"Arnold Layne had a strange hobby..."
Gadgets Wiki GitHub More Gadgets...
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Market Prices

Post by Mordasius »

SilverAzide wrote: January 24th, 2024, 12:48 pm "Arnold Layne had a strange hobby..."
Arnold Layne wrote: January 23rd, 2024, 3:54 amTo avoid getting blocked I used a dummy skin with [mIndex1_Price] defined as a string measure using String=#PriceString1#. This is what caused the problems you were having.

"Oh, Arnold Layne
It's not the same
Takes two to know
Two to know
Two to know
Why can't you see?
Arnold Layne
Arnold Layne, don't do it again
..."
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: Market Prices

Post by emp00 »

Mordasius wrote: January 24th, 2024, 6:57 am So as Syd Barret wrote for The Piper at the Gates of Dawn "Let’s try it another way..."
[...]
Much simpler and no more error messages. However, the Substitute will not round the price up correctly as the lua script did.
Understood, but sorry - not acceptable for financials - rounding is mandatory for me. Target is omitting decimals for saving space and relaxing the eyes but they should be rounded correctly...

I also tried using Text=[mIndex1_Price:/1,#DecPlaces1#] this is also very simple and works fine for most prices. But this does NOT work for prices with thousand separator commas such as 41,234 ... Argh, I seem to always run against some wall :-(

Click here --> Option 2 using your lua-rounding-script would be my preferred solution. I tried my best to fix the remaining error, but keeps displaying "ZERO" all the time. I documented what I suspect being the reason behind and what I tried to fix it - I'm sure I made some stupid mistake. Help appreciated.

:confused:
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Market Prices

Post by Mordasius »

emp00 wrote: January 23rd, 2024, 9:04 pm Option2:
- Therefore I gave it a shot adding Disabled=1 to [cIndex1_PriceCalc] and also FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] to [mIndex1_Price] ... Result: No more Calc: Extra operation errors in the log, so far so good but: - Now all price displays are again 0.00
i'm sorry I didn't read your Option2 closely enough. I thought that the Disabled=1 and FinishAction=[!Enablemeasure.. combination would work because I've used it before and was surprised when you reported the price displays were all 0.00. You were actually very, very close.

You just need to put [FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] in the parent measure which is [InfoIndex1] rather than [mIndex1_Price].

Reason is that [InfoIndex1] is the measure that scrapes the page on CNBC.com not [mIndex1_Price] which simply gets the price string from [InfoIndex1]

Make the appropriate changes to MarketPrices.ini and MetMeaTemplate.inc, change the number of stocks, refresh the skin, change the number of stocks back again, wait five minutes then refresh again and you should be good to go.

P.S. Leave DynamicVariables=1 in [cIndex1_PriceCalc]
emp00
Posts: 83
Joined: October 7th, 2022, 8:08 pm

Re: Market Prices

Post by emp00 »

Mordasius wrote: January 25th, 2024, 7:05 am You just need to put [FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] in the parent measure which is [InfoIndex1] rather than [mIndex1_Price].
[...]
Yes - Yes - Yes :-)
This did it! Argh, I could have seen this myself, of course it needs to go to the initial WebParser measure: No more Calc: Extra operation errors. Price rounding working perfectly with your lua script and thousand separators is remaining. User can adjust number of digits separately per stock meter. Complete success! THANK you Mordasius!

I added another small feature, marking [LabelPrice1] as Hidden=1 and also enabling the meter only after the WebParser has received the data: FinishAction=[!Enablemeasure "cIndex1_PriceCalc"] [!ShowMeter LabelPrice1]

Shall I share my complete, modified revision with you, so that you can upgrade your official skin distribution package with this cool new feature? Unfortunately, I have deleted two columns, deleted the menu bar and changed font/corners/design details, see screenshots above. Furthermore I made quite some code comments/code rework for better readability and switched a few variables between Skinvars.inc / Stockvars.inc and MarketPrices.ini to my "consistency likings". But this is personal preference and this is why I love Rainmeter --> full adjustability of gadgets down to the pixel. Not possible with any out-of-the-box Windows gadgets.

I saw a few more details in the script, such as using "Group=2" in a few measures but no Group bangs being used and I also still plan to add error management with OnConnectErrorAction displaying an error message in case the WebParser download fails. These are things currently in my head... But it's your meter Mordasius, I am thankful for providing this to the community.

:rosegift: