File tree 3 files changed +73
-1
lines changed 3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ function Test-macOSNetConnection {
147
147
148
148
[PSCustomObject ]@ {
149
149
ping = $r [-1 .. -2 ] -join ' , '
150
- ping6 = $r6 [-1 .. -2 ] -join ' , '
150
+ # ping6 = $r6[-1..-2] -join ', '
151
151
dns = $dns -join ' , '
152
152
dns6 = $dns6 -join ' , '
153
153
web = $web.StatusDescription
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments