Author

Topic: Awesome Miner - API Plugin (Profit Spike (Fake Profit) Guard) - (Need DIY) (Read 139 times)

jr. member
Activity: 348
Merit: 5
Hi Fellow Awesome Miners,

I'm just sharing this for those of you who are interested to try mining the most coins possible via generally the most profitable coins/algos as per Patrike's Awesome Miners' stats grabbed from various sources such as WhatToMine, Yiimp and MPOS pools. and are likely utilizing the "Current" stats for quick switching between profitable algos.

As some of you know, Awesome Miner (here on referred to as AM) is a great piece of miner moitoring/management software, but it is not without its own flaws which could be improved. Luckily, AM has provided simple ways to interact with the miners via HTTP API and opens up a great possibility to amateurs like me to further customize the capabilities of AM.

Warning: As I'm not at all a programmer myself, codes and methods provided here are only as a general guide and reference.

Credit: Patrike - AM Developer, Sootha (for inspiration from his Awesome AM Coin Updater Plugin)

***
Backstory:

The idea is simple, when pools, Whattomine reports a coin's profitability, they are susceptible to difficulty adjustments and can often inflate a coin/algo's profit by factor of tens or hundreds, this can last for a few blocks (usually fair few minutes or tens of minutes) or it could simply drop to near zero the next minute. regardless of how often one set it's switching interval, you are to encounter this fair few dozens of times a day when you expand the possible coins you mine (especially new coins where GPU miners are always on the lookout to mine...as the ASICs constantly chase us out of the bigger and more established chains)

when every time this fake spike happens, you will no doubt lose a good amount of time mining excessively inefficient coins, the time spent on mining trash for your hardware depends on the switching interval you set and how often you happen to have profit switching coincide with the fake profit reported (let's say...bad luck and "badder" luck?). It can take a huge toll on your profit when especially you are not mining with the cheapest electricity or wanting to achieve the quickest ROI...in fact...you might be making loss in a prolonged bearish market we have today...When I say a good portion of time, it is not unlikely that 20% of the time per day ( a good 5 hours) you are unlucky and stepped into dog poo pond...mining real .... poo....coins due to this.

Workaround:

Thanks to the API interactivity provided by AM (Premium Edition or above only...you have to fork out $170 USD to get that feature), one without programming knowledge can still do pretty amazing things with it and customize AM to your likings (to a certain degree)

so step it follows as below:

Make a Web data query from excel to get miner information
Code:
let
    Source = Json.Document(Web.Contents("http://mypc:17790/api/miners")),
    groupList = Source[groupList],
    groupList1 = groupList{1},
    minerList = groupList1[minerList],
    #"Converted to Table" = Table.FromList(minerList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "name", "statusInfo", "coinInfo", "hasValidStatus"}, {"Column1.id", "Column1.name", "Column1.statusInfo", "Column1.coinInfo", "Column1.hasValidStatus"}),
    #"Expanded Column1.statusInfo" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.statusInfo", {"statusDisplay", "statusLine3"}, {"Column1.statusInfo.statusDisplay", "Column1.statusInfo.statusLine3"}),
    #"Expanded Column1.coinInfo" = Table.ExpandRecordColumn(#"Expanded Column1.statusInfo", "Column1.coinInfo", {"revenuePerDay"}, {"Column1.coinInfo.revenuePerDay"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Expanded Column1.coinInfo", "Column1.statusInfo.statusLine3", Splitter.SplitTextByDelimiter("h ", QuoteStyle.Csv), {"Column1.statusInfo.statusLine3.1", "Column1.statusInfo.statusLine3.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.statusInfo.statusLine3.1", Int64.Type}, {"Column1.statusInfo.statusLine3.2", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","m","",Replacer.ReplaceText,{"Column1.statusInfo.statusLine3.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Replaced Value",{{"Column1.statusInfo.statusLine3.1", "Column1.runHour"}, {"Column1.statusInfo.statusLine3.2", "Column1.statusInfo.runMin"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Column1.statusInfo.runMin", Int64.Type}, {"Column1.coinInfo.revenuePerDay", Currency.Type}})
in
    #"Changed Type1"

and you end up with a table like this (remember the above, replace mypc with your main AM machine's address):

https://i.supload.com/r1eSFG2_cM.png

Cells that then have formulas to customize yourself how you like to set the switching condition listed below

Code:
Cell E24 (Find minimum runtime of the most recent switched miner):
=MIN(E2:E22)

Cell F24 (Total revenue in currency you set AM to display at):
=SUM(F2:F22)

Cell G24 (Total number of miners that is detected running and reporting to AM):
=COUNTIF(G2:G22,"TRUE")

Switch Condition (Cell F26), 1 = switch next macro run, 0 = no switching), here in my current setup I use the following, you can adjust as you see fit, namely
(only switch if there are at least 10 live miners AND revenue is less than 20 USD per day AND the most recent switch is  AT LEAST 1 minute ago):
=IF(AND(E24>0,F24<20,G24>10),1,0)


Next, Create a rule in AM to make a manual switch action:

https://i.supload.com/SklEQK2Ocf.png

Lastly, write up the macro to start / stop the operation and interact with AM, create 2 buttons, one assigned to start procedure, one to the stop

Code:
Global IsTimeToStop As Boolean

Sub runProfitSwitch()


'
' runProfitSwitch Macro
'
'

Dim objHTTP     As Object
Dim URL         As String
Dim Data        As String
Dim replyTXT
Dim URLConcat As String
Dim timeStamp As String

If IsTimeToStop Then Exit Sub

IsTimeToStop = False
timeStamp = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Debug.Print "Running - " + timeStamp

    ActiveWorkbook.Connections("Query - miners").Refresh
    
    Debug.Print "Refreshing Data... (Wait 10s)"
    Application.Wait (Now + TimeValue("00:00:10"))
    On Error Resume Next

If Cells(26, 6).Value = 1 Then

URLConcat = "http://mypc:17790/api/miners/33?action=rule&rule_id=8"

Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", URLConcat, False
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send ("")

timeStamp = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Range("$C$30").Value = "Switching Triggered On " + timeStamp

Else

timeStamp = Format(Now(), "dd-mm-yyyy hh:mm:ss")
Range("$C$30").Value = "No Profit Switch Needed " + timeStamp

End If

Application.OnTime Now + TimeValue("00:00:30"), "runProfitSwitch"

End Sub

Sub PauseMacro()
    IsTimeToStop = True
    Debug.Print "Stopping..."
End Sub

Sub StartSwitcher()
    IsTimeToStop = False
    runProfitSwitch
End Sub

a note of warning, you'll need to figure out the rule ID by checking with the JSON via AM's API, type in browser
Code:
 http://mypc:17790/api/miners
and search for the term "manualactionlist" without quotes...it'll show you the rule ID that is defined as manual trigger-able actions, edit the above VBA code accordingly where. also, the profit switching action triggers globally, all miners will switch as if it's running the scheduled profit switching interval in AM (interval defined by you)

Finally, result

https://i.supload.com/HJlrxhnu9G.png

so as one can see, at 10min switching intervals and the pools/coins/algos I'm mining, the trigger is roughly 2 an hour at 10min interval, and that's about 50 triggered switches a day, even at a modest estimation of 5min average time potentially wasted each instance without the switch, I was spending 4 hours (250minutes, 5minx50) per day mining inefficient algos due to the spike and sudden drops in profitability. It has already seemly helped me recoup 15% of my mining efforts lost b4 I had this up and running (let's be modest and don't forget to taken into account that RVN has gone up tremendously with approx 50% increase in 24 hours

***
Closing: Just to note I had this running on a laptop with an excel instance of it's own, apparently the above code sucks that it always hangs the all opened Excel windows while refreshing query (set to 30s to grab from AM) and also, it interferes with other active Excel windows...haven't worked out  (and can't be bothered) how to have this particular file/worksheet have a background focus...meaning it will grab/write anything into the foremost window with focus.... ;p
Jump to: