Gab0 / japonicus

Genetic Algorithm for Gekko Trading Bot.
MIT License
284 stars 102 forks source link

New Features #94

Open donkykong017 opened 6 years ago

donkykong017 commented 6 years ago

hi. i just saw your recent update and looked a little bit through the code. is there a changelog of the features you have implemented. i am sorry but am not that good to understand everything you have changed. btw i found a typo in operations.py (https://github.com/Gab0/japonicus/commit/cd3abc5682ecd0fec53468e7b2ad4778fc6480a7) made a comment. i saw your data_span feature. thx for that. and i tried it out, but i can not seem to get eval_dataset_source to work

i tried to write 'eval_dataset_source': { "exchange": "gdax", "currency": 'BTC', "asset": 'LTC', but then it says eval dataset source not found. and Evaluation dataset is disabled. when i use "none" it will test on a dataset i dont want it to test on. so i marked it with "!" like in dataset_source. this is obviously the dataset i backtest the evolution on and its working. what dataset is therefore used to check the evaluation every 20 epochs?

    'dataset' : {

-- Gekko Dataset Settings

leave the ! on the ignored entry as convenient;

'!dataset_source': None,

dataset_source can be set to None so it searches from any source;

'dataset_source': { # in case of specifying exchange-currency-asset, rename this removing the '!', and del the original key above. "exchange": "gdax", "currency": 'BTC', "asset": 'LTC', }, '!eval_dataset_source': None,

        'eval_dataset_source': {
            "exchange": "gdax",
            "currency": 'BTC',
            "asset": 'LTC',
        },
        # span in days from the end of dataset to the beggining. Or zero.
        # (to restrain length);
        'dataset_span': 80,
        'eval_dataset_span': 80,

        },
donkykong017 commented 6 years ago

not having much clues from py i tried to look through the files and tried to find something. and so i did :) it has to do with the avoidCurrency = evolutionDataset.specifications['asset'] line in evolution_generations.py

i # the line and it now shows me in the logs that it will indeed use the same dataset for both evo and eval. i guess it is there to definitely use another secondary dataset for eval. i am just trying to understand whats the benefit of that?! if i evolve a strat on a dataset dont i want to evaluate it on the same dataset? and what happens in my initial case when the eval dataset is not found? will it fall back to a random dataset (the longest [time] available) or will it use the same as chosen for evolution?

thx cheers DK

Gab0 commented 6 years ago

Cheers @donkykong017 the failure to load your explitctly selected evaluation dataset was due to a bug. The fix will be released soon, thanks for the report. On the concept I had for this function is that the machine selects another dataset for evaluation if you leave the settings on blank. With the bug it overrides the user selection if he wants the same dataset as evolution dataset, destroying the purpose of having the eval dataset :( XDD Man, the evaluation dataset is to check if the strategy also works on general candlesticks, including the future candlesticks it will encounter in real time operation. The eval dataset backtesting does not have impact on the evolution (yet). With the bug it will never fall to the same, it should select the longest thats in another asset.

donkykong017 commented 6 years ago

cheers @Gab0 and thx for making that clear. so how do i see the eval results. am i right that this is not yet completely visible? my understanding was that the evoution dataset is for evolving, seen in every min/max... values each epoch. and the evaluation dataset is for evaluation each 20th epoch? but i get the feeling that is not right haha :D

so the evaluation dataset should be for continuous backtesting on live data from a live market watcher and could be integrated for continuous evolving of live data?

edit 1: ah man, just saw your new commits an plowing through. awesome thx

Gab0 commented 6 years ago

Eval dataset is to check if the best settings found are overfitted, only that. At the same time (yeah 20th epoches) the GA evaluates also on evolution dataset (primary), to just see the overall progress of the evolution. It may not feel right.. feel free to come with ideas or spy other GAs and see how they do it for us to copy.

donkykong017 commented 6 years ago

nice1. so thats more clear now. i will test the new update today if i have the time. thx @Gab0 . i will bring up what comes to my mind and have a look at other GAs when i have the time (pretty hard for me. everything is new for me haha :D) but the gekkoGA looks nice with the tutorial and all in the forums. thought i would have a look at that in the next days/weeks. cheers bro

donkykong017 commented 6 years ago

so i had a little look at the updates. ran a test over night. found this one typo again in (https://github.com/Gab0/japonicus/blob/master/datasetOperations.py) restainedInit = self.daterange['to'] - deltams

should be

    restrainedInit = self.daterange['to'] - deltams

;)

The new features are awesome the files @ log folder are beautiful. what i am missing is the param format that c/p directly into gekko ui like i have it in the console log, that would be super convenient. also the result folder is now obsolete.

it also would be awesome to better see what GA is doing an what dataset/timespan he evaluated in the log file. and what he does with the secondary dataset and relative results? i tested over night. took the best result and put it in gekko ui same timespan as evol and same settings and did not come to the same result. how is annual profit calculated? i used a 1 year timespan and did not come to the same result.

Edit 1: found the answer thx

@jthope thanks. Annual profit is 12 random deltaDays periods backtested in sequence. Thats good results... may even try it on real trading.

also what is skeleton exactly? is it some kind of random strat generator? cause then it should build strats with indicators, right? but the ontrend.js is a strat in that folder. i dont understand completely.

thats all for now what i found with the limited time yesterday. have to have a look at 53.2 and the --help feature (can i type that during a run? guess not just before start, right) lol so much dump questions ;S

donkykong017 commented 6 years ago

ive come around a new strat, that needs a specific warmup period. otherwise it will not work properly. in japonicus it will not trade in that case. can we have a line in Settings.py to set the required warmup period like we can in the WebUI of gekko. this would be awesome in my opinion.

also i think you are working an putting candleSize in GA calculation. this also would be a great deal.

Thx @Gab0. looking forward to whats coming in the future.

donkykong017 commented 6 years ago

@Gab0 had a few runs with the latest version. The new logs are beautiful. Though there are a few things I would change. Firstly I saw the the best results are not always sorted when i run different stratagies. How does that work exactly. Also what wonders me is that the best results in locals are always pretty good but evaluation backtests always/often fail. Why is that?

One big thing would be to resume a test that had to be stopped and reuse the generated locals and log file. Atm it always creates a new unique number for every new run.

Thx @Gab0 :muscle:

Gab0 commented 6 years ago

Hey @donkykong017, U think the thing with these 'easy' locales is that their datasets can be scored high with some overfitting, so parameters that lead to a dumb long position enter that precedes, by luck, a big price rise on those candlesticks or something like that can specialize on these accidental datasets and still do bad on general candles. This not always happen, and its ocourrence may even depend on the strategy you are testing!

In fact if we catalogate small regions on those candles that are statistically most sucetible to overfitting under a large group of strategies, in order to avoid them at evolution phase, we would be doing really NEXT LEVEL stuff xDD but ofc next level stuff are complicated to implement.

But yeah, there is a tournament to select the best individues from a group selected randomically, but I think the best is always selected regardless.

Well, loading a session is a good idea ;d maybe on next version!

Is warmup the same as requiredHistory? cheers!

donkykong017 commented 6 years ago

awesome @Gab0 thx for the clarification. so it would be better so kill these regions with confirmation from more than one strategy where it appears. this sounds pretty plausible. but one can also just statistically rule out any outlier regions when they just seem to be way out of range. this could also easy be done with more than one strat. this brings a new idea: maybe with --skeleton you could test out and identify those regions. so in other words the strat would also be way better if you test in on a dataset that is as big (timewise) as possible as it will also just test on small regions and validate on the whole dataset if it competes and works well. loading sessions would be awesome, if you could implement it. also a range of candle size, but from what i know you are working on it. but wouldn't it be quite easy to put it in Settings.py like any other parameter as a range (1, 60) in minutes?

what i learned from this bit of code from the RSIBB_ADX // warn users if( this.requiredHistory < this.settings.SMA_long ) it should be the warmup period. cause when you set this to the value of SMA.long it does not warn.

cheers man and thanks for your reply.