MiniXC / simple-back

A simple daily python backtester that works out of the box.
Mozilla Public License 2.0
59 stars 12 forks source link

crypto support #26

Open MiniXC opened 4 years ago

MiniXC commented 4 years ago

Tasks

R-K-H commented 4 years ago

To be clear here, I can buy partial shares already, the num_shares is not restricted to ints so it behaves like I would expect, that being said, it implies that you can buy partial shares if someone was to use this for traditional markets.

MiniXC commented 4 years ago

Thanks for pointing that out, the backtester will fail though when you specify a percentage to buy and one share is more costly than said percentage. I'll have to make this behaviour consistent.

R-K-H commented 4 years ago

Free no API key:

Free, but requiring an API key:

MiniXC commented 4 years ago

Looked a bit more into it and would say that for crypto, the current open/close setup really doesn't make sense. We would need to add something like .interval('1m') instead of .calendar. It's definitely doable, the backtester uses a list of datetimes with the correct open/close times already so it wouldn't be a complete overhaul. I don't have the resources to work on this at the moment though - any help/pull request is appreciated.

R-K-H commented 4 years ago

Well exchanges have Kline/Candlestick data with OHLCV data so assuming you adjust the frequency or just respect the frequency of the dataset, would you be able to use that in place or is it hard coded for the specific interval vs just the open and close on date time.

https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data

One of the better ways to do backtesting is through orderbooks or at the very least trade data (which can be fetched through most exchanges, but it complicates things).

However without making this crypto specific, perhaps candlestick data formatted at whatever interval should work?

MiniXC commented 4 years ago

One of the better ways to do backtesting is through orderbooks or at the very least trade data (which can be fetched through most exchanges, but it complicates things).

As interesting as it would be, my focus for simple-back was to make something working with freely available data and for strategies with longer time horizons (I think if you don't work for a hedge fund/bank you only have a chance with alternative data over longer timespans).

Well exchanges have Kline/Candlestick data with OHLCV data so assuming you adjust the frequency or just respect the frequency of the dataset, would you be able to use that in place or is it hard coded for the specific interval vs just the open and close on date time. https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data

I had a quick look over the apis you linked before, but didn't come across this. Thanks for linking it. I can use this to build a DailyPriceProvider with binance as a data source. I won't get to it to soon though unfortunatly, I'm currently working on adding other features I experimented with in notebooks. If you want to tackle this @R-K-H a good starting point would be YahooFinanceProvider

R-K-H commented 4 years ago

As interesting as it would be, my focus for simple-back was to make something working with freely available data and for strategies with longer time horizons (I think if you don't work for a hedge fund/bank you only have a chance with alternative data over longer timespans).

Completely understand and agree with you, just wanted to further the ideation for posterity.

I had a quick look over the apis you linked before, but didn't come across this. Thanks for linking it. I can use this to build a DailyPriceProvider with binance as a data source. I won't get to it to soon though unfortunatly, I'm currently working on adding other features I experimented with in notebooks. If you want to tackle this @R-K-H a good starting point would be YahooFinanceProvider

Sure thing, I've been using your stuff to test some things out (why I posted in the first place). I'll see what I can do to clean it up and issue a PR. Don't expect anything soon though. Happy to help if I can.

MiniXC commented 4 years ago

Thanks, I will post here should I get to it sooner than expected.