QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.83k stars 3.26k forks source link

Next Brokerage Implementation #371

Closed jaredbroad closed 6 years ago

jaredbroad commented 8 years ago

Import brokerage API for TDAmeritrade (perhaps https://github.com/kriasoft/TDAmeritrade) and implement a QC IBrokerage

jameschch commented 8 years ago

I had a quick look at https://github.com/kriasoft/TDAmeritrade and it looks like it lacks make order implementation. If the order fills are via REST it may be a pain.

Was trying to find some api docs then came across this ...and am not sure they even let you see the API doc unless you're willing to pony up.

pnguyen30 commented 8 years ago

Obtaining access to TD Ameritrade API has some hefty requirements. I believe TD Ameritrade requires a minimum account balance ($150k+). I doubt most users will have an easy time getting access to the API. Been using Lean for quite some time now, just joined GitHub so that I can give back a little bit since I've been using your engine.

jaredbroad commented 8 years ago

@pnguyen30 - Great point thank you. I assumed they'd let LEAN connect as an organization and hopefully give all its users access under the same banner.

What should be the next major brokerage we connect with?

pnguyen30 commented 8 years ago

There has been quite a bit of hype with Robinhood lately, but there seem to be quite a few restrictions on how often one can buy/sell with them, so I'm not too keen on Robinhood integration. If TD Ameritrade doesn't work out, Perhaps E-Trade might be a great brokerage to integrate with.

bizcad commented 8 years ago

I cannot recommend Robinhood for QuantConnect.

I have a Robinhood account.

  1. Robinhood has an api. I signed up to get access to it, but they have not heard back yet.
  2. They do not have margin accounts yet, so you are stuck with a cash account. That means that you have to wait for 3 days for the funds to settle.
  3. So far they only support US stocks, which are all T-3.
  4. They do have a feature in beta called Robinhood Instant which a "limited" margin account and allows access to funds from selling stocks without waiting for 3 days. I am 139,687 of 234,973 in line. I can improve my spot in line by inviting friends.
  5. Robinhood is only available on iOS7 and newer and 4.1 Jelly Bean and above.
  6. Robinhood is only available for USA citizens and residents with a valid Visa and a Social Security Number.
  7. No commission, but you still have to pay exchange fees.
  8. They control the routing, so you can be sure they will route to the exchange with the highest rebate.
jaredbroad commented 8 years ago

Good to know thanks @bizcad

BradGessner commented 8 years ago

Hi Jared,

I just came across this blog and wanted to let you know that I have C# code for TD Ameritrade API for orders, L1 quotes, history, news, etc. It would be great to have a native data feed for QuantConnect. I've attached the API docs and am happy to share the code with you if you're interested. Let me know if I can help build a data connector. Since I just joined QC, I'm still getting familiar with the architecture and would need a tutorial on QC iBrokerage or I could help test since I have a live account. Attached is the API documentation, which is in an old windows help file format.

Thanks Brad Gessner QC Newbie TDA-API.zip

jaredbroad commented 8 years ago

Awesome! Welcome @BradGessner! :) TD seems to have very high minimums to use the API putting out out of the reach of individuals, but would be helpful for hedgefunds. I'd be happy to help you implement an IBrokerage + IDataQueueHandler -- shoot me an email jared@quantconnect.com and we can setup a time to chat.

jameschch commented 8 years ago

Hi @BradGessner, I have a mostly complete IBrokerage integration waiting in the wings and a second in the pipeline. Would be great to share stories and advice on this.

pi-over-two commented 8 years ago

Jared,

Please see http://apiforums.tdameritrade.com/tda-board/ubbthreads.php?ubb=newuser

The requirements for using the TD API are:

(a) your Account value is not less than $500,000; and/or (b) you place at least 30 trades per quarter through your Account.

If at any time you no longer meet these requirements, you may be denied access to API.

kenfehling commented 8 years ago

Quantopian has Robinhood and I think it'd be really exciting if QuantConnect did!

OpenTrading commented 8 years ago

There may be an easier way to do this: do a FIX connector. There are a number of open-source FIX libraries of code out there. You also don't need to implement all of it.

FIX is to my eyes ugly, but it's quite standardized and many of the FOREX companies offer FIX feeds with not too high minimum accounts (~10k$).

In practice, each company's FIX feed may need some tweaking, but it would be relatively minor so with one programming effort you might get a number of partners.

jaredbroad commented 8 years ago

Thanks for the suggestion @kenfehling! I tend to agree with @OpenTrading; a fix connector should be the next implementation to unlock many others.

OpenTrading commented 8 years ago

One of the main retail forex platforms has rolled out a FIX API for ALL accounts: https://smnweekly.com/2016/08/02/spotware-adds-fix-api-ecn-forex-platform-ctrader/ https://help.spotware.com/FIX

It looks like the implementation is still a little incomplete and/or buggy https://ctdn.com/forum/fix-api

but they're rapidly improving it.

This would add a huge number of eligible accounts, with effectively no minimum account balance.

quant1729 commented 8 years ago

Hi guys, just a quick note on FIX. While it is a standard in the industry, many implementations are slightly different and not always fully compatible. Generally, we cannot expect a broker to use particular FIX implementation to be compatible with us. So it makes sense for us to initially design a support for multiple different FIX connectors in the system. It also makes sense to contact our supported (or planned) brokers with question on FIX implementation they use before coding the stuff. At least, this is the approach that one of BBBs has taken to hedge the risks. Thank you, Pavel

OpenTrading commented 8 years ago

Yes the implementation details are often frustratingly different, but once you have done one, you have a good starting point for others. I thought spotware would be a good one to start with because the developers are actively rolling it out and fixing it right now. Plus it gives you access to a number of brokers all at once, some of them big, all with ~100$ account minimums (not k$).

jameschch commented 8 years ago

I've looked at the fix api's for a few brokerages and some seem to be incomplete in terms of supported features: you still need to perform some operations with REST. Have to admit given the choice between websockets and fix, the websockets API's always seem a lot more intuitive, If the fix integration does not reuse across brokerages, this is probably a deal breaker.

rodlogic commented 7 years ago

Even if TD is not the next brokerage implementation, is there a branch or repo where any work is being done? I am interested in this integration and wouldn't mind lending a hand, time permitting.

MuSyStQ commented 7 years ago

Hello all,

I wonder why QuickFIX/n is not mentioned here as a possible FIX implementation in Lean: http://quickfixn.org/ https://github.com/connamara/quickfixn To me it seems to be the natural choice for this task, since it's all CSharp, uses NUnit testing, is open source and configurable (http://quickfixn.org/tutorial/configuration.html), so it should be rather simple to adapt to different brokerages using different versions of this protocol. However, unfortunately the last commit was on October 5th 2016, while there still seem to be some bugs.

Greetings

jaredbroad commented 7 years ago

Thanks for the suggestion @MuSyStQ; it has a pretty sleek API (http://quickfixn.org/tutorial/receiving-messages.html). We're in bug crunching mode at the moment but will resume feature development when the issues from the new release (2.3.0.0+) have been resolved.

MuSyStQ commented 7 years ago

@jaredbroad Ah, I understand this perfectly well. I just wanted to make sure that this implementation was mentioned at least.

Oh, since I am very new here (on Lean as well as on GitHub), I want to thank you for making Lean open source and for your hard work. It's absolutely fabulous to have this framework available in CSharp as completely open source with no closed source dependencies (at least as far as I could see).

jaredbroad commented 7 years ago

Thanks @MuSyStQ - its a massive team effort. We're very grateful to the 50 contributors mentioned here: https://github.com/QuantConnect/Lean/graphs/contributors

If you like what we're doing please support the project with a subscription at www.quantconnect.com! :)

jhashemi commented 7 years ago

TT - traders technologies.

StefanoRaggi commented 7 years ago

Just adding to the list -- tastyworks, it seems an API will be available this summer.

kmerlo commented 7 years ago

I suggest:

1) IG'S API https://labs.ig.com/

2) DIRECTA an Italian Broker https://directa-it.github.io/documentation/en.html

Thanks

laurentm1 commented 7 years ago

What about CQG? This is supported by a lot of futures brokers.

jaredbroad commented 6 years ago

Closing thread to help keep issues focused on single topic.

kkimdev commented 4 years ago

Hi, is there a separate issue for TDA support?