GunnarPDX

GunnarPDX

I don’t think we should make things too dependant on any particular DB, it would be nice to make the backtesting/ohlc parts of the project modular so that you can just pass in the data and get results with whatever DB setup.

Also, not to add to the DB confusion :slight_smile: , but it looks like Redis could be another good choice https://redislabs.com/blog/unlocking-timeseries-data-redis/.

1
Post #21
rm-rf-etc

rm-rf-etc OP

@LostKobrakai looks very cool, but also looks like someone will have to write a NIF for this (probably over my head for now).

@GunnarPDX in principle I agree, but when I attempt to abstract away from the database, I start to see my progress slowing. I looked to see if I can simply use Ecto and back it with SQLite for my own purposes, and it seems that I can… Maybe?
https://github.com/phoenixframework/phoenix/issues/3218

Making the library abstract enough to use most any database is a challenge that I’m kind of short on ideas for.

I decided to push on ahead with sqlite. Depo has been very straightforward to use. I wrote some functions tonight to seed my DB from polygon:
https://github.com/rm-rf-etc/seeder

And I discovered that jupyter notebook works with elixir! So I am working towards backtesting in JN with SQLite.
https://github.com/pprzetacznik/IElixir

@GunnarPDX I’m sorry, I still haven’t ran your support/resistance code. I will get to it. Planning on adding unit tests?

1
Post #22
GunnarPDX

GunnarPDX

@rm-rf-etc Hey, I went ahead and added a unit test as well as decimals.
https://github.com/GunnarPDX/trade-indicators
Right now it returns a list of tuples like:

[
    {:support, %{h: 208.94, l: 208.94, t: 1597657204}},
    {:resistance, %{h: 210.16, l: 209.84, t: 1597656664}}
]

I can’t remember why I opened a pr last week, I closed that and can open a new one if it’s ready. I’ll also try to mess around with the polygon seeder and JN to see how that works with the S/R levels.

1
Post #23
rm-rf-etc

rm-rf-etc OP

@GunnarPDX that’s awesome, thank you.

Polygon’s data may give you some hassles. There can be holes in the data for some intervals, I posted about the issue here:

So I’m gonna try it with TD Ameritrade’s API.

0
Post #24
GunnarPDX

GunnarPDX

Oh I see what the issue is now. Yeah, that’s a tricky one… I never ran into this issue with the portfolio stuff I worked on since it was all EOD data which is pretty easy to come by. I’m going to try out a company called TwelveData which looks promising.

If that doesn’t work and you can’t make a brokers API work then maybe take a look at DTN IQfeed. You would need to stream IQfeed’s data off a windows box because of their client, which is annoying, but people say good things about their reliability and their prices are reasonable.

0
Post #25
rm-rf-etc

rm-rf-etc OP

Thanks for the info, I’ll take a look.

I think Ameritrade’s historical data will work well. I haven’t yet made start_date and end_date work, since an extra calculation step will be needed for Ameritrade’s params. You can see the endpoint doc here, the issue is that params period and periodType seem to define the start and end dates (unless I’m mistaken).

But otherwise what I added is working and you can try it out.

%Seeder.Conf{
    ticker: "MSFT",
    start: %Date{year: 2018, month: 1, day: 1},
    end: %Date{year: 2020, month: 10, day: 1},
    period_size: 1,
    period_unit: :minute,
    db_root: "/your/data/path",
    api_key: "****"
}
|> Seeder.dl_to_db(:ameritrade)

https://github.com/rm-rf-etc/seeder/blob/master/lib/seeder.ex#L49-L63

0
Post #26
GunnarPDX

GunnarPDX

Nice! I haven’t tried it yet so this may not be the issue, but It looks like you aren’t supposed to provide a period/periodType if you use the startDate and endDate. Their naming is kinda weird, I’m guessing that period and periodType are for when you just want a variable number of the most recent weeks/months/years data. And frequency would be the bar interval size, eg: :minute.

1
Post #27
rm-rf-etc

rm-rf-etc OP

Migrating to ElixirTradingTools · GitHub, will push some commits after work to fix names that I changed, and redirect people from the old location to the new. @GunnarPDX, check your github for the invite :slight_smile:

1
Post #28
rm-rf-etc

rm-rf-etc OP

Checking in, since some time has passed with no updates.

I’ve been spending my time lately with TradingView, testing strategies in pinescript. This has the advantage of being very quick for prototyping.

I’ve landed on two strategies that I’m pretty sure will translate to consistent profit, and I’m switching back to elixir now to collect larger samples, refine the strategy, and produce a bot that’s ready to run:

  • opening range breakout
  • trend following

Here’s a helpful video on building a trend following strategy.

I’ve been doing some work on the seeder repo to make the Ameritrade downloader work right (it’s in a separate branch).

2
Post #29
rm-rf-etc

rm-rf-etc OP

Here’s a client library for streaming market data. No unit tests yet, but the examples work. Supported brokers are Polygon, Binance, and Coinbase.

https://github.com/ElixirTradingTools/market_client

To get forex data from Polygon, you have to buy the entry-level tier. I tried using a free key from Alpaca but Polygon blocks those. I will update this to support stocks too. Enjoy.

2
Post #30