Post
Topic
Board Project Development
Re: [ANN] MarginBot - A Bitfinex Margin Lending Management Bot
by
BeastOfBodmin
on 03/09/2017, 18:15:00 UTC
Ok, its ready!  MarginBot v0.1.07 is now live on github!  Full Crypto Margin lending!  Currently it supports all currencies that Bitfinex supports for margin.
For a few weeks now, my marginbot setup has not been picking up account history, nor unused funding, but the cron job runs were being added to the BFXLendBot_CronRuns table.

I spent some time on it yesterday, and didn't get any ideas as to what might be wrong. Not least because my php binary will not execute a .php file.

But the problem shows up as a lack of history on http://.../marginbot/index.php

and a lack of entries in the table BFXLendBot_Tracking. The last entry was 2017-08-19.

So I noticed this morning 1.07b was available on the master branch.

I followed the update instructions, and the following occurred:

A new table BFXLendBot_CurPairs is created, and the 4 existing tables are backed up to copies with the suffix _BACKUP_v17

But I get this error on the screen http://.../marginbot/update.php?doUpdate=2

Quote
THERE HAS BEEN A DATABASE ERROR
Please Contact Support If this error persists.
1264 - Out of range value for column 'dep_balance' at row 7

I am using

5.7.16
MySQL Community Server (GPL)


Poking around the MySQL tables, it seems the table definitions are still the same: decimal(12,2). But I can see some ALTER TABLE statements in update.php, that switch to decimal(12,8).
When I paste the ALTER TABLE for the Tracking table into MySQLWorkbench it thinks there is a syntax error in both MODIFY COLUMN parts of the SQL statement.

Code:
ALTER TABLE `BFXLendBot_Tracking`
ADD COLUMN `trans_cur`  varchar(10) NULL AFTER `user_id`,
MODIFY COLUMN `dep_balance`  decimal(12,8) NULL DEFAULT NULL AFTER `date`,
MODIFY COLUMN `swap_payment`  decimal(12,8) NULL DEFAULT NULL AFTER `dep_balance`,
DROP INDEX `uniquieKeys` ,
ADD UNIQUE INDEX `uniquieKeys` (`user_id`, `trans_id`, `trans_cur`) USING BTREE;

Code:
CREATE TABLE `BFXLendBot_Tracking` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `user_id` smallint(4) DEFAULT NULL,
  `trans_id` int(12) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `dep_balance` decimal(12,2) DEFAULT NULL,
  `swap_payment` decimal(12,2) DEFAULT NULL,
  `average_return` decimal(8,6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniquieKeys` (`user_id`,`trans_id`)
) ENGINE=MyISAM AUTO_INCREMENT=171 DEFAULT CHARSET=latin1;

CREATE TABLE `BFXLendBot_Tracking_BACKUP_v17` (
  `id` int(12) NOT NULL AUTO_INCREMENT,
  `user_id` smallint(4) DEFAULT NULL,
  `trans_id` int(12) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `dep_balance` decimal(12,2) DEFAULT NULL,
  `swap_payment` decimal(12,2) DEFAULT NULL,
  `average_return` decimal(8,6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniquieKeys` (`user_id`,`trans_id`)
) ENGINE=MyISAM AUTO_INCREMENT=171 DEFAULT CHARSET=latin1;

I am also wondering it it makes more sense to use decimal(16,8), as that way you can still support numbers up to 999,999,999. decimal(12,8) only goes up to 9,999.