I don't think this skin has anything to do with the staying topmost issue you're having. Changing its state from the right click context menu > Settings > Position works as expected for me for the DeviantArt link indicated in the initial post. You might want to unload any other skin you're having, restart Rainmeter, and see if the problem persists. My guess is that it's some other skin that is potentially causing this (I'm talking about changing its state from the context menu, to keep it simple)...
It is currently September 19th, 2024, 4:29 pm
Market Prices
-
- Rainmeter Sage
- Posts: 8179
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Market Prices
-
- Posts: 34
- Joined: April 8th, 2015, 1:27 pm
Re: Market Prices
Cheers,
MARK
MARK
-
- Posts: 1178
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Market Prices
Sorry my "Nope" reply was a little curt but it was late at night and I couldn't replicate the problem or think of any solution. Hopefully the other guys will have sorted you out.
Cheers and may your market prices be trending ever upwards.
-
- Posts: 117
- Joined: October 7th, 2022, 8:08 pm
Re: Market Prices
Hello Guys, I need a little hint for the "Market Prices" skin:
I would like to display the prices with only one decimal instead of two. See Screeshot - I would like to remove the red-marked digits. Obviously the below LabelPriceX meters need to be modified. Can you help me please? Many thanks!
Actually, for me it would be perfect if the the skin would automatically even do this smart move:
- If price is <10 display two digits
- if price is (>=10 AND <1000) display one digit
- if price is >=1000 display no digits at all
Reason behind: I have very different values in my stocks, some only at few dollars and on the other hand BTC with XX,XXX.XX dollars. I want to optimize space consumption and relax my eyes with this. Should be possible... But how?
I would like to display the prices with only one decimal instead of two. See Screeshot - I would like to remove the red-marked digits. Obviously the below LabelPriceX meters need to be modified. Can you help me please? Many thanks!
Actually, for me it would be perfect if the the skin would automatically even do this smart move:
- If price is <10 display two digits
- if price is (>=10 AND <1000) display one digit
- if price is >=1000 display no digits at all
Reason behind: I have very different values in my stocks, some only at few dollars and on the other hand BTC with XX,XXX.XX dollars. I want to optimize space consumption and relax my eyes with this. Should be possible... But how?
Code: Select all
[LabelPrice1]
Meter=STRING
MeasureName=mIndex1_Price
MeterStyle= sTextRight | sColorSetGray
x=#Col2XPos#
-
- Posts: 1178
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Market Prices
Apologies for the tardy reply. Here is one way to show variable numbers of decimal places for the prices.
I'll just show you how to do it for the first index or stock and you can make the chamges for your other stocks.
1) Firstly add the number of decimal places you want in the [Variables] section of MarketPrices.ini.
Code: Select all
[Variables]
DecPlaces1=2
Code: Select all
[FormatPriceScript]
Measure=Script
ScriptFile=FormatPrice.lua
UpdateDivider=-1
Code: Select all
[mIndex1_Price]
Measure=WebParser
Url=[InfoIndex1]
StringIndex=2
;;>>-- add this line to take comas out of the price string
Substitute=",":""
Code: Select all
[cIndex1_PriceCalc]
Measure=Calc
Formula=[mIndex1_Price]*1
Code: Select all
[LabelPrice1]
Meter=STRING
MeterStyle= sTextRight | sColorSetGray
x=#Col2XPos#
Text=[&FormatPriceScript:format_price( [&cIndex1_PriceCalc] , #DecPlaces1# )]
Code: Select all
-- FormatPrice.lua
-- adapted from http://lua-users.org/wiki/FormattingNumbers
-- add commas to separate thousands
function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
-- round number to nearest decimal places
function round(val, decPlaces)
if (decPlaces) then
return math.floor( (val * 10^decPlaces) + 0.5) / (10^decPlaces)
else
return math.floor(val+0.5)
end
end
-- -----------------------------------------------------------
-- format_price formats output with comma to separate thousands
-- and rounded to given decimal places
function format_price(amount, decPlaces )
local str_amount, formatted, famount, remain
decPlaces = decPlaces or 2 -- default 2 decPlaces places
famount = math.abs(round(amount,decPlaces))
famount = math.floor(famount)
remain = round(math.abs(amount) - famount, decPlaces)
-- add commas to separate the thousands
formatted = comma_value(famount)
-- attach the decimal places portion
if (decPlaces > 0) then
remain = string.sub(tostring(remain),3)
formatted = formatted .. "." .. remain ..
string.rep("0", decPlaces - string.len(remain))
end
return formatted
end
Post a screenshot when you've made the above changes for all your stocks and I'll decide whether or not to incorporate the changes into the DA version of MarketPrices.
-
- Posts: 117
- Joined: October 7th, 2022, 8:08 pm
Re: Market Prices
Hello Mordasius - your help is much appreciated!
I love your approach to add new variables DecPlacesX so that we can set individual decimals per stock! Proposal: This fits perfectly into Stocksymbols.inc like this (better than putting it into MarketPrices.ini I think):
However, I followed your instructions line by line (even not yet putting DecPlacesX in Stocksymbols.inc, which works just the same) and I have to report it does not work. I even reverted back to your original script Market_Prices_by_mordasius_dchxbyy.rmskin just to confirm it's not caused by other modifications I made. But the error persists: I think the error is caused by the Substitute=",":"" in [mIndex1_Price]. This seems to return "0" all the time! However, I also found Calc: Extra operation as error in the Log, so the Calc measure is the issue?! Fixing this is currently above my head... Thanks for looking into this!
More improvements you probably already considered:
1) For consistency put FormatPrice.lua into the @Resources subfolder and call the script with ScriptFile=#@#FormatPrice.lua
2) For the other meters after [LabelPrice1] surely we need to modify MetMeaTemplate.inc at [LabelPrice_^1^] , correct? I think I will manage doing that, once the decimal trick above works!
3) Stupid question: Does the FormatPrice lua script keep the thousands separator commas? E.g. 12,345.67 should not be displayed as 12346 (assuming 0 digits are set) but rather as 12,346 ... Can the script do that?
Substitute-PROBLEM - see these screenshots before & after below:
Looking for the Calc Extra operation error, I found this hint - I have a feeling this is the way to go, but I may be completely wrong:
You could also have the calc measure disabled then use finishaction on webparser to enable it. This is the way to handle webparsers
I love your approach to add new variables DecPlacesX so that we can set individual decimals per stock! Proposal: This fits perfectly into Stocksymbols.inc like this (better than putting it into MarketPrices.ini I think):
Code: Select all
Label-1="-"
Symbol1=.DJI
DecPlaces1=2
Label-2="-"
Symbol2=.FTSE
DecPlaces2=0
Label-3="-"
Symbol3=.SPX
DecPlaces3=1
...
More improvements you probably already considered:
1) For consistency put FormatPrice.lua into the @Resources subfolder and call the script with ScriptFile=#@#FormatPrice.lua
2) For the other meters after [LabelPrice1] surely we need to modify MetMeaTemplate.inc at [LabelPrice_^1^] , correct? I think I will manage doing that, once the decimal trick above works!
3) Stupid question: Does the FormatPrice lua script keep the thousands separator commas? E.g. 12,345.67 should not be displayed as 12346 (assuming 0 digits are set) but rather as 12,346 ... Can the script do that?
Substitute-PROBLEM - see these screenshots before & after below:
Looking for the Calc Extra operation error, I found this hint - I have a feeling this is the way to go, but I may be completely wrong:
You could also have the calc measure disabled then use finishaction on webparser to enable it. This is the way to handle webparsers
-
- Posts: 1178
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Market Prices
Sorry it didn't work out. I must admit I didn't test the above solution in MarketPrices.ini as I've had my IP banned in the past when repeatedly making quick changes and then refreshing the skin. To 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.
[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
As to your other points:
1) I completely agree with your suggestions to add the DecPlacesXX variables to Stocksymbols.inc and put FormatPrice.lua in the @Resources subfolder. I didn't do this because I wasn't testing the solution using MarketPrices.ini.
2) Yes you will need to modify the measure [LabelPrice_^1^] in MetMeaTemplate.inc once the fix is working. You will also need to modify the [LabelPrice_^1^] meter in MetMeaTemplate.inc.
3) Yup, the FormatPrice.lua script will keep the thousands separator commas no matter what you set as the number of decimal places. You can even display a less precise price by using a negative number of Decimal Places.
-
- Rainmeter Sage
- Posts: 8179
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Market Prices
This should be written somewhere in a sticky topic or in the docs: when testing or developing such skins, a few local saves in the @Resources folder of the retrieved page in different circumstances and using them with the file:// URI scheme in the URL option is trivial to do and avoids any IP blocking or banning whatsoever since you can poll the local file at any frequency without any drawbacks.
You could then easily revert to the online version when the testing or development phase is done and you need to check a few times if it works as expected in the "real world". The whole approach is just a matter of a few edits or commenting the code as needed and has only benefits for both the skin designer and the users afterwards.
-
- Rainmeter Sage
- Posts: 5527
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: Market Prices
Debug is your friend when troubleshooting Webparser issues and will avoid getting banned for excessive site visits.
When 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.
Then remove or comment out Debug=2 and change the URL value to URL=File://WebparserDump.txt.
Now you can make changes and refresh as often as needed without any chance of being banned due to reading the site over and over.
Note that you can also see StringIndex values in the Rainmeter log by using Debug=1 and setting Rainmeter in Debug mode.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Posts: 1178
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Market Prices
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.Yincognito wrote: ↑January 23rd, 2024, 1:11 pm when testing or developing such skins, a few local saves in the @Resources folder of the retrieved page in different circumstances and using them with the file:// URI scheme in the URL option is trivial to do and avoids any IP blocking or banning
Last time I got my IP Banned was when I was developing CogsMoonSun.ini skin. I was tinkering around with something or another and had completely forgotten that whenever the skin was refreshed it checked with TimeAndDate.com to be sure that the correct time zone and DST was being used for the location being displayed. I apologised profusely and they unbanned after three days by which time I had already switched to Weather.com to get the correct UTC/GMT offset for wherever the info is being displayed for.