It is currently March 28th, 2024, 8:33 pm

Coinmarketcap Ticker with Bangs (Solved)

Get help with creating, editing & fixing problems with skins
Florin1991
Posts: 1
Joined: January 20th, 2018, 11:10 am

Coinmarketcap Ticker with Bangs (Solved)

Post by Florin1991 »

Hi, I am lost in Rainmeter manual. I can do a simple ticker with WebParse for prices of coins but, if I want prices for more coins, with UpdateRate all readings are made all at once and that is more than the limit of 10 requests per minute required from Coinmarketcap. I want to do readings one by one, one at 10 seconds, for example:

Coin1=bitcoin
Coin2=ethereum
...
Coin20=verge

Update=-1

for i=1,20 do
wait 10 sec
measure PriceCoin'..i..' ;Ex: Webparse URL=https://api.coinmarketcap.com/v1/ticker/coin'..i..' for RegExp=(?siU)"price_usd": "(.*)",.*
meter PriceCoin'..i..'
wait 10 sec
measure ChangeCoin'..i..' ;Ex: Webparse URL=https://api.coinmarketcap.com/v1/ticker/coin'..i..' for RegExp=(?siU)"percent_change_24h": "(.*)",.*
meter ChangeCoin'..i..'
end

repeat

Can anyone help me with this small code?



.........................................................................................................................................................
(Update)

Ok, let's say that I made this ticker (prices for 3 Coins on BitStamp.net site):

Code: Select all

[Rainmeter]
Update=10000
AccurateText=1
AntiAlias=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,128
BackgroundMargins=0,0,5,5

[Metadata]
Name=Test

[Variables]
Coins=3
c1=BitCoin
c2=Ethereum
c3=LiteCoin
a1=https://www.bitstamp.net/api/v2/ticker/btcusd
a2=https://www.bitstamp.net/api/v2/ticker/ethusd
a3=https://www.bitstamp.net/api/v2/ticker/ltcusd
reg=(?siU)"last": "(.*)".*
xc=5
xp=130

;..............................................CP
[Mc]
Meter=String
StringAlign=Left
X=#xc#
Y=5r
FontSize=12
AntiAlias=1
FontColor=255,255,0,255
SolidColor=0,0,0,1
Text=Coin

[Mp]
Meter=String
StringAlign=Right
X=#xp#
Y=r
FontSize=12
AntiAlias=1
FontColor=255,255,0,255
SolidColor=0,0,0,1
Text=Price

;..............................................C1
[Mc1]
Meter=String
StringAlign=Left
X=#xc#
Y=20r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=#c1#

[p1]
Measure=Plugin
Plugin=WebParser
URL=#a1#
RegExp=#reg#
UpdateRate=600
StringIndex=1

[Mp1]
Meter=String
StringAlign=Right
MeasureName=p1
X=#xp#
Y=r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=%1

;..............................................C2
[Mc2]
Meter=String
StringAlign=Left
X=#xc#
Y=15r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=#c2#

[p2]
Measure=Plugin
Plugin=WebParser
URL=#a2#
RegExp=#reg#
UpdateRate=600
StringIndex=1

[Mp2]
Meter=String
StringAlign=Right
MeasureName=p2
X=#xp#
Y=r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=%1

;..............................................C3
[Mc3]
Meter=String
StringAlign=Left
X=#xc#
Y=15r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=#c3#

[p3]
Measure=Plugin
Plugin=WebParser
URL=#a3#
RegExp=#reg#
UpdateRate=600
StringIndex=1

[Mp3]
Meter=String
StringAlign=Right
MeasureName=p3
X=#xp#
Y=r
FontSize=10
AntiAlias=1
FontColor=255,255,255,255
SolidColor=0,0,0,1
Text=%1

; When skin is loaded, all the prices of coins are read from the site all at once and metered, then,
; every once at 10 sec (Update=10000), skin updates, and prices of coins updates too all at once (UpdateRate=600).
; I wanna use UpdateRate=-1, so skin updates every 10 sec, but prices don't update anymore, except with Bangs.
; I made a counter to update price of 1 coin every 10 sec:

Code: Select all

Measure=Calc
Formula=i%#Coins#+1
; So, when skin is loaded, i=1. After 10 sec, skin updates and i=2, after 10 sec skin updates and i=3,
; after 10 sec skin updates and i resets to i=1 (number of Coins=3), and so on...
; I dont know how to use Bangs to command the UpdateMeasure of the readings from the site:
; I think it is something like that:

Code: Select all

[A]
 Measure=String
;MeasureName=i
;DynamicVariables=1
u=[!EnableMeasure p[i]][!CommandMeasure p[i] Update][!UpdateMeasure p[i]][!UpdateMeter Mp[i]][!DisableMeasure p[i]]
Can anyone help me?



.........................................................................................................................................................
(Update2)

I tried to use IfActions but coin prices are not updating, even if values of i1, i2 and i3 are cycling 1 to 3 every 10 sec.
(I did not use [!Redraw] because Update=10000 so skin redraw every cycle of 10 sec with (I hope) the updated prices.)

Code: Select all

; ;............................................Loop
; [i]
; Measure=Calc
; Formula=i%#Coins#+1

; [i1]
; Measure=Calc
; Formula=i
; IfEqualValue=1
; IfEqualAction=[!UpdateMeasure p1][!UpdateMeter Mp1]

; [i2]
; Measure=Calc
; Formula=i
; IfEqualValue=2
; IfEqualAction=[!UpdateMeasure p2][!UpdateMeter Mp2]

; [i3]
; Measure=Calc
; Formula=i
; IfEqualValue=3
; IfEqualAction=[!UpdateMeasure p3][!UpdateMeter Mp3]

Any thoughts?



.........................................................................................................................................................
(Update3)

I figured out:

Code: Select all

;............................................Loop
[i]
Measure=Calc
Formula=i%#Coins#+1

[i1]
Measure=Calc
Formula=i
IfEqualValue=1
IfEqualAction=[!SetOption p1 UpdateRate 0][!UpdateMeasure p1][!SetOption p1 UpdateRate 600][!UpdateMeter Mp1]

[i2]
Measure=Calc
Formula=i
IfEqualValue=2
IfEqualAction=[!SetOption p2 UpdateRate 0][!UpdateMeasure p2][!SetOption p2 UpdateRate 600][!UpdateMeter Mp2]

[i3]
Measure=Calc
Formula=i
IfEqualValue=3
IfEqualAction=[!SetOption p3 UpdateRate 0][!UpdateMeasure p3][!SetOption p3 UpdateRate 600][!UpdateMeter Mp3]

Skin works. Every 10 sec one coin price is webparsed from the site and metered, cyclic.
Yey!

Some observation though (you can add more than 3 coins):
In the first cycle of 10 sec nothing 'happens', but i is stil incremented to i=1. In the second cycle all coins prices are measured and metered, and i is incremented to i=2. From the third cycle forward, when i=x, is measured and metered Coin(x-2), so increment i is always 2 step forward than the measured and metered Coin(i). But that does not really matter, because everything is cyclic.
:)

So, everyone who want a ticker for more coins prices than the limit of requests per minute required from the site, use my code (eventually do it better, I am just a rookie...).
nocrack
Posts: 1
Joined: October 16th, 2021, 1:46 am

Re: Coinmarketcap Ticker with Bangs (Solved)

Post by nocrack »

I was searching something like this for smth like 1 hour and finally Iam here. New to Rainmeter but I wanna know how I must copy the code to make it work. Can you help me? What other site can I use instead of bitstamp? Just to get BNB and ADA reports...
riparid
Posts: 1
Joined: October 23rd, 2021, 5:23 pm

Re: Coinmarketcap Ticker with Bangs (Solved)

Post by riparid »

nocrack wrote: October 16th, 2021, 1:54 am I was searching something like this for smth like 1 hour and finally Iam here. New to Rainmeter but I wanna know how I must copy the code to make it work. Can you help me? What other site can I use instead of bitstamp? Just to get BNB and ADA reports...
Hi buddy, you can use Coinbase or Binance instead of Bitstamp.
Hi team, thanks for creating such an active forum.