Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: GoCryptoTrader Backtester (thrasher-corp#622)
* Backtester: event handler completed, basic back tester support is working * Backtester: support for ticker data added, general code clean up, start of risk & size manageR * Backtester: WIP * Me: I am going to write tests and comment as I go this time, also me: doesn't write any tests or comments as i go * Backtester: work on orderbook system to track orders, increased test coverage * Backtester: further test coverage, output json, start of js chart output * Backtester: test coverage, output strat name * Backtester: WIP * WIP backtest charts * WIP on template * Backtester: further test coverage added * Backtester: WIP * backtester: attempting easier to read template for backtesting output * comments, and tests * Backtester: end of day WIP started work on risk management for handling leveraged positions * Backtester: WIP * Backtester: started heavy documentation phase for handover * Backtester: started heavy documentation phase for handover * Backtester: further comments, also work on making chart solution modular to allow for usage outside backtester (e.g OHCLV data) * Backtester: CHART LIBRARY * Backtester: move backtester over to new chart library * Backtester: removed old chart templates, template updates * Chart: add advancedintervaldata, convert from stats -> chart * Chart: gctscript hookup to generate chart from OHLCV data * Chart: reworked template to load from generated data if no template path is set * chart: template wip * correclty generate backtester readme, readme generation for charts, chart data generation * Removed old read file methods * Removed chart library from backtest as its now standalone * Remove reference to unfinish TA code. Removes value calculation from order signal. It belongs with portfolio signal * regen * Re-jiggles everything around to not have import cycle issues and makes it look like a normal application * End of day commit creates a new function to setup a backtester from a settings struct. Doesn't work though lol * Builds up more backtest work to allow to be run from the command line * Regen RPC * End of day mind mine field of RSI calculation5 * Finishes basic main.go application * Minor updates while theorising * Rearranging things like the size and data types. Adds portfolio setup like a normal human. Allows positions to be decimal based since this is for CRYPTOCURRENCIES :o * Moves code around to related positions. Adds compatibility to ordermanager to handle order submission. Fails to do things * End of day commit. Adding config based loading for indiviual strats. Attempting to allow for multiple cps per strategy as well as loading fees * End of day commit. Expanding config definition and loading implementation. Attempting to setup backtester wide multi currency support in a strategy. * Moves risk, attempts to revert multi currency, but also supports more in depth multi currency for later...... in the portfolio * End of day commit for realsies. Updates the strat and sets the invalid backtester * No more panics. Finishes config loading. Renames buyandhold to dollarcostaverage * Extends strategy to include a reason why its performing an action. Adds 420blazeit.strat. Expands statistics output. Moves folders around some more. Reduces amount of processing when "DO NOTHING" is the direction * Commit before home time. Looks to expand the order manager to cater to the backtester. Fleshes out risk manager to think about leverage and holdings in other currencies * Some basic expanding of strategy definitions. Changes weird package naming. * Expands size and risk validations. Expands config settings for the validation. Starts looking at loading from live data source * Merge branch 'master' into backscratcher * Work towards having backtester load data * Adds support and tests for all data source loading except for LIVE * Some basic additions looking to append to data streams instead of load all at once, for the purpose of live data analysis * End of day commit where I broke functions * Adds live backtesting * Adds FANCY MATHS to correctly size orders before slippage. Rearranges minmaxing in config and strats * Prints out initial settings. Creates a lame slippage calculator. Ensures that order price/amounts respect OHLCV data. Adds customisable config variables that can influence a strategy * Fixes minor issues with rendering. Fixes portfolio buying and selling now * ALL OVER THE PLACE END OF DAY COMMIT! In order to expand stats, thing must be tracked appropriately, which they arent. Here we add the addition of a compliance.go to track orders specifically. This will allow for the holdings manager to keep track of base stats such as how much we hold versus whats in use along with profits Compliance holds snapshots of every tick and what orders were there across exchanges. Also added a random slippage calculator which will allow a user to set their own slippage rates * Another fun end of day commit where nothing works. In order to have accurate stats, you need accurate positions, to have accurate positions you need to break things down to individual levels and store them. This is part of that process of ensuring that we can have multiple settings and everything processed appropriately. * Finalises multi currency config and support at most levels with exception to data loading. Simplifies some struct property definitions by removing redundancy Allows tracking of entire portfolio snapshots after each interval to track the entire process Lowercases use of exchange names * Sets the different prices to track across time. Attempts to sort out compliance snapshots * end of day commit. Moving compliance to the portfolio to manager and track all transactions at each interval. * Moves compliance calculation to portfolio.go. Adds a nice little decorator on the compliance manager orders to keep track of slippage, cost basis, volume adjusted price and close price. Moves "positions" to "hodlings" to be more accurate. Ensures exchange value calculations are accurate. Begins looking at Statistics and hodlings * Moves statistics to eventhandlers. Removes ticker work as not needed. Redefines hodler properties * hodlings are actually part of the portfolio * Renamed 420blazeit.strat file. Renamed hodlings to holdings. Moved Datahandler to data_types.go. Expanded holdings calculations, doesn't work, but we're getting somewhere. Renamed bad var names in backtest.go. Added new order side types to highlight lack of action reasons * Adds tests for holdings to ensure that holding snapshot calculation is accurate for the length of a strategy. Removes portfolio.Funds because its now handled via the holdings snapshots. Adds helper functions to Holding snapshots to retrieve relevant holdings. Updates sizing calculation to properly handle sell events. Expands holdings definitions to allow for comparison. Expands risk calculations to include holding snapshots so as to analyse all positions simultaneously * Changing the statistics results to consider all datas, with the ultimate goal to replace the current statistics package with this multi currency output * Made "Why" more generic. Expands statistics output. Removes time tying to stats map. Moves order event to correct location. Removes some debug lines. * Adds some raw funky drawdown statistics 🎉 * End of day commit. experimentation leaves little code changes * An attempt at expanding statistics. Need to have ones dedicated to exchange, asset, pair. Early work for having global map to track all the asset things to minimise all the maps throughout the application * 🎉 ADDS MULTI CURRENCY SUPPORT TO FOR THE BACKTESTER 🎉 Can either execute strategies by assessing multiple currencies individually, or as a group and make strategic decisions on what currency to signal in. Adds new strat files to demonstrate * End of day shenanigans. Moving codes around, making more fun stats. Expanding DCA strat to check if DCA is better than the market longer term * Adds sharpe ratio and total stats for final output if more than one currency is considered * Adds sortino ratio and test for validation * Adds information ratio * Adds calmar ratio * Adds CAGR * Slims down the statistics file to only include my work. Updates everything to use interfaces rather than direct code references to make it easier to swap out codes. Begins looking at serialising statistics for reports * More neatening. Removal of old FAKE tests. Can now output a report in JSON * End of day commit. Creation of reporting. Uses tradingview charting library and some basic bootstrap CDN to render content nicely. Will be updating everything to have a special kline item to annotate chart results * Minor formatting changes before all the reviews * End of day commit. Expands reporting to have an enhanced candle. These candles contain metadata on whether an order has been placed and to mark charts appropriately. This will be expanded to have all the stats and make it pretty * Extra code I forgot to commit! * Fixes an issue where data cannot render above 1,100 candles by stopping it from rendering more than that.. * End of day commit. There is no inclusivity with candle requests and I cant figure it out right now. * Fixes issue with missing data by adding events when data isnt present and classifying it. Adds new way for klines to verify data with a bit more clarity * Completes report generation * Improves cagr. removes butts. Replaces old kline function with new supercalc * Adds readme templates and files across whole backtester. Renames 420rsi to more appropriate name. Moves interfaces to common * Some extra documentation * New header * Adds some nice coverage to backtest.go. Updats readmes to use new backtester header template * End of day crappy test commit * Adds report coverage... Somewhat. Adds template path and output path to allow custom properties and easier testing. Fixes interface duplication * Adds some lame tests. * Fixes test * Adds coverage to the exchange event handler * Minor test changes * Fixes slippage calculations based on buying and selling. Adds more tests to compliance and holdings * Rejiggles risk assessment to properly consider leverage if it were ever to be implemented fully. Removes bot dependency and adds coverage to the risk package * Expands coverage to sizing * Rejiggles code to add coverage for the portfolio package and its compatriots. * Adds additional testing to the backtester along with some data gathering tests * Tried and failed attempt to expand testing for the database. * Adds testing for kline, data, statistics * into the 70%s of coverage! Adds tests for base, DCA, statistics * Adds test coverage of strategies * Adds test coerage to statistics. updates template generation to not require CurrencyStatistics to have EAP. Removes EAP from currencystatistics * Adds coverage to currencystatistics.go BUT ITS NOT COMPLETE * 86% coverage wow. Fixes 2 tests * Fixes data races due to engine dependency craziness. Changes order manager to not have a global dependency * Completes currencystatistics test coverage * Some linting fixes * Adds new documentation to the bakctester config. Updates how risk leverage/ratios work with a single map. * Minor documentation changes. Its difficult to describe how it all works * Redefines strats and strat tests. Adds some really light documentation * Updates some basic documentation. * Fixes lazy bugs * Fixes bug in fill event processing. Fixes bug in statistics crashing. Fixes report generation. Fixes multi-currency processing to still process non-errored signals * More documentation. * Fixes ALL LINTING ISSUES * Cuts off unnecessary limbs/interface functions. linting. Adding comments to all functions. Adding ability to use whalebomb to calculate slippage for live orders. Adds testing for it too. Simplifies adding events to statistics. * Removes a weird overlap of holding features that made no sense and the writer of those functions should be ASHAMED. Adds additional documentation * Fixes issue with data being outside ranges. Adds some extra validation to areas where people can mess around. Makes generating configs easier with consistent dates. Adds more documentation. Cleans up okex/okcoin implementation to some functions since people aren't understanding that they share a based okgroup and that anything that is the same between two functions only needs to be written once...................... Also fixes some bad gct script code * Updated image and slight change to readme * Removes unused code. Fixes up verbose and removes old comment * Fixes issues with data validation for other data sources. Fixes bad reference in template * Fixes missing data problem for last candle considered missing. Fixes issue where fill order crashes when sizing error occurs. Adds documentation * Fixes issue with drawdown calculations. Fixes live data usage * Adds some comments for good measure * Default strat fix * Fixes surprise linting issues * gofmt * New linting issue with every commit * Fixes testing. Adds new config setting to set a custom gocryptotrader config path. Updates config tests to use dryrun. Results now include the nickname in the file for easier identification * Fixes live testing bitstamp. Fixes some template issues. Adds comments. * Updates max drawdown calculation to go peak vs trough. Fixes minor return issue. Removes unnecessary Data implementations. Removes weird verbose false. Fixes holdings calculations for boughtvalue. Removes Swingholder and just uses Swing. Fixes time calculation issue in kline * End of day commit that breaks things. Fixes issue with documentation generation only going one space deep. Adds exchange name to warnings of missing candle data. Renames missing candle data function. Adds some testing to kline functions. Adds new ability to size modified orders to portfolio allowance. Addresses defer close and other small nits. Fixes slow loop * End of day commit. There are too many mini changes to list. DateType to int. Default switch case. Returning earlier. Nil returns instead of ok. High low price in data, now used in max drop down. Missing data shown in the report. * End of day commit moving things from stats to maths. * Move the rest to math package and add testing * Ammends slippage calculations for live. Adds sizing funds to order event. Improves CAGR calculation * Mini fix commit for test * End of day mini change for documentation * Fixes in documentation and expanded error messages. Pretties up the report * minor adjustments to sharpe ratio and other ratio calculations * Fixes test by taking it out back. linting * Fixes tests * Fixes some tests, addresses some poor nits * More test and lint fixes * Fixes binance translation issue * Further craziness into reducing the concurrent test issues * lint * Mini fix * Geometric average added and tested. Adjusts application to support it. End of day experiementation with negative geometric mean. Fixes typo in currencystatistics package name * Fixes geometric calculation. Adds sweet CMD logo * fixes geometric mean 😆 can now disable logo output if you hate everything good in life * lint * Should fix test in appveyor by not being nil * Fixes chance of getting no trades error. Maybe making nil events in the test will stop this poorly formed appveyor error * Forgotten Y tail * Check-ch-check-check-check-ch-check it out, minimising stutter is what its all about... Also provides more verbose error messages * de-ooopsies the whoopsie * Attempts to further address race issues when using global logs during start stop process * Includes a copy of the logger itself when logging so that no log.Debug action can create a data race upon being changed globally * Reduces bot usage further * Removes sharpie from b-acktester * comments, renames and bears, oh my! * Fixes git merge issues/tests. Splits average calculation into their own functions. Clarifies math function and sell position comments. Removes taker fee from final report. Adds warning when maker and taker aren't appropriately set. Fixes config testing issue where the config was saved when running exchange_template tests. Adds new test to ensure the testconfig isn't changed unnecessarily * More why to reason * Remove test due to hash discrepancy. * Updates maths to use errors. Updates tests to support it. * Fixes error handling for some packages. Uses position value instead of position size. Fixes leverage ratio work. Removes extra binance windows * Removes references to "multi currency" to shiny new verbiage "simultaneous processing" * Fixes issue with extra data be appended and then declared missing * Removes redundant code via code removal * Does a larger transition to using error types. Addresses math related nits * eat a mint while you lint * Completes err definition sweep * replaces over 80 instances of the same typo! * Renames more properties with Maximum ratios. Adds examples to config readme. Updates config maker takers. Adds cool kline error * Adds 'InclusiveEndDate' config property to API and Database datas. Adds testing for it. Updates readme for it * splint * Minor naming fix. Minor drawdown fix. Attempts to lower the bot usage when heaps of candles are requested. * Large data set processing improvements * Speeds up backtesting processing. Ensures rate limits are set Processing of most events is done in a linear fashion. So functions that relied on checking an events time for example, will now check the latest before processing every interval. The functions will still work normally in the event that someone wishes to use them out of order, but for general backtesting, it greatly speeds up all processing. Further, rather than comparing times all the time, I've introduced offsets for comparisons of ints for events and with candle data tests * Fixes build issue * Adds committed funds stat. Adds config goal Committed funds are calculated as the total amount of money currently in position It allows for a strategist to get the maximum returns for the smallest funds The goal function is to allow a strategist to set a goal description * Fixes data race * Adds unfinished config builder application * End of day broken commit I focussed on too many things at once and there are many things left to resolve * Fixees panics * Finishes config builder * Fixes order manager start/stop. Improves config manager * Fixes writefile reference * Adds some extra readme * Makes a more user friendly config builder. Fixes initial nil. Adds more order size reasons * lint * Adds warnings for when data is missing and ratios will be skewed * bodMISSED bodmas * Does not consider initial entry in performance calculations Adds strategy description field Adds cost basis to chart Fixes time rendering on default configs * Fixes bug in ratio calculations * saveConfig := !(!false != !true) == true * lint * Fixes start end single day drawdowns. Expands cmd drawdown explanation * Comment on rounding, updated report rounding * Addresses readme link issues * Actually fixes readme references * Should truly solve readme links.... * Includes filename for report log * Fixes panics, reduces csv trade candle size, no more science * Removes more science * test123 * Adds extra config validation * Fixes the date validation * Shows smaller fees * Changes perfectly cromulent error message to start >= end Co-authored-by: Andrew Jackson <[email protected]>
- Loading branch information