Skip to content

Commit f0f52d9

Browse files
committed
add kraken
1 parent 400bfb8 commit f0f52d9

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

M01Stats.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function Get-M01Stats {
2+
param(
3+
$ComputerName = "m01"
4+
)
5+
6+
# kind of complicated
7+
#$sensors = sensors | Select-String -Pattern ":"
8+
#$sensorsTable = $sensors -replace ":","=" | ConvertFrom-StringData
9+
10+
try {
11+
$xmrApi = Invoke-RestMethod -uri "http://$ComputerName`:16000/api.json" -ErrorAction Stop
12+
$hashrate = $xmrApi | Select-Object -ExpandProperty hashrate | Select-Object -ExpandProperty total | Select-Object -First 1
13+
} catch {
14+
Write-Warning "Could not connect to XMR Api"
15+
}
16+
17+
$out = [ordered]@{
18+
"TimeStamp" = $(get-date -Format "yyyy-MM-dd HH:mm:ss")
19+
"Host" = $ComputerName;
20+
"Uptime" = $xmrApi.uptime
21+
"HashRate" = $hashrate
22+
}
23+
Write-Output (New-Object -TypeName psobject -Property $out)
24+
}

Microsoft.PowerShell_profile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function Test-macOSNetConnection {
147147

148148
[PSCustomObject]@{
149149
ping = $r[-1..-2] -join ', '
150-
ping6 = $r6[-1..-2] -join ', '
150+
#ping6 = $r6[-1..-2] -join ', '
151151
dns = $dns -join ', '
152152
dns6 = $dns6 -join ', '
153153
web = $web.StatusDescription

kraken-stats.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
function round2($i){
3+
[math]::round($i,2)
4+
}
5+
6+
function Get-KrakenStats {
7+
param(
8+
$Path,
9+
$Pair
10+
)
11+
process {
12+
$items = import-csv -Path $path
13+
if($Pair){
14+
$allPairs = $pair
15+
} else {
16+
$allPairs = ($items | Group-Object -Property pair).Name
17+
}
18+
foreach($pair in $allPairs){
19+
$out = [ordered]@{ pair='';pos='';vol='';cost='';fee='';maxprice='';minprice='';pnl='' }
20+
21+
$pairItems = $items.where{$_.pair -eq $pair}
22+
$minmax = $pairItems | Measure-Object -Property price -Maximum -Minimum
23+
$buys = $pairItems.where{$_.type -eq "buy"}
24+
$sells = $pairItems.where{$_.type -eq "sell"}
25+
$sumBuys = round2(($buys.vol | Measure-Object -Sum).Sum)
26+
$sumSells = round2(($sells.vol | Measure-Object -Sum).sum)
27+
$costBuys = round2(($buys.cost | Measure-Object -Sum).Sum)
28+
$costSells = round2(($sells.cost | Measure-Object -Sum).sum)
29+
$fee = round2(($pairItems | Measure-Object -Property fee -Sum).Sum)
30+
31+
$out.pair = $pair
32+
$out.pos = $sumBuys - $sumSells
33+
$out.vol = round2(($pairItems | Measure-Object -Property vol -sum).Sum)
34+
$out.cost = round2(($pairItems | Measure-Object -Property cost -sum).Sum)
35+
$out.fee = $fee
36+
$out.maxprice = round2($minmax.Maximum)
37+
$out.minprice = round2($minmax.Minimum)
38+
if($out.pos -eq 0){
39+
$out.pnl = round2($costSells - $costBuys - $fee)
40+
}
41+
42+
[PSCustomObject]$out
43+
}
44+
}
45+
}
46+
47+
Get-KrakenStats -Path ~/Downloads/trades.csv | ft
48+

0 commit comments

Comments
 (0)