QuantConnect / Lean

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

Metatrader 4 Data via MT4 SDK #14

Closed talaikis closed 8 years ago

talaikis commented 9 years ago

I found open source C# API for Metatrader 4 at Codeplex, didn't tested yet if it works, but this is good way to get free live data from various brokers on FX, CFDs, some major stocks (all minute level, ticks need to be collected live), and also have implementation of all brokers who support MT4.

Here: https://tradeplatform.codeplex.com/

jaredbroad commented 9 years ago

Sounds interesting, it wouldn't be too much work if you dig into the way the data feeds work -- take the MT4 data you need and push it into the bridges.

jaredbroad commented 9 years ago

We re-factored the way the brokerage classes were implemented last night to give more separation between the transaction handlers and the brokerage implementation. It should now be feasible to implement a new brokerage completely independent of the rest of QC. Hopefully this will make brokerage additions easier.

talaikis commented 9 years ago

I have reviewed it and think it's simpler and more flexible to implement this through MySQL datafeed rather than TradngPlatform SDK which is outdated and too heavy.

It would consist of two parts:

  1. MT4/5_to_MySQL.
  2. MySQL data feed on Lean engine.

I think I can do 1st. And for 2nd will try to understand how that works with subscriptions/bridges.

jaredbroad commented 9 years ago

Hi @xenu256, we're simplifying the bridges now trying to spot the patterns and abstract them away. I've made a MySQL bridge as part of this initiative. You can see it here: https://github.com/QuantConnect/Lean/blob/master/Engine/DataFeeds/DatabaseDataFeed.cs

talaikis commented 9 years ago

Great, seems I have older version of Lean. Will explore how that works.

jaredbroad commented 9 years ago

Super, recommend exploring the git API -- "git pull" will update your local copy.

We added a lot since you first pulled; dividends, splits, different price modes, live trading fixes and datafeeds!

On Sun, Apr 26, 2015 at 4:35 AM, Tadas Talaikis notifications@github.com wrote:

Great, seems I have older version of Lean. Will explore how that works.

— Reply to this email directly or view it on GitHub https://github.com/QuantConnect/Lean/issues/14#issuecomment-96344122.

Jared Broad

www.quantconnect.com Phone-USA: +1 917 310 1082 Democratizing Finance, Empowering Individuals Facebook http://www.facebook.com/QuantConnect | Twitter https://twitter.com/#!/QuantConnect | LinkedIn http://www.linkedin.com/company/quantconnect | Skype: jaredbroad

talaikis commented 9 years ago

OK, github autoupdates only official release, but whatever, I can download zip.

Will you need MT4 files included on Lean or keep it as separate repo? (because they'll be not related in anyway other than through MySQL database).

jaredbroad commented 9 years ago

Thanks Tadas, for now please submit it as a pull request to Lean, and we'll reorganize it all in a few weeks. The pull request should be for files like this:

/DataFeeds/MT4DataFeed.cs /DataFeeds/MT4/MT4Connector.cs .. Libraries for MT4 here.

I wouldn't recommend doing it through MySQL -- that greatly limit who can use it. Its a little harder but worth building a dedicated IDataFeed implementation, just follow the patterns I laid out in the MySQL one,

Best, Jared

On Mon, Apr 27, 2015 at 12:45 PM, Tadas Talaikis notifications@github.com wrote:

OK, github autoupdates only official release, but whatever, I can download zip.

Will you need MT4 files included on Lean or keep it as separate repo? (because they'll be not related in anyway other than through MySQL database).

— Reply to this email directly or view it on GitHub https://github.com/QuantConnect/Lean/issues/14#issuecomment-96735941.

Jared Broad

www.quantconnect.com Phone-USA: +1 917 310 1082 Democratizing Finance, Empowering Individuals Facebook http://www.facebook.com/QuantConnect | Twitter https://twitter.com/#!/QuantConnect | LinkedIn http://www.linkedin.com/company/quantconnect | Skype: jaredbroad

talaikis commented 9 years ago

MT4 isn't reliable for frequent calls for data, it's why I've though it may be done through MySQL. But if you want it in C#, then I'll explore how that's done on TradePlatform.

talaikis commented 9 years ago

OK, in any case, I've done MT4toMySQL: https://github.com/xenu256/MT4toMySQL/tree/master and will see what to do next :)

jaredbroad commented 8 years ago

Hey @xenu256 will close this as almost a year old, but if MQ4 data is still of interest please submit a new issue.