Jump to content

Python3 Automated Trading App

Recommended Posts

First let me tell you a bit of a story, Found myself out of work and too much time on my hands, well deserved break so to speak. I decided to learn Python, I thought what better ways to do that than program a real world application that would make me some money and automate my trading... hopefully, So here I am, today I get an email to check out the new and improved IG community. It's been a long road but I am here to share it with the community and the wider world. 


At first I started by trying different trading strategy's, Some with more success than others. I finally got a working strategy for Forex only to be priced out of the market with the ESMA regs. That said. I have spent time re writing my code to work with small cap stocks, that you would see the likes of in the FTSE250. The margin requirements are a lot less. This is great for people just starting out. 


I have learned lots of lessons along the way, The most prominent one been that do not try give anything away for free on the internet people will only complain. That said...Here It is. 


What is this for? I hear you ask.... Will it get you instantly rich... most definitely.... Come on, really? ... No... It will not. Will it make some money well all I can say is it certainly has for me, It is a learning tool for you to get to grips with algorithmic trading and perhaps Python and using a world class API/infrastructure that IG have. The API has been rock solid for me and I hope it continues the way it is. 


I DO NOT in anyway shape or form work for IG or have never done, I just happen to like IG. This project is NOT affiliated, backed or supported by IG. This is ALL my own work. 
This code will run on Windows or Linux, Quite a few people are running it on a Raspberry Pi or very cheap VPS. I run it on a Linux VPS using nohup to keep it running 24/5. It uses a few standard Python3 library’s. As for the algorithm itself you can discuss it on the Discord chat and work out what it is doing. 


Please please and I cannot stress this enough TEST IT FIRST on a demo account, That way you can understand what it does. All the code is open source so people can rip it to bits, suggest improvements learn from it. 


Link to Discord Chat. https://discord.gg/ZfwukPz


Link to Github Code https://gist.github.com/tg12/4dc0107b5b45fd91dd15fbd5b16f593c


Attached is two performance graphs, Self explanatory. 


Enjoy! 

Instrument Summary.png

Running Total.png

  • Like 1

Share this post


Link to post

@TheGuru12

I personally would class FTSE 250 companies as mid cap shares. Small cap would be lower in terms of FTSE 350 or even FTSE Small Cap! AIM shares would be a mixture of small cap and nano cap. Yes that is right nano caps. 

I personally do not feel comfortable clicking on the two links you have sent.

Share this post


Link to post
3 minutes ago, TrendFollower said:

@TheGuru12

I personally would class FTSE 250 companies as mid cap shares. Small cap would be lower in terms of FTSE 350 or even FTSE Small Cap! AIM shares would be a mixture of small cap and nano cap. Yes that is right nano caps. 

I personally do not feel comfortable clicking on the two links you have sent.

OK, Thank you for your comment's.

Share this post


Link to post
8 minutes ago, TrendFollower said:

If you are still out of work and have not found a job then maybe IG may have a look at your system and offer you a job.

?

Thanks for your comments, I wish! I'd love to work in this world but I am currently employed. I did talk about this in my interview. 

Share this post


Link to post

Hi  @TheGuru12 I'm not too good at python coding but was just wondering what on earth is the thousand lines of ? before you get to the actual trading API code. Also, why have you not gone through the IG Labs site API's forum. And lastly, we all know things don't perform the same on demo as live so how have you found the API going live?

ft1.thumb.PNG.1bdeb4e4f1bf909a5d581755c5fc01dc.PNG

Share this post


Link to post
27 minutes ago, Caseynotes said:

Hi  @TheGuru12 I'm not too good at python coding but was just wondering what on earth is the thousand lines of ? before you get to the actual trading API code. Also, why have you not gone through the IG Labs site API's forum. And lastly, we all know things don't perform the same on demo as live so how have you found the API going live?

ft1.thumb.PNG.1bdeb4e4f1bf909a5d581755c5fc01dc.PNG

Hello, Thank you for your reply. The top of that is the imports I use certain library's for and then there is also a giant list of stocks to loop through and check. Perhaps these could have been split out into another file but ... it works. 

The results I posted are on my live account, I have found my live and demo to perform pretty much identically. There is more money in my Demo so more trades but in terms of trading functionality and algorithm design they work the same. 

 

The IG Index API forums are not used by many people also I have been waiting for them to approve my account, I am not sure why they are separate. Perhaps they are not now. Either way they are not used by many. 

Edited by TheGuru12

Share this post


Link to post

Thanks for that, very interesting, obviously only 6 weeks worth of data but promising, look forward to the updates.

There will be many on here who may have used MQL5 and EAs but not python and APIs, perhaps you might give a quick basics starter guide at some time.

Best of luck.

  • Like 2

Share this post


Link to post
6 minutes ago, Caseynotes said:

Thanks for that, very interesting, obviously only 6 weeks worth of data but promising, look forward to the updates.

There will be many on here who may have used MQL5 and EAs but not python and APIs, perhaps you might give a quick basics starter guide at some time.

Best of luck.

Thank you, There's lots of documentation around. People have wrote stuff on the Discord chat. I pretty much just provide the code. I might answer some very specific questions but not much now as I don't have much time. My code is very niche, So yes anyone who is a professional trader should use MQL/EA's. 

Share this post


Link to post

So I'm not a coder and unfortunately wouldn't want to get in on this discussion, but it looks very promising from the chart posted. It would be good to get further confirmation from a statement or similar from the demo account which I think would satisfy a few people as well.

There is no way for me to get my head around this right now but it's looking good and I would love to see someone else who has tested out on demo to see their results. Those returns are solid.

Thanks for a good post and welcome to the forum!

Share this post


Link to post

It does look interesting and the hard work has already been done. Running the python code on the web based platform on a demo account through IG's API on the face of it doesn't look any more difficult to running in a EA in MT4, though I've never tried the API myself. Here is the 'get started' page from IG labs for anyone interested in having a go.

https://labs.ig.com/

 https://labs.ig.com/gettingstarted

 

Share this post


Link to post

out of interest - what are peoples thoughts on bringing over the Labs forum to this main Community area? So it's all in the one place, and hopefully given a bit more prominence and re-inject with a bit more 'life. 

  • Like 1

Share this post


Link to post
7 minutes ago, JamesIG said:

out of interest - what are peoples thoughts on bringing over the Labs forum to this main Community area? So it's all in the one place, and hopefully given a bit more prominence and re-inject with a bit more 'life. 

You know my thoughts on this. Even from a practical point of view within IG it would make sense. Everything under one roof. No separate infrastructure etc. However that said. It is every niche and it’s hardly ever visited. Even on the wider internet the API is not used much but I think I’ve got quite a few people to use it singlehandedly. If I remember correctly the last post office on there was months ago. Shame. I was hoping more people would use it. 

Share this post


Link to post

Yes, it's probably a good idea to join the two forums, as tg12 says, the labs forum is infrequently used. Though it is niche it could have it's own forum header here and also I know there are plenty on here who run, or are interested in EAs on mt4 who would probably also be interested in API if the subject were to get a wider airing. 

Share this post


Link to post

I myself am not a coder but I think it could enhance the IG Community. I agree with @Caseynotes, that maybe it could have its own section just like Commodities or Cryptocurrencies and Blockchain. 

@JamesIG, If you are unsure then why not simply trial it or would that require far too much effort?

Share this post


Link to post

Ha @TrendFollower, can't say I am much of a coder myself though I have recently done a bit of re-writing and debugging of some mt4 indicators that I'm interested in. The introduction of IG's API onto this forum may well gain a following of those interested in auto trading but so far only familiar with MT's EAs.

https://medium.freecodecamp.org/what-is-an-api-in-english-please-b880a3214a82

 

 

  • Thanks 1

Share this post


Link to post
12 hours ago, TrendFollower said:

 

@JamesIG, If you are unsure then why not simply trial it or would that require far too much effort?

You can't really trial something like that. Once you have done the migration of one Community to another it's effectively done. It's an all or nothing scenario. 

Share this post


Link to post

@JamesIG, oh ok. 

In that case as you have asked the IG Community the question then are you able to provide some statistics?

  • How many members are in the Labs Forum?
  • How many members actively participate in the Labs Forum?
  • What value or enhancement will this migration bring to the IG Community?

There must be a beneficial reason for this migration for the IG Community and if there is then I would support such a move. If the reasons are 'wishy / washy' then it is a different matter.

I think for the IG Community to move to the next level the amount of participation must be greater from all those 'passive' members who are on the sidelines but do not wish to post anything on the threads. Will any migration solve this issue? It seems to be the 'usual suspects' posting most of the content. How can the IG Community change this?

  • Like 1

Share this post


Link to post

I am interested in the response to soundings from the 'techies', they may not want leave their basement  lab....                 ?     ☢️?‍?

Share this post


Link to post

I will try post a monthly update. Since I started this on the 18th it will be then or around then. Thing's to note on this one. I doubled the size of my investment hence the straight up line, don't get too excited. The rest is the same. 

Chart1.png

Chart2.png

  • Like 1

Share this post


Link to post

@TheGuru12 I love that chart number 2 you have that goes up on the left and down on the right. 

How did you do it? Excel I assume but I’m a **** at that so could you maybe give a little guidance? 

Share this post


Link to post
3 hours ago, PandaFace said:

@TheGuru12 I love that chart number 2 you have that goes up on the left and down on the right. 

How did you do it? Excel I assume but I’m a **** at that so could you maybe give a little guidance? 

Perhaps that word "****" means something else where I am from! haha.

What version of Office?

Share this post


Link to post
On 19/09/2018 at 13:30, PandaFace said:

Thanks @JamesIG 

@TG12 we have 2013 at home. Thank you! 

Create a PivotTable, Sort it by size and create a template graph from that. 

  • Like 1

Share this post


Link to post

Sorry to resurrect this old thread but I read there were thoughts to unite the IG Labs forum with this forum here.

I'm myself an algorithmic trader that uses MATLAB to trade through IG's API and I think this would be a good idea. As already was pointed out the IG Labs forum is rather dead.  Maybe it would become a little more active when a IG Labs subform was created here.

This would be really appreciated. I often miss the opportunity to discuss problems I encounter but writing in this IG Labs forum feels like talking in an empty room. ?

Share this post


Link to post

Hopefully IG are still considering this, I don't actually participate on the labs forum myself but do look in from time to time to see whats happening and there does seem to be a lot of unanswered questions or occasionally someone just talking to themselves in the dire hope someone else might respond.?

I know a lot on this forum don't even know the labs one is there and quite a few are interested in coding/running auto traders.

Share this post


Link to post

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Member Statistics

    • Total Topics
      6,079
    • Total Posts
      26,693
    • Total Members
      33,889
    Newest Member
    galina2809
    Joined 23/01/19 05:15
  • Our picks

    • The pull-back is here - APAC brief 23 Jan
      The pull-back is here: The pull-back markets were waiting for – the one we inevitably had to have – has arrived. It’s risk-off across financial markets and the optimism that drove global stocks off their December lows has subsided. Relatively speaking, it’s been a day of significant downside, but nothing yet to warrant tremendous fear. It should be common knowledge, but it bears repeating: proper validation that global equities have truly established a recovery ought to be judged not by the latest high, but by where markets form their next low. The retracement which is apparently upon market participants now hands a golden opportunity to judge this market for what it truly is – have the bulls reclaimed their dominance, or have the bears lulled them into a trap, and now stand poised to assert further downside?


      The market’s rationale: A greater look at this subject and Wall Street’s price action later. In relation to the overnight sell-off, the rationale was as feeble as the one that got stocks to their recent peaks in the first place. It’s been chalked up to reduced positivity towards the trade-war, and renewed concerns about global growth. To begin with, very little data throughout the past week has provided a clear and substantial picture on economic growth. The boost in sentiment has come from geopolitical or monetary policy developments that was assumed to be supportive of the growth outlook – at some point in the future.  Some nice-noises made between the US and China in trade negotiations here, and a few dovish comments from a handful of US Fed speaker there, is what ignited the latest part of the risk-on rally.
      • 0 replies
×