Username: Password:

Author Topic: Cryptowally's gunbot linux console, Part I  (Read 29225 times)

Offline cw

  • Rookie
  • *
  • Banned!
  • Posts: 57
    • View Profile
    • Gunbot University
Cryptowally's gunbot linux console, Part I
« on: May 10, 2017, 10:11:02 PM »
Several people have asked in the telegram chat for the steps of the "gunbot console" I made so I can monitor multiple pairs on one screen at once.  What this does is let me see the most important recent information of 16 pairs on one screen.  I have dual-screens, so I can see 32 pairs on the two screens.  All at once - for example, I can see if an instance needs to be restarted.  Or I can see if polo is giving me errors across all of them at once (the dreaded 429 errors).  Or I can see if one of the pairs is getting the "polo is being bad and giving us wrong alt coin balance!!!!!!!!" and I need to restart the bot. 

All these things help me manage multiple pairs with less effort and with a keen eye.

This is what it looks like on one screen:


And for another one with just 6 pairs, it would look like this (for example, ETH only has a few available coin pairs):  You might have another 16 pairs on the second screen, or yet another 16 pairs behind that, or whatever.


This is draft #1 - I was able to make this setup work for me in a few minutes, because I've used screen, tee and multitail in a former life and it's second nature.  However, it's not necessarily easy to explain to others who are new to it.

I'm working on a draft #2 for an improved console, but it will take a lot longer.  Since draft #1 works and suits its purpose and only took a few minutes, I might not hurry too much for draft #2 :)

I've color coded the text in the console like so:
RED TEXT: Error codes like status 422, 500, 520, 420
Yellow Text: Bags.  There's a "has order: " line in the output.  That means there's a bag.
Purple Text: There's an active BUY order still at polo
Cyan Text: There's an active SELL order still at polo
Red/Yellow Text: Order information (buy or sell order placed), profit calculated.
Red/White text: The price is about to buy or about to sell.  Might want to watch because something's happening.
Green Text: supergun true and falls no
RED TEXT: supergun false and falls yes

For example, if Gunbot is thinking about buying or thinking about selling, you'll see the ">= prSell" or "<= prBuy" turn red with white background so it will catch your attention.


The whole point is that I can watch the screen at 16 different pairs and only look for major things - bags, balance, purchases, market swings, buys, sells, etc.   And then I can launch another 16 pairs and another 16 pairs, etc.

The general setup is:
  • `screen` is a program that lets you have multiple terminals and gunbot will run while you're logged out.
  • Each gunbot instance runs in a different screen terminal
  • Each gunbot instance pipes output to `tee`
  • `tee` is a program that sends output to console AND puts output into a file
  • `multitail` is a neat program that will tail a file and put it into a self-contained window and do things with it
  • There are tons of command line options you need for multitail to make it pretty
  • I wrote a multitail.conf that strips out the extra stuff we don't need
  • For my purposes, I wrote a bash script for each group of up to 16 pairs of gunbot instances

Also, I have no idea if this will work for anyone else - it works for me, so that's all I know.  So, some caveats:
  • This is working for me.  I make no warranty for anyone else.
  • This is based on v2.0.3b - probably should work with other versions
  • This is using stepgain output - probably should work with other versions
  • I'm using Ubuntu LTS 14.04 - probably should work with other versions
  • Not expected to work with Windows in any way

In my environment, I create a new directory for each gunbot instance, and I name the directory with a naming convention using the pair name with a dash.  For example, "btc-maid" or "eth-gnt".  This is important in order for the rest of this to work smoothly!

------------------------------
GNU SCREEN:
------------------------------

As I mentioned above, I use GNU screen to manage multiple gunbot instances.  Google how to install screen for your OS.  It's pretty easy using the package manager of your choice.  There are some good tutorials about screen here, here and here.

I typically will group no more than 16 instances in a single screen session.  For one, I have a pretty big monitor and fitting more than 16 together gets to be a little crowded.  I probably could fit 20 and maybe 24 but I'm not running that many pairs yet.  Maybe when I do, I'll try it.  You're free to try.  When things are working, each cycle only really needs 4-5 lines of output so you could easily increase the number of output in multitail or use a smaller font.  It's doable.

Put this in a file called ~/.screenrc - modify at your leisure or find some other tidbits online.  For example, vim ~/.screenrc or use nano or your favorite text editor.

This is the .screenrc I use:

Code: [Select]
defscrollback 9999
startup_message off
shell -$SHELL

hardstatus string '%{= kG}%{C}Screen: %{c}%{= kG}[%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{C} %d-%m %{W}%c %{g}]'

caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %c"
vbell off

termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'

Now you can start screen.  Just type in

Code: [Select]
# screen

and you should have a blank window with a "0 bash" at the bottom


now you have one bash shell running and it's screen number is zero "0".

If you press CTRL+a and then the letter "c" for "create" it will create a new window and run a bash shell by default and it will be screen number "1" (aka "window 1")


You can keep doing this (CTRL+a, then letter c, or CTRL+a-c for short) and you will keep creating new screen windows.  Notice how it keeps adding little tabs at the bottom, and each time it increases the number next to it.  Each window is a new separate bash shell and you can run whatever you want in it (like, say, a gunbot instance).


CTRL+a is the "command key" for screen. It's how you tell screen what to do.  CTRL+a-? (CTRL+a then question mark) will give you all the help, and there are lots of tutorials online that will help guide you through all the power tools of what screen can do (tip: google search for "GNU screen" instead of just "screen").  Here are the main ones you need for gunbot:

  • CTRL+a-space - moves forward one window
  • CTRL+a-backspace - moves backward one window
  • CTRL+a-CTRL+D - disconnect from screen session altogether (so you can reconnect later)
  • screen -r    this resumes a disconnected screen (assuming you only have one disconnected session - see tutorial links above)
  • CTRL+a-(number) - connect to window number specified (single digit only unfortunately)

------------------------------
USING TEE WITH GUNBOT
------------------------------


Part of how this console magic works is that we need gunbot's output but we only want part of it.  So, we pipe gunbot's output to a program called "tee".  Go to one of the screen windows and run gunbot like you normally do but pipe the output to tee. 

Now, what I do is I use a naming convention, not only for each directory I run gunbot in (important) but also the name of the file the I pipe the console output to (important).  That way the multitail works more easily.

Also, I keep everything in a directory called 'gunbot' and each instance is in its own subdirectory labeled with the pair, say "btc-maid".
So, I go to window 1 (NOT WINDOW 0 because I use window 0 for my "status console") -

Press CTRL+a-1 (this will get you to window 1 no matter what window you're 1) and it will highlight the tab at the bottom with the "1 bash").

Code: [Select]
zcash@zcash1:~$ cd gunbot
zcash@zcash1:~/gunbot$ cd btc-maid
zcash@zcash1:~/gunbot/btc-maid$ ./gunbot BTC_MAID | tee -a btc_maid-console.log

This specific example I'm showing above is for gunbot v2.0.3.  It launches stepgain, loads the configuration from BTC_MAID-config.js (which is just how it works in this version), displays the output into the console, and will also put all the output into the btc_maid-console.log file.

Then press CTRL+a-space to go to the next window (or CTRL+a-c to create one if I need a new window) and repeat the steps for the next pair - create a new btc-(pair) directory if needed... untar the whole gunbot installation files if needed....

QUICK TIP for spinning up a new pair: what I do is create a master installation directory when Gunthar gives us a stable version and I know I'm going to use it.. for example, v2.0.3b is what I'm using now. So I create a gunbot/v2.0.3 directory that is blank except for the files needed.

So, if I want a new pair, say btc-NEW, I do the following:

Code: [Select]
zcash@zcash1:~/gunbot$ mkdir btc-new
zcash@zcash1:~/gunbot$ cd v2.0.3
zcash@zcash1:~/gunbot/v2.0.3$ tar cvf - . | (cd ../btc-new; tar xfBp -)
./
./config.js
./package.json
./BTC_DASH-config.js
./gunbot
./save.json
./x86/
./x86/gunbot
zcash@zcash1:~/gunbot/v2.0.3$ cd ../btc-new
zcash@zcash1:~/gunbot/btc-new$ mv BTC_DASH-config.js BTC_NEW-config.js
zcash@zcash1:~/gunbot/btc-new$ vim !$

This creates a nice pristine copy that I can edit.  Then I edit the config of the new coin (if needed) and I'm ready to add it somewhere and run it.  This could be scripted if I was doing it often enough.

------------------------------
STATUS SO FAR
------------------------------


So, hopefully you were able to continue with the above steps and launch your multiple gunbot instances, each in their own screen window.  Keep doing CTRL+a-space to move forward a window at a time so you can watch gunbot happily run (don't worry that you don't see any colors from gunbot... tee doesn't support colors... and you don't want colors in the console logs anyway because it messes up the multitail coding). 

Ok, now let's say we have 8, 12, 16 or so gunbot instances running in the single screen session.  For many people, that's enough.  If you didn't want "cryptowally's fancy linux console" and just wanted screen to have the ability to run gunbot in unattended fashion, you're done.  You can just do the following:

  • CTRL+a-space to move forward and see the raw console of each instance
  • CTRL+a-backspace to move backwards
  • CTRL+a-CTRL+D to detach your entire screen session - that way everything continues to run while you're logged out.
  • screen -r to restore or return to your screen session later (more advanced options exist here, like naming them with -S and -list)

If you still want the fancy console, continue reading.

------------------------------
MULTITAIL CONSOLE
------------------------------


Again, I use a main "gunbot" directory that holds all my pairs.  Depending on how you do your pairs, this may change for you.  You might make a "btc1" to hold the first 16 pairs, and a "btc2" for the next 16 pairs and a "eth1" for the eth pairs, etc.

You need to have multitail installed.    Start at the official home page first, then google for some of the other tutorials.  Here are some of my favorites. Installation of multitail on linux tips,  A good .conf file, and Stackexchange article on watching a file even if not created.   

Create a "multitail.conf" file that contains the following text:
Code: [Select]
#include:/etc/multitail.conf
#check_mail:0
colorscheme:gunbot
cs_re:red,magenta:< prBuy
cs_re:red,white:<= prBuy
cs_re:red,white:>= prSell
cs_re:red,yellow:> prSell
cs_re:red,yellow:Sell order placed
cs_re:red,yellow:.*ORDER INFORMATION.*
cs_re:red,yellow:.*profit.*
cs_re:white:.*MinPriceToSell.*
cs_re:white:.*MaxPriceToBuy.*
cs_re:white:.*MaxPriceToSell.*
cs_re:white:.*MinPriceToBuy.*
cs_re:yellow:^Direction:\s+\d+
cs_re:white,red:Not enough BTC
cs_re:red:Error\!*
cs_re:red:.*failed.*
cs_re:red:.*no altcoins.*
cs_re:red:statusCode (.*)
cs_re:green:true
cs_re:red:false
cs_re:magenta:.*buy.*
cs_re:cyan:.*sell.*
cs_re:red:falls\syes
cs_re:green:grows\syes
cs_re:yellow:Has order:.*
cs_re:white:\:\:.*

Of course, the format is pretty self explanatory - if you want different colors, change the colors and the text that you want it to match.  It's normal regex so if you understand regular expressions it's pretty easy.  Put the matches in order from top to bottom.

Notice I'm also highlighting times when there isn't enough BTC or ETH, or when SELL or BUY orders are placed.  Those are things I like to have pointed out to me if I'm just watching things go by.

The next thing I like to see are a list of my latest trades.  So I wrote a little bash script that finds them for me. Since they're in the console logs, I can find them.

Create a directory called stats and create a file in there called "latesttrades.sh":

Code: [Select]
#!/bin/sh

for i in `ls /home/zcash/gunbot/[be]*/[be]*-console.log`
do
        tail -30000 $i  |  egrep '(Buying|Selling|Error\!\!\! Not enough )'
done

Note that you will need to change the "/home/zcash/gunbot/" part to be your normal directory.... and for me, since I run btc and eth pairs, the be be part is a regular expression that matches both "btc" and "eth" in the name.  What it does is looks for ALL the files with "console.log" in the name, but only the ones with "btc" or "eth" in the directory name, AND in the file name but only ones that start with "b" or "e" at the beginning of the name... and then it looks at the last 30000 lines of the file and finds if it bought, sold or had an error.

That's what gives me a nice one-liner summary at the bottom right hand corner of the console -- not sure if you noticed that in the first picture.  If you don't want that, you can leave out the script.

----------------------
The big stats page
----------------------


Now for the script that fires off the multitail.  Create a "btcstat.sh" file inside the top-level gunbot directory and put the following in it:

Code: [Select]
#!/bin/sh

multitail -Z red,black,inverse --config multitail.conf -CS gunbot -x "%m %u@%h %f (%t) [%l]" -b 4 -s 2 -m 0 -n 100 \
   --mark-interval 200 \
        -Ev "before to buy" \
        -Ev "Cannot sell" \
        -Ev "MaxPriceToBuy" \
        -Ev "Last price <=" \
        -Ev "Last price >=" \
        -Ev "Last price >" \
        -Ev "Last price >" \
        -Ev "Altcoin Balance" \
        -Ev "Not supergun:" \
        -Ev "Supergun: " \
        -Ev "avCoins" \
        -Ev "CANCEL sell orders" \
        -Ev "CANCEL buy orders" \
        -Ev "SEll on start" \
        -Ev "^$" \
        -Ev "^\s+\d+\.\d+$" \
        -Ev "No order" \
        -Ev ":::" \
        -Ev "Error\!\!\! statusCode 422" \
        -Ev "Will repeat" \
        -Ev "cycle" \
        -Ev "No basePrice" \
        -Ev "need_" \
        -Ev "Response:" \
        -Ev "Bot responsed" \
        -Ev "next delay" \
        -Ev "^\*" \
        -Ev "\*\*" \
        btc*/*-console.log \
        -ts -c- -Rc 10 -l "./stats/latesttrades.sh "

In short, what this does is:

  • runs multitail
  • loads the multitail.conf file we created before
  • loads the gunbot scheme
  • will warn you with yellow marker lines if any window doesn't have output for 200 seconds (so you can see any HANGING gunbot instances so you can restart them manually... ie, CTRL+a-space over to that window, CTRL+C to stop gunbot, up-arrow and press enter...)
  • strips out all the lines we don't need - that's what the -Ev lines do
  • dynamically makes a window for any -console.log file that matches the btc*/ line (so make sure your directory structure is good)
  • runs the stats/latesttrades.sh script every so often so you know how your trades are going

What *I* do is run ./btcstat.sh from screen window 0.  So I launch all my gunbots starting on window 1, then 2, then 3... etc and make sure they're all running first... then go to window 0 and run ./btcstat.sh.   That way all the -console.logs are there.  multitail will create all the windows it needs.... if you have 8 console logs, it will create 4 x 2 windows plus the latesttrades, so it will have 9 windows.  If you have 16 gunbots running, then you will have 17 windows (8 on the left and 9 on the right).

Notice again that if you start getting yellow lines in any of the windows, that means the gunbot instance in that specific window hasn't had any output for 200 seconds (or whatever you have "mark_interval" set to)...


See the window with the yellow in it?  Multitail is telling me that gunbot has locked up or is hung.  gunbot isn't responding or at least the console log file it's writing to hasn't had any updates.  I NEED TO ACT!

So what do you do?  You need to CTRL+a-space over to that window, CTRL-C gunbot, up arrow and press enter so it can restart.  This happens sometimes when gunbot sent a request to polo and polo didn't send it back.  Here's an example - you'll see "collecting data..." at the bottom of the window and gunbot is not doing anything... there's no output to the console like the other windows.


Just restart gunbot in that one window and you're back in business.  (ie, CTRL++-space until you get there, then CTRL+C to stop gunbot.  Press up-arrow to bring up the command that last started gunbot with the exact same settings in that window and press enter.  It will restart with the same settings and same tee command and everything.  Then CTRL+a-0 to get back to your btcstat.sh page.

I use that mark-interval and the yellow coloring so I can more quickly see that something is wrong.  There have been times when I see a whole bunch of yellow.  Thank goodness I had this system.  I can much more quickly determine if I have a bot that's hung up because I can quickly scan all the bots and see what's wrong.

Now, if you're running any of the other strategies like BB, Russian Roulette, Supergun or some version other than 2.0.3b, I don't know how the console output is different from stepgain.  I don't run those.   There may be tweaks needed to multitail.conf file, btcstat.sh, or latesttrades.sh scripts.  If someone wants to post their console output here, I can maybe post some possible tweaks.

-------------------
DISK SPACE CLEANUP
-------------------


As you can imagine, having each gunbot instance write all its console logs to the disk can eat up a lot of disk space over time.  You really only need the most recent console logs, so what you do with the logs after some time is up to you.  But since you don't want your disks to fill up, you need something to clear out those files.

I use a tool called logrotate.  If you want to copy what I do, it's easy and at least preserves the logs long-term by compressing them and only gives you a minor weekly task.

My system already had logrotate installed, so if you don't have it installed, google "logrotate" or "logrotated" and at least have the defaults running.  Usually, /etc/logrotate.conf points to an /etc/logrotate.d directory where you can put your own local settings.

Create an /etc/logrotate.d/gunbot file and put the following, changing the directory to match your own console.log files and directory naming:

Code: [Select]
/home/zcash/gunbot/[be]*/*-console.log {
        missingok
        weekly
        create 664 zcash zcash
        rotate 30
        compress
        dateext
}

For example, if your home directory is /home/gunbot and you put all your files into a directory called btc1, and your pairs are btc-<coin>, then that first line would have /home/gunbot/btc1/btc-*/btc*-console.log in it. Just make sure the regular expression matches what you have there.  You can use one line to match all your console logs if you want.

This will compress your big console.logs every week and rotate them out every month and put a date on them so if you wanted to go research how gunbot worked, you could still do so.

After my system has been running a while, here's how the log files look:

Code: [Select]
zcash@zcash1:~/gunbot$ ll btc-fct/
total 43952
drwxrwxr-x  3 zcash zcash     4096 May  9 09:23 ./
drwxrwxr-x 33 zcash zcash     4096 May 10 10:56 ../
-rw-rw-r--  1 zcash zcash     3432 May  9 09:23 BTC_FCT-config.js
-rw-rw-r--  1 zcash zcash  2586115 May 10 12:29 btc_fct-console.log
-rw-rw-r--  1 zcash zcash   885421 Apr 16 06:54 btc_fct-console.log-20170416.gz
-rw-rw-r--  1 zcash zcash   594402 Apr 23 21:49 btc_fct-console.log-20170424.gz
-rw-rw-r--  1 zcash zcash   430755 Apr 30 06:40 btc_fct-console.log-20170430.gz
-rw-rw-r--  1 zcash zcash   398708 May  7 06:53 btc_fct-console.log-20170507.gz

Notice how I still have my main console.log (and it's pretty big), and every week, it has a .gz file of the previous week's logs, which is much smaller.

I should point out that I enabled debug logging in my config... so I even have more console logging enabled than most people.  You can tweak your logrotate file to delete the console logs after a week, or not keep so many if you'd like.  Check out the many logrotate example files on the internet, or in the man pages.

Note that what this means is that multitail will turn yellow every week, because it won't know to refresh and look at the new log files.  So Monday morning when you come in, you'll see a sea of yellow windows.  Do not panic - just go to window 0, CTRL+C the btcstat.sh and up-arrow restart it so it can re-read the new console log files.  Or, you may need to just go to each gunbot instance and restart them - just to refresh the tee overwriting the console logs.  Don't worry - gunbot works fine and hasn't quit.  It's just that logrotate and tee or multitail don't get along sometimes.  It's still trading just fine.

--------------------
Multiple screen sessions
--------------------


So, the above is for one screen session for up to 16 pairs.  If you're going past that, I'd recommend you start the next set of pairs with another completely different directory and duplicate everything separately so nothing stomps on anything else.  That way, you're free to use the asterisks and regular expressions and things without messing things up.  It gets complicated if you're trying to juggle too many pairs in the same directory structure.

Personally, I run separate screens for my BTC and ETH pairs.  When I start my BTC screen session the first time, I name the screen session "btc" by running it with "screen -S btc".  For eth pairs, I do "screen -S eth".  This is only the very first time I launch screen, before I've started any gunbot sessions.    That way, with the screen session itself having a name, when I do a "screen -list" I can reconnect to the one I want:

Code: [Select]
zcash@zcash1:~/gunbot$ screen -list
There are screens on:
        31870.eth       (04/05/2017 08:14:10 PM)        (Attached)
        31307.btc       (04/05/2017 08:04:40 PM)        (Attached)

Instead of using "eth" or "btc," you might use "btc1" or "btc2" for the first set of btc pairs, second set or whatever.

So, when I reconnect to my server, I can just type in "screen -r eth" and I'll see all my 6 eth screens still running.  Then I fire up another putty session to my server and in that putty screen I type in "screen -r btc" and the 16 gunbot sessions show up there.  Everything's still running and money's still being made.

Nothing's stopping you from running multiple screens for each set of pairs.  Have a separate directory for each set of pairs.  "btc1" would contain multitail.conf, btcstat.sh, and one subdirectory for each pair.  Everything would be contained together so nothing stomped on each other.

btc2 would be a different directory with it's own multitail.conf, btcstat.sh and subdirectory for its pairs. 

-----------------------
Next steps / future ideas
-----------------------


Future Idea #1: better console
I've been working on a Part II, where the output is more formatted instead of just filtered, and one where it can react to output (such as restarting gunbot when it's yellow), or maybe even change the configs if it notices things like BTC rising, but that takes time.  Plus Gunthar keeps improving the bot (and changing the output) so at some point it might not be worth making changes.

But here's what I've mocked up as the next version of the console - if you'd like me to work on this, consider leaving a tip, or reputation.  The next version constantly watches each cycle's output and feeds a realtime console with the updates but only gives the pertinent and relevant information.  Do I have a bag?  Is it about to buy?  Do I have enough balance?  Is the coin pumping?  Are my settings way off?  How come I don't understand bitcoin market?  And my favorite:  Why am I expecting Gunthar to read my mind when I haven't even tried to understand what gunbot is really doing?


I think with this kind of console, we can better tweak our settings and understand what's going on.  Notice how in the console, I see consistent information in the same spot for each pair, the price is in the same format, I can see buy/sell history, and current orders, and when something changes, it highlights it with color, and I can see the last error, etc.  All this is in the current console output, so I just need to scrape it, collect it, and then fill out the formatter. 

Future Idea #2 - auto-launch. 
One thing I'm mostly done with is automating the above, where instead of manually setting up the screen sessions and such, one could use a .screenrc that launches the different gunbots in a synchronized manner, cd'ing to the directories and running gunbot correctly, and in a staggered fashion, say 3 seconds apart, so as not to anger the API gods.  I just haven't finished it because it's not bothering me too much.  I start gunbot by hand and time it manually by doing CTRL+a-space, up-arrow, enter and go to the next one and that takes about 3 seconds, and I do it so infrequently that I haven't found the need to automate it.  But it can be done and I know others have done it.

But it would look something like this:

Code: [Select]
$ more testscreen/fireguns
startup_message off
defscrollback 100000

#create windows
screen -t btc_gnt
select 0
stuff "sleep 3; fire gunbot command here"
screen -t btc_nav
select 1
stuff "sleep 3; fire gunbot command here"
# repeat to add more and more gunbot windows
# .......
screen -t stats
select 16
stuff "multitail monitoring command here"
#

Note you need a CTRL+M sequence at the end of the stuff commands in order for it to actually execute the commands... like so:




--------------
TIP JAR
--------------


If you enjoyed this tutorial and would like to leave a small tip, you may do so at the following address:
(I'll take any altcoin tip as well.. PM me to tell me the coin and I'll give you an address)

BTC: 1AhkpVhEqxfiaJoEayifwgqppEqZVbdCmn







Cointracking affiliate link (10% discount for you) https://cointracking.info?ref=C937652

Offline Snapper_Head

  • Rookie
  • *
  • Posts: 4
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #1 on: May 11, 2017, 12:06:33 AM »
That is quite a beautiful and sophisticated set-up.

I have been wondering what is the most efficient way to run several pairs at once.

This will make for a good weekend project !

Thank you for taking the time to write such a detailed how to.

Offline AlfonseX

  • Contributor
  • **
  • Posts: 101
  • Trop de chefs, pas assez d'indiens !
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #2 on: May 13, 2017, 02:26:49 PM »
Nice script guy  :)

You said:
Quote
... tee doesn't support colors...

Take a look at unbuffer https://superuser.com/questions/352697/preserve-colors-while-piping-to-tee, it's part of expect-dev package.

So you run gunbot like this:
Code: [Select]
unbuffer node BB BTC_XXX poloniex | tee -a outpout.log
unbuffer send escape code to the terminal, so even tail profit:
Code: [Select]
tail -f output.log
display colors  :)

And because escape codes, you run multitail:
Code: [Select]
multitail -cT ANSI -f output.log
La vie en rose
If you think I helped you, give me a drink:
in btc: 12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
in eth: 0x02a611f0c15bccdb6fa8e5e4b0692ff6d77852bd

Offline cw

  • Rookie
  • *
  • Banned!
  • Posts: 57
    • View Profile
    • Gunbot University
Re: Cryptowally's gunbot linux console, Part I
« Reply #3 on: May 18, 2017, 05:18:06 AM »
AlfonseX - thank you for the post and the tip.  Actually, I knew that I could tee in color, and that the codes would be there, but that it messed up multitail.  What I didn't know was unbuffer, so that's a great tip.

Also, I didn't know about the ANSI mod for multitail.

Since I recolor the output in the multitail windows to suit my individual color schemes, it's probably better I start with it all stripped out anyway, but it's good that you put the options here. Others might want to preserve gunbot's original color scheme.

I'm about to test with 3.2 and may play with this new setup.

Cointracking affiliate link (10% discount for you) https://cointracking.info?ref=C937652

Offline AlfonseX

  • Contributor
  • **
  • Posts: 101
  • Trop de chefs, pas assez d'indiens !
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #4 on: May 18, 2017, 02:49:10 PM »
You're welcome  :)
Do not hesitate to publish your progress.
If you think I helped you, give me a drink:
in btc: 12aeQSpytxoehCEptQE8tUJVVSAS42LvXo
in eth: 0x02a611f0c15bccdb6fa8e5e4b0692ff6d77852bd

Offline cw

  • Rookie
  • *
  • Banned!
  • Posts: 57
    • View Profile
    • Gunbot University
Re: Cryptowally's gunbot linux console, Part I
« Reply #5 on: May 18, 2017, 09:39:11 PM »
I installed 3.2 and started working with Kraken exchange.  I've modified a stats.sh launcher and the multitail.conf file to change how things display, but the new console has so much on it, that it's difficult to fit it all into a window if running too many pairs.  So I've had to cut out a number of lines...

Also, I've noticed a few discrepancies in this version, like the console eventually will report "Open orders" whether or not there are open orders.

Anyway, here's how it looks so far:


And here are the changes to the files:

(for my new 3.2, I started to lump all the bots into one directory instead of each into it's own directory.  Now that it supports ALLPAIRS, it seems better to have them together. So you'll see that I changed it to be .*/*-console.log for example)

Code: [Select]
#!/bin/sh

multitail -Z red,black,inverse --config multitail.conf -CS gunbot -x "%m %u@%h %f (%t) [%l]" -b 4 -s 2 -m 0 -n 100 \
   --mark-interval 200 \
   -Ev "before to buy" \
   -Ev "Cannot sell" \
   -Ev "price to buy" \
   -Ev "MaxPriceToBuy" \
   -Ev "Last price <=" \
   -Ev "Last price >=" \
   -Ev "Last price >" \
   -Ev "Last price >" \
   -Ev "price  grows \(" \
   -Ev "price  falls \(" \
   -Ev "^need " \
   -Ev "^Callback:" \
   -Ev "no altcoins" \
   -Ev "Altcoin Balance" \
   -Ev "\+\+\+"\
   -Ev "\[\]"\
   -Ev "-------" \
   -Ev "is too high" \
   -Ev "price is too low" \
   -Ev "price too high" \
   -Ev "waiting to sell" \
   -Ev "Creating market client" \
   -Ev "Loading config" \
   -Ev "Not supergun:" \
   -Ev "Supergun: " \
   -Ev "avCoins" \
   -Ev "CANCEL sell orders" \
   -Ev "CANCEL buy orders" \
   -Ev "SEll on start" \
   -Ev "^$" \
   -Ev "^\s+\d+\.\d+$" \
   -Ev "No order" \
   -Ev ":::" \
   -Ev "Error\!\!\! statusCode 422" \
   -Ev "Will repeat" \
   -Ev "cycle" \
   -Ev "No basePrice" \
   -Ev "need_" \
   -Ev "Response:" \
   -Ev "Bot responsed" \
   -Ev "next delay" \
   -Ev "^\*" \
   -Ev "\*\*" \
   .*/*-console.log \
   -ts -c- -Rc 10 -l "./latesttrades.sh "

Code: [Select]
#include:/etc/multitail.conf
#check_mail:0
colorscheme:gunbot
cs_re:red,magenta:< prBuy
cs_re:red,white:<= prBuy
cs_re:red,white:>= prSell
cs_re:red,yellow:> prSell
cs_re:red,yellow:Sell order placed
cs_re:red,yellow:.*ORDER INFORMATION.*
cs_re:red,yellow:.*profit.*
cs_re:white:.*MinPriceToSell.*
cs_re:white:.*MaxPriceToBuy.*
cs_re:white:.*MaxPriceToSell.*
cs_re:white:.*MinPriceToBuy.*
cs_re:yellow:^Direction:\s+\d+
cs_re:white,red:Rate limit exceeded
cs_re:white,red:Not enough BTC
cs_re:red:iInvalid nonce\!*
cs_re:red:ESOCKETTIMEDOUT\!*
cs_re:red:returned error\!*
cs_re:red:Error\!*
cs_re:red:.*failed.*
cs_re:red:.*no altcoins.*
cs_re:red:statusCode (.*)
cs_re:magenta:.*buy.*
cs_re:cyan:Open orders
cs_re:cyan:.*sell.*
cs_re:red:falls\syes
cs_re:green:grows\syes
cs_re:green:falls\sno
cs_re:yellow:Has order:.*
cs_re:yellow:.*have altcoins.*
cs_re:white:\:\:.*



Cointracking affiliate link (10% discount for you) https://cointracking.info?ref=C937652

Offline Xaos

  • Rookie
  • *
  • Posts: 14
    • View Profile

Offline cw

  • Rookie
  • *
  • Banned!
  • Posts: 57
    • View Profile
    • Gunbot University
Re: Cryptowally's gunbot linux console, Part I
« Reply #7 on: May 26, 2017, 07:59:57 PM »
by the way, here are my latest versions... it helps colorize some of the items and clean up better.  Also, it alerts you of issues like Waiting for orders: 0 and things you need to fix.

Oooh, and a script that shows the latest trades of buys and sells... straight from the trades file.. in the local timezone

2017/05/26 10:00:34 buy 86.5056903114187 PIVX for 0.000578 BTC
2017/05/26 10:20:20 buy 602.4101385542169 SNGLS for 0.000083 BTC
2017/05/26 10:27:24 sell 86.50569031 BTC-PIVX for 0.00061245
2017/05/26 12:11:29 sell 39.95670799 BTC-STRAT for 0.00133799
2017/05/26 13:35:20 buy 82.64512809917356 PIVX for 0.000605 BTC
2017/05/26 13:41:24 buy 38.217157876835365 STRAT for 0.00130833 BTC

Here are the files you need

put the following into a file named "latesttrades-gb.sh"

Code: [Select]
#!/bin/sh

cat *trades.txt | sort | sed 's/\*\*\* MARKET CALLBACK | //' | tail -10


Here's the updated multitail.conf file:

Code: [Select]
#include:/etc/multitail.conf
#check_mail:0
colorscheme:gunbot
cs_re:red,magenta:< prBuy
cs_re:red,white:<= prBuy
cs_re:red,white:>= prSell
cs_re:red,yellow:> prSell
cs_re:yellow:.*< prSell.*
cs_re:red,yellow:Sell order placed
cs_re:red,yellow:.*ORDER INFORMATION.*
cs_re:red,yellow:.*profit.*
cs_re:white:.*MinPriceToSell.*
cs_re:white:.*MaxPriceToBuy.*
cs_re:white:.*MaxPriceToSell.*
cs_re:white:.*MinPriceToBuy.*
cs_re:yellow:^Direction:\s+\d+
cs_re:white,red:Rate limit exceeded
cs_re:white,red:Not enough BTC
cs_re:white,red:Waiting for orders: 0
cs_re:cyan:Waiting for orders: (\S+) (\S+)
cs_re:red:iInvalid nonce\!*
cs_re:red:ESOCKETTIMEDOUT\!*
cs_re:red:returned error\!*
cs_re:red:Error\!*
cs_re:red:.*failed.*
cs_re:red:.*no altcoins.*
cs_re:red:statusCode (.*)
cs_re:magenta:.*buy.*
cs_re:cyan:Open orders
cs_re:cyan:.*sell.*
cs_re:red:falls\syes
cs_re:green:grows\syes
cs_re:green:falls\sno
cs_re:yellow:Has order:.*
cs_re:yellow:.*have altcoins.*
cs_re:white:\:\:.*

And here's the updated stat.sh:

Code: [Select]
#!/bin/sh


multitail -Z red,black,inverse --config multitail.conf -CS gunbot -x "%m %u@%h %f (%t) [%l]" -b 4 -s 2 -m 0 -n 100 \
   --mark-interval 200 \
        -Ev "before to buy" \
        -Ev "Cannot sell" \
        -Ev "price to buy" \
        -Ev "MaxPriceToBuy" \
        -Ev "Open orders" \
        -Ev "have altcoins" \
        -Ev "Last price <=" \
        -Ev "Last price >=" \
        -Ev "Last price >" \
        -Ev "Last price >" \
        -Ev "price  grows \(" \
        -Ev "price  falls \(" \
        -Ev "^need " \
        -Ev "^Callback:" \
        -Ev "no altcoins" \
        -Ev "Altcoin Balance" \
        -Ev "\+\+\+"\
        -Ev "\[\]"\
        -Ev "-------" \
        -Ev "is too high" \
        -Ev "price is too low" \
        -Ev "price too high" \
        -Ev "waiting to sell" \
        -Ev "Creating market client" \
        -Ev "Loading config" \
        -Ev "Not supergun:" \
        -Ev "Supergun: " \
        -Ev "avCoins" \
        -Ev "CANCEL sell orders" \
        -Ev "CANCEL buy orders" \
        -Ev "SEll on start" \
        -Ev "^$" \
        -Ev "^\s+\d+\.\d+$" \
        -Ev "No order" \
        -Ev ":::" \
        -Ev "Error\!\!\! statusCode 422" \
        -Ev "Will repeat" \
        -Ev "cycle" \
        -Ev "No basePrice" \
        -Ev "need_" \
        -Ev "Response:" \
        -Ev "Bot responsed" \
        -Ev "next delay" \
        -Ev "^\*" \
        -Ev "\*\*" \
        .*/*-console.log \
   -ts -c- -Rc 10 -l "./latesttrades-gb.sh "

As before, just run it with "./stat.sh" to get a colorful status page of the status files.  Note that it might take a couple seconds for the trades to show up.


Cointracking affiliate link (10% discount for you) https://cointracking.info?ref=C937652

Offline dyvosvit

  • Rookie
  • *
  • Posts: 30
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #8 on: May 27, 2017, 07:51:57 PM »
Thank you very much, CryptoWally, great tools for a linux Gunbotter!

Offline cryptico

  • Rookie
  • *
  • Posts: 7
  • GUNBOT Official Reseller
    • View Profile
    • tradewithgunbot.shop
Re: Cryptowally's gunbot linux console, Part I
« Reply #9 on: June 01, 2017, 02:57:57 PM »
Hi, nice job Cryptowally! looks fantastic...

I want to have that monitor working on my VPS, but i have this problem:
Quote
The following problem occured:
-----------------------------
line 35 of file 'multitail.conf' is too long!
Terminated
TradewithGunbot.shop | GUNBOT Official Reseller

Offline dextro

  • Rookie
  • *
  • Posts: 2
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #10 on: December 23, 2017, 06:40:33 AM »
Such great inspiration Cryptowally!  Thanks for sharing and thanks as well as to AlfonseX for the tips on 'unbuffer' and 'multitail -cT ANSI'.

I'd love to see where you got with the "better console" idea.  Definitely a direction I'm curious in going.

For now I'm enjoying multitail.  I've made the following adjustments to your process:

1) In multitail.conf I use 'follow_filename:yes' to have it continue after a log rotation.  I've also been playing with the 'filterscheme', 'rule', and 'usefilterscheme' options to control the input, instead of the command line options.  The changes look like this:

Code: [Select]
# follow filename instead of descriptor?
follow_filename:yes

Code: [Select]
filterscheme:gunbot-filter:description
rule:ev:"before to buy"
...
rule:ev:"next delay"

usefilterscheme:gunbot-filter:out.log


2) I added the 'copytruncate' option to my 'logrotate.d/gunbot' file.  That allows 'tee -a out.log' to continue writing to the file without restarting.


Offline sarog

  • Rookie
  • *
  • Posts: 4
    • View Profile
Re: Cryptowally's gunbot linux console, Part I
« Reply #11 on: February 09, 2018, 01:43:32 PM »
I very much like your Future Idea #1: better console.
Is there a beta test version for Gunbot v8.0.3?

I am searching for a better and more clear logging method.

Any ideas?