Building an automated trading system from scratch
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Building an automated trading system from scratch
My goal is to try and build an automated trading system from scratch (where I can essentially press a button to start the program and it will trade throughout the market hours before I close it). I'd prefer being able to use Python for this, but I honestly not sure where I have to start from.
I see a lot of posts and books about Algo trading strategies but I want to actually build a system that trades it.
Are there any specific resources (online courses, books, websites) you guys would recommend for figuring this out?
Also, what are the specific parts I need? I know I need something to gather data, parse the data, run the strategy on the data, and send orders. Is that it?
really appreciate any assistance/ wisdom you can pass on.
p.s-dear admin, i'm not sure if this question should be posted on this thread or any other. please move or direct me to the correct forum thread. Thanx
- slstockVeteran
- Posts : 6216
Join date : 2014-06-12
Re: Building an automated trading system from scratch
1) Are you looking at building a system to trade at CSE?
2) If so, there are bottleneck you have to overcome.
a) At CSE, without an online account through a broker you are not allowed to trade. Anycase you need a CSE/Broker Account ID to trade.
b) The CSE realtime available share price/trading data was presented though a document ( it used to be xls not sure now) . You need to find such is on CSE and take a look what you can do with it.
_________________
Never listen to anyone including myself without your own study. Only few truly genuine people exist in this world.
Please read : https://forum.lankaninvestor.com/t1548-important-warning-and-message
---------
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
Thank you for the reply.
yes i'm currently looking at CSE.
then definitely i would have to look in to a way of getting real-time data since the project i'm planning is more in to HFT.
- කිත්සිරි ද සිල්වාTop contributor
- Posts : 9679
Join date : 2014-02-23
Age : 66
Location : රජ්ගම
Re: Building an automated trading system from scratch
Why do you want to reinvent the Wheel?
Let us know, please.
(I know nothing about the subject but I can always act like the Devil's advocate).
_________________
I am the wisest man alive, for I know one thing, and that is that I know nothing.
Socrates
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
Not exactly to reinvent the wheel, but to evolve it a bit
Well simply to put, I'm trying to test my own algorithm.
I'm not sure if i would be able to use my algorithm with any of the current trading applications available locally.
Also i'm planning to integrate a bot to continuously run the algorithm.
- කිත්සිරි ද සිල්වාTop contributor
- Posts : 9679
Join date : 2014-02-23
Age : 66
Location : රජ්ගම
Re: Building an automated trading system from scratch
I am sure there will be someone here who could help you more.
(I am just a Sarong clad simpleton who uses his Gut feeling for decision making).
janith wrote:Hi කිත්සිරි,
Not exactly to reinvent the wheel, but to evolve it a bit
Well simply to put, I'm trying to test my own algorithm.
I'm not sure if i would be able to use my algorithm with any of the current trading applications available locally.
Also i'm planning to integrate a bot to continuously run the algorithm.
_________________
I am the wisest man alive, for I know one thing, and that is that I know nothing.
Socrates
- CKActive Member
- Posts : 1393
Join date : 2015-11-01
Re: Building an automated trading system from scratch
What are the criterias you are going to give to bot??
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
I'm currently monitoring some reference models which I can absorb in to my project. And yes I believe I can get the bot to work on CSE.
As for the share name and other details, I expect there should be an easier way to import financial data to my coding than a manual entry.
- pjrngroup
- Posts : 444
Join date : 2015-11-01
Re: Building an automated trading system from scratch
My two cents below,
I used to trade in the forex market earlier. There are so many automated trading system in the forex market. but i have not seen or heard anyone using that in CSE. i am only in CSE for last two+ years.
And i doubt the online trading platforms in Srilanka is capable of accommodating AUTOMATED TRADING SYSTEM. This is not to de motivate you. May be they don't have it so far, because no one needed it so far. Since you are in a mission to invent it, it would be beneficial for all of us in the forum.
Good luck.
- nihal123Top contributor
- Posts : 6327
Join date : 2014-02-24
Age : 58
Location : Waga
Re: Building an automated trading system from scratch
Welcome to the Forum,
If you need historical trading data of CSE, I can give you ( 1991 to 2012 ) There are 30 xls files................
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
Thank you for your insights and advise.
I'll rather take your constructive feedback than someone just saying 'NO IT CANNOT BE DONE'.
@nihal123
Thank you so much for the offer.
What will it cost for me to get the data from you?
- nihal123Top contributor
- Posts : 6327
Join date : 2014-02-24
Age : 58
Location : Waga
Re: Building an automated trading system from scratch
janith wrote:@pjrngroup
Thank you for your insights and advise.
I'll rather take your constructive feedback than someone just saying 'NO IT CANNOT BE DONE'.
@nihal123
Thank you so much for the offer.
What will it cost for me to get the data from you?
රැපියල් ශත මත, මිළ තබන සමාජයක ඔබගේ පැනය ගැන අමනාප නොවෙමි.
එය සියල්ලන්ගේම යහපත පිණිස නොමිලයෙ ලබා දෙමි.
මා එය ලබාගත්තේ CSE තුලින් නොමිලයෙමය,
ඔබගේ ඊමේල් ලිපිනය දන්වන්න.
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
janithds2cash at gmail dot com
(apologies for inputting the address like this as the system says that I can't put any e-mail addresses until 7 days from registration)
Greatly appreciate your support. Having this data would definitely ease up some of my burdens on this project.
- nihal123Top contributor
- Posts : 6327
Join date : 2014-02-24
Age : 58
Location : Waga
Re: Building an automated trading system from scratch
19 MB zip file
- CKActive Member
- Posts : 1393
Join date : 2015-11-01
Re: Building an automated trading system from scratch
(I think for long term investments, shouldn't use a trading system. Should be hand picked)
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
Thank you very much.
The data set is very useful. I may have to clean it a bit. But you have definitely saved a lot of time for me.
@CK,
Past data is to test my algorithm. It is not necessarily just buy and sell. My algo will be designed to control the risk as well. Having an algo just to buy and sell would not be useful as I may end up loosing money with commissions for each trade. So i'll have to design it such a way that the algo has been fed with accurate possibilities of profits and losses so that it can avoid unwanted deals.
- Yin-Yang
- Posts : 1321
Join date : 2016-03-12
Re: Building an automated trading system from scratch
This is exactly the right way all world famous multi billionaire investors started.
You can follow the following steps and become the Universe's best automated trader in CSE.
+ Summarize your trading algorithm in to 8 steps
+ Get hold of a broker account with DirectFN trading client
+ Use its conditional trading module and APIs to build an automating script
+ Execute the newly built script
+ Wait and see what happens
+ Notice some error executions done by the script
+ Correct the script algorithm
+ Execute it
+ Notice now the program works right
+ Notice that auto trades didn't bring the intended proftis
+ Do some adjustments in the script and execute
++ Wow! the program brings its first profit trades
+ Enjoy your success
+ Have a party and plan what would you do with all the profits going to be generated by your program
+ Plan your dreams of how to spend all unlimited money going to pour in
+ Put more money and plan for bigger automated trading
+But; Notice that something has gone wrong
+ Notice that intended profits are not coming anymore, because something has gone wrong with the market
+ Yes something is wrong with the market
+ Market is not behaving rationally
+ Notice your frustration
++Then, Start your next threat on seeking help again from gurus in this forum
See ya later buddy!!
- CKActive Member
- Posts : 1393
Join date : 2015-11-01
Re: Building an automated trading system from scratch
Brokerage is very primary thing and you can easily take it in to your system mate.
If you don't need to take unnecessary or necessary risk, beter go for long term investments (But you should ready to lock your money atleast 5 years)
Anyhow for me long term investments are the most riskier ones as how we know what happen to the company after 5 or 10 years..
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
I also agree with you on the longer holdups. But my calculations are based on specific market trends and i'm trying to test my algo using past data before I implement it for live trading.
Once I do some backtesting with past data, I can at least check how my algorithm is holding up with the market and also i'll be able to tweak any performance and risk issues.
- slstockVeteran
- Posts : 6216
Join date : 2014-06-12
Re: Building an automated trading system from scratch
1) Didn't want to say this before but we did a project like this maybe 10 year ago. We used AI training of software using past data to predict short term trades at CSE.
2) Anyway as there are lot of feedback on the thread and you seems to be knowing what you want to do, I will eagerly await more details of your approach and success ( I mean the technical side how you did it).
3) Just a tip . I mentioned this before . I see 2 other people also mentioned it in different ways but you may have not picked up the fact
At CSE, there are no public accesible APIs ( to my knowledge) just so anyone can access the ATS ( trading server) for obvious reasons.
So maybe need to find a Trading software ( though a broker) with a good API if you
want to excute real time trades . ( But don't do it at the start as it going to cost you)
Direct FN is a good start as it has some APIs.
I am not sure , Python can be used to access it though.
4) Best to call CSE also to find out latest developments.
The CSE trading server was updated year or 2 ago.
How transactions done were changed from long ago.
Anycase, do update this thread with your progress.
I would personally like to specially know both the approach and specially the techincal details of how you did it.
Good luck
ps : You might find Ying Yang comment a bit sarcastic ( as you have not met him before),
but I can tell you there are certain truths in it.
I will wait for you own discovery , success/failure and reporting of such
_________________
Never listen to anyone including myself without your own study. Only few truly genuine people exist in this world.
Please read : https://forum.lankaninvestor.com/t1548-important-warning-and-message
---------
- janith
- Posts : 9
Join date : 2018-04-05
Location : Colombo
Re: Building an automated trading system from scratch
Hahaha
yes I saw that sarcasm coming at me a mile away
and I also agree with some (or most) of them pointers he has highlighted. To be honest, i've kept it as a checklist to tick one by one off
As for your feedback, thank you for giving me a highlight of your experiences.
I've already got a trading platform (an open source platform; but still adjusting it to suite my requirements though) and my next obstacle would be to find a broker who I can integrate. Since i've also done my research, it seems that currently CSE does not support direct individual access.
I think the only 2 available (or at least most prominent) players to provide online trading in Sri Lanka are Direct FN and ATrad.
So I think I'll have to check the feasibility of integrating their API. I'm currently working with python and C#. So I hope that integration should not make extra workload for me since Python and C# are like 2 of the most preferred languages when it comes to Algo trading or Investment/trading.
I will anyway keep you guys posted on the progress of this project. I know that I will definitely run in to some problems in coming days and better to have some 'know how' people around to get some help.
Thanx
- slstockVeteran
- Posts : 6216
Join date : 2014-06-12
Re: Building an automated trading system from scratch
I hope he shows up and comments as he can give you some tips.
I also like to hear his view on LLUB situation now as bonus discussion.
He was interested in LLUB and did good discussion on it.
( When LLUB was in the Rs 300 before split)
_________________
Never listen to anyone including myself without your own study. Only few truly genuine people exist in this world.
Please read : https://forum.lankaninvestor.com/t1548-important-warning-and-message
---------
- CKActive Member
- Posts : 1393
Join date : 2015-11-01
Re: Building an automated trading system from scratch
Oh.. I got it machan. It's for testing. Great.. wish you good luck.janith wrote:Hi CK,
I also agree with you on the longer holdups. But my calculations are based on specific market trends and i'm trying to test my algo using past data before I implement it for live trading.
Once I do some backtesting with past data, I can at least check how my algorithm is holding up with the market and also i'll be able to tweak any performance and risk issues.
- slstockVeteran
- Posts : 6216
Join date : 2014-06-12
Re: Building an automated trading system from scratch
CK wrote:
Anyhow for me long term investments are the most riskier ones as how we know what happen to the company after 5 or 10 years..
Very interesting comment.
I make this statement to add balance to this opinion ...
1) Anycase if this was the case for everyone , there will be no
a) Captains, Dammika pereras and Harry J
b) No unit trusts , and CINV and GUAR
c) or most importantly there will be no top 10 long term holders for any company
Even companies like COMB, HNB, SAMP, JKH which lasted for decades !
There are some companies which has lasted for 100 years to date.
d) then during certain periods at CSE there will be all sellers and Zero buyers
2) Even if one goes longer term, it does not mean, one buys for 5 years and forget about it. One needs to monitor the company results atleast 6-12 months
So any interested in longer term investing as opposed to shorter term trading,
no need to have undue fear ,
that is if one does his/her homework and future work on the company.
_________________
Never listen to anyone including myself without your own study. Only few truly genuine people exist in this world.
Please read : https://forum.lankaninvestor.com/t1548-important-warning-and-message
---------
- spw19721Active Member
- Posts : 683
Join date : 2015-08-22
Re: Building an automated trading system from scratch
CK wrote:
Anyhow for me long term investments are the most riskier ones as how we know what happen to the company after 5 or 10 years..
Buffett's biggest stock win
Warren Buffett's biggest stock investment win of all time is an excellent example of what he looks for in a "forever stock." Buffett bought shares of Coca-Cola (NYSE:KO) for Berkshire Hathaway in 1988, and just under 30 years later, the stock is up by approximately 1,350% from Buffett's cost basis. And that doesn't even include the dividends Berkshire has received over the past three decades. At the current dividend rate, Coca-Cola pays Berkshire $592 million per year.