gazbert / bxbot

A simple Bitcoin trading bot written in Java.
MIT License
825 stars 280 forks source link

Plan for back testing? #27

Closed Gondee closed 7 years ago

Gondee commented 8 years ago

What is the plan for supporting back testing?

gazbert commented 8 years ago

No plan at the moment. The primary goal of the project was about getting folks up and running on Bitcoin exchanges using Java - and for me to learn a tonne of stuff!

The main focus right now is on building a REST API/Angular UI to administer the bot - SSH'ing' onto AWS and hacking XML files sucks!

Providing a capability to support back-testing user algos is certainly something to consider in the future - feel free to start tweaking stuff.

jmlw commented 7 years ago

Do you have a recommendation on how to hook backtesting in or any ideas you've been toying with?

Gondee commented 7 years ago

@jmlw Yeah I am currently working a implementation. It is a modified exchange adapter that connects to my local MongoDB database that has REST payloads from the exchange. It passes the rest payload to the exchange adapter as if it were coming from the exchange. On checking open orders, it determines if the order would have been filled. I am doing HFT related things so its a bit more complicated but if your doing normal capital gains strategies then its not bad

gazbert commented 7 years ago

Hey @jmlw, @Gondee is already on the track I would have explored if I had the time - my day-job coding is all consuming at the mo :-(

I would look at creating a cut-down exchange adapter to 'harvest' the order book for a given exchange and dump the JSON in storage someplace - flat files or MongoDB most likely. The adapter would run in 'record' mode while doing this - I'd have a bot instance up and running for, say, a month, polling at a configured interval (e.g. every 1/4/12/24 hours), and recording the books.

To run the backtest, I'd configure the adapter to run in 'playback' mode - whenever it gets invoked by the Trading Engine (I'd set the engine poll to be 1 sec to speed it up), it would sequentially load the next 'time slice' of JSON pie from order book data collected in 'record' mode. Your trading strategy would then record any successful trades/stats and write them out someplace to be analysed offline after the test completes - there is already an Issue/Enhancement to create an analysis API for doing this...

Very crude to start with, but the whole process could eventually be automated/scripted/configured using Chef/Docker etc...

gazbert commented 7 years ago

Closing - currently no plans to add back testing.