It is currently September 21st, 2020, 6:45 pm

Simple Bitcoin Tracker

Post your work-in-progress and completed skins to share and discuss.
Deofol
Posts: 19
Joined: February 19th, 2020, 6:29 am

Simple Bitcoin Tracker

Post by Deofol »

Hey, fellas! I know I've been lost for a while and still got work to do on my skin for this topic: https://forum.rainmeter.net/viewtopic.php?f=5&t=34754 but I'd like to share with you a skin that I got distracted with while doing that. I made a simple bitcoin tracker as I often get paid in Bitcoin for my work. Here's a screenshot of it:
Image
It uses bitstamp.net's API to retrieve values. Now, onto the features, here is what it does:
  • Gets Bitcoin price automatically every #Seconds# seconds (#Seconds# is a Variable you must change by yourself depending on how often you want the skin to update. Default value is 60).
  • Indicates if Bitcoin rose or fell since last update with a green or red arrow.
  • Shows max and min 24H values in green and red respectively to the left of the current price
  • Shows a line graph in the background as a reference from the time you start running the skin. Every pixel it moves is #Seconds# seconds away from the next one. May be adding scaling in the future.
  • Graph changes color to green if price grows over 24H high and red if price grows over 24H low.
  • Force refresh on middle mouse button click.
It's my first release ever and I put some effort into it. Might be releasing a bigger skin sometime but for now I think this is worth sharing :). Here's the code to it:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
MiddleMouseUpAction=[!RefreshApp]

[Metadata]
Name=Simple Bitcoin Tracker
Author=Deofol
Version=1.0
License=GPLv3
Information=Shows ongoing rate for the USD/BTC pair, max and min 24 hour values and a reference graph through time running the skin.

[Variables]
Seconds=60
; Set how many seconds should each update take

[MeasureParent]
Measure=WebParser
UpdateRate=#Seconds#
URL=https://www.bitstamp.net/api/ticker/
RegExp=(?siU)high".*"(.*)000000".*last".*"(.*)"bid".*"(.*)".*low".*"(.*)000000"

[MeasurePrice]
Measure=WebParser
URL=[MeasureParent]
StringIndex=3

[MeasureLast]
Measure=WebParser
URL=[MeasureParent]
StringIndex=2

[MeasureLow]
Measure=WebParser
URL=[MeasureParent]
StringIndex=4

[MeasureHigh]
Measure=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasureLine]
Measure=Calc
Formula=(100*([MeasurePrice:2]-[MeasureLow:2]))/([MeasureHigh:2]-[MeasureLow:2])
MinValue=0
MaxValue=100
IfCondition=#CURRENTSECTION#<0
IfTrueAction=[!SetOption MeterLine PrimaryColor 255,0,0,100]
IfCondition2=(#CURRENTSECTION#>=0) && (#CURRENTSECTION#<=100)
IfTrueAction2=[!SetOption MeterLine PrimaryColor 255,255,255,100]
IfCondition3=#CURRENTSECTION#>100
IfTrueAction3=[!SetOption MeterLine PrimaryColor 0,255,0,100]
DynamicVariables=1

[MeasureGrowth]
Measure=Calc
Formula=[MeasurePrice:2]-[MeasureLast:2]
IfCondition=#CURRENTSECTION#<0
IfTrueAction=[!SetOption DownArrow Hidden 0][!SetOption UpArrow Hidden 1]
IfCondition2=#CURRENTSECTION#>0
IfTrueAction2=[!SetOption UpArrow Hidden 0][!SetOption DownArrow Hidden 1]
DynamicVariables=1

[GraphBG]
Meter=Shape
Shape=Rectangle 0,0,160,45,3 | Fill Color 0,0,0,100 | StrokeWidth 1 | Stroke Color 255,255,255,255

[UpArrow]
Meter=Shape
Shape=Line 4,27,40,18 | Stroke Color 0,255,0,255
Shape2=Line 40,18,35,16 | Stroke Color 0,255,0,255
Shape3=Line 40,18,37,21 | Stroke Color 0,255,0,255
Hidden=1

[DownArrow]
Meter=Shape
Shape=Line 4,18,40,27 | Stroke Color 255,0,0,255
Shape2=Line 40,27,35,29 | Stroke Color 255,0,0,255
Shape3=Line 40,27,37,24 | Stroke Color 255,0,0,255
Hidden=1

[MeterLine]
Meter=Line
MeasureName=MeasureLine
UpdateDivider=#Seconds#
X=3
Y=3
W=154
H=39
PrimaryColor=255,255,255,100
SolidColor=0,0,0,0
AntiAlias=1

[MeterPrice]
Meter=String
MeasureName=MeasurePrice
W=110
H=70
X=100
Y=-3
FontSize=20
FontColor=255,255,255,255
InlineSetting=Face | Roboto-Bold
StringAlign=Center
StringStyle=Bold
AntiAlias=1

[CurrencyText]
Meter=String
Text=USD - BTC
StringAlign=Center
StringStyle=Bold
X=r
Y=27r
FontSize=10
FontColor=255,255,255,255
InlineSetting=Face | Roboto-Bold
AntiAlias=1

[HighText]
Meter=String
MeasureName=MeasureHigh
StringAlign=Left
X=3
Y=4
FontSize=8
FontColor=0,255,0,255
InlineSetting=Face | Roboto-Bold
AntiAlias=1

[LowText]
Meter=String
MeasureName=MeasureLow
StringAlign=Left
X=3
Y=27
FontSize=8
FontColor=255,0,0,255
InlineSetting=Face | Roboto-Bold
AntiAlias=1
Pearse
Posts: 2
Joined: August 18th, 2020, 5:25 pm

Re: Simple Bitcoin Tracker

Post by Pearse »

This handy little meter has stopped working recently, have bitstamp changed something i wonder?
User avatar
ikarus1969
Posts: 385
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Simple Bitcoin Tracker

Post by ikarus1969 »

Pearse wrote: August 24th, 2020, 6:59 pm This handy little meter has stopped working recently, have bitstamp changed something i wonder?
The whole site the skin is using (https://www.bitstamp.net/) is under maintenance currently:
ScrennShot.PNG
You do not have the required permissions to view the files attached to this post.
Pearse
Posts: 2
Joined: August 18th, 2020, 5:25 pm

Re: Simple Bitcoin Tracker

Post by Pearse »

Thanks for the heads up ikarus, hopefully they will be back soon.
User avatar
ikarus1969
Posts: 385
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Simple Bitcoin Tracker

Post by ikarus1969 »

Should work now. At least the website is accessible again.
User avatar
ikarus1969
Posts: 385
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Simple Bitcoin Tracker

Post by ikarus1969 »

They've changed the ticker so to have it work again adapt the [MeasureParent] by replacing the existing RegExp=... by the following:

Code: Select all

RegExp=(?siU)"last":\s*"(.*)".*"bid":\s*"(.*)".*high":\s*"(.*)".*low":\s*"(.*)"
and the StringIndex of the following measures by replacing those measures by the following:

Code: Select all

[MeasurePrice]
Measure=WebParser
URL=[MeasureParent]
StringIndex=2

[MeasureLast]
Measure=WebParser
URL=[MeasureParent]
StringIndex=1

[MeasureLow]
Measure=WebParser
URL=[MeasureParent]
StringIndex=4

[MeasureHigh]
Measure=WebParser
URL=[MeasureParent]
StringIndex=3
Edit: the json that you get with the ticker looks as follows:

Code: Select all

{"volume": "3769.76512605", "last": "11367.49", "timestamp": "1598509333", "bid": "11366.88", "vwap": "11397.23", "high": "11549.80", "low": "11250.14", "ask": "11371.47", "open": 11462.91}