Change options at runtime

Issue #707 resolved
Desrever Nu created an issue

HTTP POST to localhost:4567 to update options at runtime

post to /config all options

post to /partialconfig for a subset of options

{"maxsellvolume":"10","maxbuyvolume":"3","spread":"50"}

The bot will stop, change options and restart.

Success response:

{
 "success":true ,
 "error":""
}

Error response example:

{
 "success":false ,
"error":"err description "
}

Comments (11)

  1. creon-nu

    Hi, the TLLP client needs to be able to adjust the amount held in Tier 1 and Tier 2 every 15 seconds. This could basically be achieved if you would allow me to set maxsell and maxbuy on the fly.

    Another useful feature would be if we could dictate the price to the NuBot. I already thought about simply providing a localhost price feed from the client which is then taken by the NuBot as only price source.

    In general I think an interface which allows to overwrite almost any parameter in the NuBot during the execution would make the NuBot very interesting for developers and not just LPCs.

  2. Desrever Nu reporter

    Sure, but let's start with one ticket at the time. This issue is very specific for changing tier1 limit.

    After changing the limit, do you expect the change to take effect immediately (aka reset orders) or wait for the next event that triggers the and order reset (price change etc) ?

    Another useful feature would be if we could dictate the price to the NuBot. I already thought about simply providing a localhost price feed from the client which is then taken by the NuBot as only price source.

    we have a streaming socket coming soon on prices.tradingbot.nu

  3. Desrever Nu reporter

    Currently we have an entrypoint :

    config/
    

    That takes the the full options as POST parameter .

    Snippet to demonstrate usage from js :

        var exchangename = $("#exchangename").attr("value");
        var apikey = $("#apikey").attr("value");
        var apisecret = $("#apisecret").attr("value");
        var txfee = $("#txfee").attr("value");
        var pair = $("#pair").attr("value");
        var dualside = $("#dualside").prop("checked");
        var multiplecustodians = $("#multiplecustodians").prop("checked");
        var executeorders = $("#executeorders").prop("checked");
        var verbosity = $("#verbosity").attr("value");
        var hipchat = $("#hipchat").prop("checked");
        var mailnotifications = $("#mailnotifications").attr("value");
        var mailrecipient = $("#mailrecipient").attr("value");
        var emergencytimeout = $("#emergencytimeout").attr("value");
        var keepproceeds = $("#keepproceeds").attr("value");
        var maxsellvolume = $("#maxsellvolume").attr("value");
        var maxbuyvolume = $("#maxbuyvolume").attr("value");
        var priceincrement = $("#priceincrement").attr("value");
        var submitliquidity = $("#submitliquidity").prop("checked");
        var nubitaddress = $("#nubitaddress").attr("value");
        var nudip = $("#nudip").attr("value");
        var nudport = $("#nudport").attr("value");
        var rpcpass = $("#rpcpass").attr("value");
        var rpcuser = $("#rpcuser").attr("value");
        var wallchangethreshold = $("#wallchangethreshold").attr("value");
        var spread = $("#spread").attr("value");
        var mainfeed = $("#mainfeed").attr("value");
    
        var backupfeedsString = $("#backupfeeds").attr("value");
        var backupfeedsarray = backupfeedsString.split(',');
    
        //could check on the client side if valid post
    
        var jsondata = JSON.stringify({
            "exchangename": exchangename,
            "apikey": apikey,
            "apisecret": apisecret,
            "txfee": txfee,
            "pair": pair,
            "dualside": dualside,
            "multiplecustodians": multiplecustodians,
            "executeorders": executeorders,
            "verbosity": verbosity,
            "hipchat": hipchat,
            "mailrecipient": mailrecipient,
            "mailnotifications": mailnotifications,
            "emergencytimeout": emergencytimeout,
            "keepproceeds": keepproceeds,
            "maxsellvolume": maxsellvolume,
            "maxbuyvolume": maxbuyvolume,
            "priceincrement": priceincrement,
            "submitliquidity": submitliquidity,
            "nubitaddress": nubitaddress,
            "nudip": nudip,
            "nudport": nudport,
            "rpcpass": rpcpass,
            "rpcuser": rpcuser,
            "wallchangethreshold": wallchangethreshold,
            "spread": spread,
            "mainfeed": mainfeed,
            "backupfeeds": backupfeedsarray
    
        });
    
    
        $.ajax("http://server.ip:4567/config", {
            data: jsondata,
            dataType: "json",
            type: 'POST',
            success: function(data) {
    
                console.log("got data " + data);
    
                // server returns custom error message
                var success = data["success"];
                //console.log("success " + success);
                var errormsg = data["error"];
                //console.log("error " + errormsg);
    
                if (success) {
                    //sth
                } else {
                    //sth else
                }
            },
    
            error: function(xhr, textStatus, errorThrown) {
                alert("makePostConfig - error posting to server " + textStatus + " " + errorThrown);
                alert(xhr.responseText);
            }
        });
    

    I never thought of the consequence of changing options at runtime, and doing so will take me some time. I should check one variable at the time and where each variable is being used.

    I suspect it will be a logistic nightmare making it fail-safe. I suspect it is easier to trigger an internal restart each time options are overwritten, (and still, this would need some fail-checks.

    Will think about it .

    In the meantime it probably makes sense to make a new entry point that allow to post a subset of options.

  4. creon-nu

    If it is too much effort then providing an interface to set maxsellvolume and maxbuyvolume would be sufficient. This should happen directly and not on the next wall shift. I'll look into the POST command, thanks.

    The price feed question was not about reliability. The user has to stick to the price dictated by the server, regardless what other sources say. Other price feeds should only be used on the client side to check if the server provides faulty data. If the nubot just takes Bitfinex and not the server price then there might be some temporary situations where the price deviation is too large, because the server had to take Coinbase for example. But this is not a big deal.

  5. Desrever Nu reporter

    If it is too much effort then providing an interface to set maxsellvolume and maxbuyvolume would be sufficient.

    Got it. Will update progress on this page and make a build to test it it as soon as I have something

  6. Desrever Nu reporter

    Update: added support for changing (all) options at runtime. The bot will stop/change config/restart .

    Will work on a method to change subset of options this afternoon

  7. Log in to comment