askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.95k forks source link

Import api not saving to history #2130

Closed bettimms closed 6 years ago

bettimms commented 6 years ago

When trying to make imports of data through api by making a post request with config, data is not saved in db (sqlite), therefore it's not showing for backtesting, even though the whole process seems to go well. In UI it shows like it's still in progress but when you click on it it shows import is done!

import_1

Clicking on BTC/NULS (in this case)

import_done
xFFFFF commented 6 years ago

One of possibilities is that candle writer is using different db adapter than paper trader. Did you change something related to db adapter in any of config files? or using original configs from gekko?

You can downloads dumps instead import from my repo : https://github.com/xFFFFF/Gekko-Datasets It's faster solution.

bettimms commented 6 years ago

I've disabled candleWriter in config in order to be able to run multiple strategies & currencies simultaneously (and avoid SQL busy exception) while I send another config as param on post request!


const baseConfig = {    
    gekkoConfig: {
        'watch': {
            'exchange': 'binance',
            'currency': 'BTC',
            'asset': 'NULS'
        },
        'paperTrader': {
            'feeMaker': 0.1,
            'feeTaker': 0.1,
            'feeUsing': 'maker',
            'slippage': 0.05,
            'simulationBalance': {
                'asset': 1,
                'currency': 100
            },
            'reportRoundtrips': true,
            'enabled': true
        },
        'tradingAdvisor': {
            'enabled': true,
            'method': 'TSI',
            'candleSize': 1,
            'historySize': 10
        },
        'TSI': {
            'short': 10,
            'long': 35,
            'thresholds': {
                'low': -25,
                'high': 25,
                'persistence': 1
            }
        },        
        'performanceAnalyzer': {
            'riskFreeReturn': 2,
            'enabled': true
        },
        importer: {
            'daterange': {
                'from': '2018-04-22T12:00:00Z',
                'to': '2018-04-23T12:00:00Z'
            }
        },
        'valid': true,
    },
    data: {
        candleProps: ['close', 'start'],
        indicatorResults: false,
        report: true,
        roundtrips: true,
        trades: false
    },
}
xFFFFF commented 6 years ago

You yourself wrote where the cause is. From what I know, the CandleWriter plugin has the task of write the candle in the database.

bettimms commented 6 years ago

I've copied the default gekko config with candleWriter:true but the issue still persists!

xFFFFF commented 6 years ago

It's wrong file. I know it from ':' character. You copied config.js when you should edit file in config/plugins folder.

Config.js file in main gekko directory is only for CLI version. Is unusable in UI

bettimms commented 6 years ago

I didn't touch files in config/plugins, shall I do any change there in any specific file?!

xFFFFF commented 6 years ago

Most important in this case is it do candle writer, trading advisor, paper trader are enabled and use sqlite. In next step check files in config and config/adapter directories.

bettimms commented 6 years ago

I've cloned e clean gekko repository locally and tested the case (I've checked config files as well), the result is the same. This is the code to simulate the case:

const baseConfig = {    
    gekkoConfig: {
        'watch': {
            'exchange': 'binance',
            'currency': 'BTC',
            'asset': 'NULS'
        },
        'paperTrader': {
            'feeMaker': 0.1,
            'feeTaker': 0.1,
            'feeUsing': 'maker',
            'slippage': 0.05,
            'simulationBalance': {
                'asset': 1,
                'currency': 100
            },
            'reportRoundtrips': true,
            'enabled': true
        },
        'tradingAdvisor': {
            'enabled': true,
            'method': 'TSI',
            'candleSize': 1,
            'historySize': 10
        },
        'TSI': {
            'short': 10,
            'long': 35,
            'thresholds': {
                'low': -25,
                'high': 25,
                'persistence': 1
            }
        },        
        'performanceAnalyzer': {
            'riskFreeReturn': 2,
            'enabled': true
        },
        importer: {
            'daterange': {
                'from': '2018-04-22T12:00:00Z',
                'to': '2018-04-23T12:00:00Z'
            }
        },
        'valid': true,
    },
    data: {
        candleProps: ['close', 'start'],
        indicatorResults: false,
        report: true,
        roundtrips: true,
        trades: false
    },
}

Then make a post request somewhere while the server in the port 3000 is running


const url = "http://localhost:3000/api/import"
axios.post(url, baseConfig.gekkoConfig).then(function (result) {
     console.log(result.data);
}).catch(function (error) {
     console.error(error);
});
askmike commented 6 years ago

Assuming this is fixed, if not please open a new issue and point to this one.