This will take some time I think, so please disregard this post until the (WIP) is removed from the title. Thanks!This post will be my attempt to get some visual documentation and explanations of the various strategies gunbot uses, as well as some more verbose descriptions of the config files. If ANYONE catches something said herein that is false, please reply and let me know. It takes a village and all that.... Let's get started!
I will attempt to keep this thing somewhat readable, there's a lot to cover, and much I don't know. This started with just wanting to make a verbose line for all the existing config comments, and has ballooned into something much more considering how often some questions get asked and assumptions of knowledge from existing users when trying to talk to newcomers. I had a decent amount of frustration getting details of the various parameters when I first joined up. Let's mitigate that a bit for future users.
Gunbot as of right now employs 4 different strategies.
- BB - Bollinger Band
- GAIN - Stepgain (explained later)
- 1000 Trades - Ping Pong EMA
- Supergun - Old Russian Roulette (confusing name, not to be confused with the supergun watchdog algo)
Bollinger Bands:This is a well known indicator used in many other markets besides altcoins, of course. It is a method that attempts to visually represent the range of prices a security could hit on either extreme. It is calculated using standard deviation and SMA (simple moving average). It's a good way to visually see volatility in a security. (Gunbot likes volatility)
https://www.tradingview.com/wiki/Bollinger_Bands_(BB)Now, actual strategies on using this particular indicator are beyond the scope of this document. However, let's make some basic assumptions so that the way it is configured with the bot and expected behaviors can be explained.
Let's assume you want to buy at the lower portion of the inside of the bands, and sell when a price climbs to the upper portion of inside the bands. The configuration file has these lines to set that:
LOW_BB: 10,
HIGH_BB: 10,
SELL_STRATEGY: 'BB',
BUY_STRATEGY: 'BB',
This is showing what your settings would then be trying to do. Please note that the overlays in that image are not to scale. We are dealing with percentages, so when the bands tighten up, so does the colored line I drew. This is more of a concept than an attempt to use hard numbers. The entire width of the inside of the bands will be 100%. The HIGH value measures as a % from the top of the band going down, and the LOW measures as a percentage on the inside going up. Also notice that gunbot uses a signed int for the integer variable, so will indeed accept a negative value. You can see the effect of that in the image, as it will start going negative as you leave the confines of the band.
OK, so you see how that works. For this to be effective though, you really need to have a lot of prices to calculate the deviations. The default of 300 prices is a suggestion, but of course you can go higher than this.
This next bit is fairly important for you to understand, as it relates to many other things gunbot does and the logic it follows.When gunbot makes a call to the exchange, it is pulling whatever the newest price is at it existed on the books at that time. It logs this in memory and in the logs. How accurate this data is will be highly dependent on how often you are asking for the pricing data. It can and does collect data via PUSH notification via the public API, but this isn't enough.
Poloniex, Kraken, Bittrex, etc do not send any data as it relates to EMA, BB, etc. Meaning, it can't call and say "Give me the BB data for this pair, in this time frame, kthx." It is because of this fact that it has to collect the data itself in order to make it's own formula calculations.
Bot sleep delay really means "I will ask the exchange for a price every N seconds and wait that long before trying again."
MAX_LATEST_PRICES: 300
is where you would set how many prices you want the bot to store before switching to Bollinger Band trading. This is a sliding window, meaning it will ONLY be looking at the last N number of prices when making decisions.
It has a save state, to allow for a bot to restart and not have to collect a complete set of data again. Gunbot will perform best if you allow it to always be seeing a complete set of pricing data so as not to throw off your standard deviation numbers.
POLONIEX_VWA_1_INTERVAL: 0.02,
POLONIEX_VWA_2_INTERVAL: 0.04,
These are weighted variables, using EMA1 and EMA2, adjusted according to volume.
Poloniex can calculate the BB using all the available data on the books, and gunbot can only do it's best with the prices it has retrieved. This is why you CANNOT simply look at the Poloniex bands and see your bot didn't buy where you think it should have, because there will be a discrepancy there. The bands will change if you change the candles you are looking at, but not if you change the range of time.
You *need* to set the candlesticks on Poloniex (or other exchange) to match the PERIOD you have set in your configs to have any hope of comparison without creating your own charts from the bot log data!This candle range will be set with
PERIOD: 15, // candlestick period
I believe that is the same across the configs, as far as the naming used there.
Ok, well let's see if I can manage to annotate the BB-XXX_YYY-config.js file with lots of comments, and let Gunthar tell me all the ways I'm wrong. Fun!
var config = {
DEFAULT_MARKET_NAME:'poloniex', // Self explanatory, I think he uses this in case some other parameter isn't passed, not sure though
DEFAULT_CURRENCY_PAIR:'BTC_PIVX', // ^^^^^ same
BTC_TRADING_LIMIT:0.01, // This is the maximum amount of currency that gunbot will be allowed to use to trade with. In the BB strategy, I believe this is all used in one trade.
SECURITY_MARGIN: 60, // This is a percentage you set to tell the bot when you've raised the white flag and you are ready to surrender. If the price of the security you bought drops this number as a percentage from the price you bought, an immediate sell is issued.
MIN_VOLUME_TO_BUY: 0.0005, // This is pretty much if you don't like to see those small bags collecting in your portfolio. Set this to an amount that is the minimum you want to buy.
LOW_BB: 5, // Low end of the BB band, as a % measure up from the bottom band
HIGH_BB: 5, // High end of the BB band, as a % measure down from the top band
SELL_STRATEGY: 'BB', // You can mix and match strategies here, BB or GAIN
BUY_STRATEGY: 'BB', // You can mix and match strategies here, BB or GAIN
BUY_LEVEL: 0.1, // this is the buy level used in GAIN, it's here in the BB because it will be used until enough prices have been collected to start BB
BITTREX_KEY: '', // API KEY
BITTREX_SECRET: '', // API SECRET
BITTREX_GAIN: 2, // This number is a percentage where gunbot will sell after the purchase
BITTREX_PRICE_METHOD: 'vWP', // yeah, no clue. This follows his variable naming, so some thing needed in relation to how the API data gets pulled differently from each exchange
BITTREX_VWA_1_INTERVAL: 10, // Time interval as Bittrex is concerned. I don't know, but I would assume this is close to the .02 from polo
BITTREX_VWA_2_INTERVAL: 120, // Time interval as Bittrex is concerned. I don't know, but I would assume this is close to the .02 from polo
KRAKEN_ASSET_PAIR: 'XETHXXBT',
KRAKEN_KEY: '',
KRAKEN_SECRET: '',
KRAKEN_GAIN: 2,
KRAKEN_PRICE_METHOD: 'vWP',
KRAKEN_VWA_1_INTERVAL: 1,
KRAKEN_VWA_2_INTERVAL: 15,
POLONIEX_KEY: '', // API KEY
POLONIEX_SECRET: '', API SECRET
GAIN: 2, // this is the buy level used in GAIN, it's here in the BB because it will be used until enough prices have been collected to start BB. It is also used in a situations where your best bet is to take the gain, due to what supergun is currently seeing.
POLONIEX_PRICE_METHOD: 'ohlc', // yeah, no clue. This follows his variable naming, so some thing needed in relation to how the API data gets pulled differently from each exchange
POLONIEX_VWA_1_INTERVAL: 0.02, // ema1 + volume period
POLONIEX_VWA_2_INTERVAL: 0.04, // ema2 + volume period
SELL_ON_START: false, // sell all your inventory when bot starts
CANCEL_SELL_ORDERS_ON_START: false, // cancel all your sell orders when bot starts
CANCEL_BUY_ORDERS_ON_START: true, // cancel all buys when bot starts
CANCEL_OPEN_ORDERS_ON_START: false, // cancel any open orders when bot starts
MAX_LATEST_PRICES: 300, // how many prices the bot will store to do the deviation calculations (this should be a nice high number for BB)
MAX_LATEST_DIRECTIONS: 30, // number of prices bot will use to determine price momentum up or down (supergun watchdog)
MAX_LAST_ORDERS: 500, // number to tell bot how many order entries to store in logs
PERIOD: 15, // candlestick period (If looking at Poloniex, make sure this matches your chart on the website)
SAVEFILE_SUFFIX: '-save.json', // pretty obvious, no need to change unless you're a tweaker. :)
API_CALLS_DELAY: 777, // new variable, not sure exactly what this does. Sounds like it should be obvious, but we are making calls for prices all the time. Maybe it has something to do with a specific API call. Gunthar?
BOT_SLEEP_DELAY: (1000) * 20, // used to determine the amount of time the bot should wait between calling the API and asking for orderbook prices.
BOT_MAX_LIFETIME: 999999999, // how long should this bot run before turning off?
BOT_ON_FAIL_DELAY: (1000) * 10, // If you get an error from Poloniex, due to any issue including them getting slow, this is a delay you set to override your normal delay. This is useful to not get banned!
ALERT_ON_NO_FUNDS: false,
SMTP_EMAIL: '%40@gmail.com',
ALERT_EMAIL: '********',
SMTP_PASSWORD: '**********',
SMTP: true,
SMTP_PROTOCOL: 'SMTPS',
SMTP_HOST: 'smtp.gmail.com',
DEBUG_LOG: false,
I_REALLY_WANT_IT: false,
BUY_SMALL_PORTION: 1,
INSUFFICIENT_FUNDS_ON_SELL_FIX: 0.0005,
MAX_LATEST_PRICES_SHOWN: 0,
SHOW_LASTEST_DIRECTIONS: false,
MAX_LATEST_DIRECTIONS_SHOWN: 0,
LASTEST_DIRECTIONS_LIST_WIDTH: 0,
BTC_BALANCE: 2,
};
module.exports = config;
That's it for the BB section, I am surely wrong on some things, and missed others. I will be adding the next strategy soon, probably GAIN, as I haven't even run the 1000Trades or Russian Roulette yet!