He needs to get in touch with the stock exchange (and brokers) before jumping into any implementation conclusions.
He is not a broker, you can't really interact with any exchange directly. He needs to use some bank (which will already do 99% of what he is implementing).
Without knowing exactly how the market systems work, this is a toy, he should have talked to someone BEFORE writing any code. Things are way more complex and simpler than it looks. It's extremely simple to use bank services to do that for you and close to impossible for a developer to just jumpt into writing trading software without a bank backing it.
This isn't quite accurate. There are brokerages such as Interactive Brokers that provide an API so that you can write automated trading systems. And automated trading isn't limited to just high frequency trading. It's true that most banks have the simple features he mentions in the post but as soon as you want to get a bit more complex what the bank offers just isn't going to cut it.
Yes indeed. The problem with using smaller brokerages would be the pricing (because he is trying to be some kind of broker himself). Banks (investment banks) can even expose the exchange 'API' directly to you. EBS kind of does that for FX
It's not the orders you need to monitor from the sound of it (at least once the trade is complete), it's the position that you hold in the market vs the current price.
* Actually the previous statement could be wrong: You might also want to do this on a per order basis, although they are on some sense functions of each other.
I would suggest the following:
For any market which you have a position in, subscribe to that market's price feed. I'd use zeromq for this, but there are plently of pub/sub libraries and products. The previous point implies that you are republishing your market data feed into specific channels. How they are mapped depends on many factors, but basically you want to de-multiplex the market data so that you are able to pick out one market's price data as a stream of updates from the whole.
Once you have a feed of the market with a position you can use it to transform the stream of market data to multiple streams of values. You might have new steam of PnL values for each order you have on the market, or a stream of price differences or whatever, you then re-publish those streams. Depending on how many of these derivative streams you have and the rate of data, you might want to do some downsampling too.
From some of the comments I see, let's not read too much into this. He's not asking how to build an -automated- trading system, just one that's realtime and all analysis and decisions are made by the user. The best I've seen that's commonly available is "Trader Workstation" and it's free with your account at Interactive Brokers. It's written in Java.
While it's certainly an interesting question, I presume you're posting it here to garner support for it being reopened (as far as the rules go, I agree with the closure, it's very open-ended). It might fit better on http://programmers.stackexchange.com.
I know little about stock markets but I quite like the idea of spawning workers to monitor orders after being placed. These could then update a page live to the customer.
For instance orders would be open from week into week if the user enables it (each week).
In my case "decision making" is only based on some fixed price threshold in order to provide some risk management. So the amount of data to aggregate would be minimal. But the data to analyse came directly (as a huge stream) from the markets.
You might be interested in zipline, an open source backtester written in Python. Zipline, Quantopian's open source backtester (yes, I work at Quantopian).
The backtester is designed to also be a trading engine. You feed zipline data in "events" where each event is a point in time. Zipline doesn't care if the events are live or replayed from a database - it processes the data and executes any trades in the order book.
The tricky part here is that zipline is more aimed at implementing trading algorithms. You'd have to write a simple algorithm to implement the buy/sell orders coming in.
I think the How To format might be too limiting as their are many possible answers. A wiki format with embedded diagramming targeted at architecture would probably suffice once you arrive at some standard for page structure.
This small toolset could also elaborate various business models and business processes as well.
One of the objectives of SE is to build a vast Q&A, which relies on the assumption that all questions can be definitively answered. There's typically no canonical solution to design/architectural questions (there can be many solutions, with varying degrees of quality).
Yesterday I learned about Postgres' LISTEN/NOTIFY functionality. I'm not sure about your architecture, or how many listeners/watchers Posgres supports, but it might be that you can just listen to changes in your database -- that might be the most lightweight solution.
I have made one in ruby for my trades. The key point of the architecture was to do all asynchronous with queues and workers. It worked for me because the network time was big and I don't do high frequency trading.
I have used rabbitmq and ruby with event machine.
Depends. I wrote a rather complicated corridor based routing algorithm for a courier company in the UK which worked on real time traffic data. It was only 11 files and 12,000 loc and that was their entire business model.
Wouldn´t it be much more interesting to spend that precious brainpower into something that actually solves real problems like war, disease, crime, militarism, xenophopia, lack of education, etc. instead of building another greed-engine that will trigger even more poverty, exploitation and repression?
Of course everybody is free to act on his own karma (in a few countries) - but you will have a much better life by doing some more useful work that will benefit all human beeings, not only a few criminals that build weapons of mass murder just for the mentally poor reason of making more and more money.
Programmers haz powers to push human evolution, don´t waste your life on golden lies, that will turn into deadly dust in the end!
This kind of sanctimony is tiring. Every time one of these threads comes up here, it inevitably devolves to a point where someone brings up something like the above. There are those of us who actually enjoy these kinds of problems in and of themselves. I don't consider what I do particularly noble, but I'm paid to solve very interesting and unusual problems in a very fast-paced environment, and I don't feel the need to apologize for it.
I'm under no illusions that I'm doing God's Work, but if the bar for useful work is something that will end "war, disease, crime, militarism, xenophopia, lack of education", I think >99% of us fall quite short of it. Maybe I fall shorter than you do (you don't mention what it is that you do), but I still enjoy my job.
A "Quantitative Analyst Salary" starts at 100k/year. Trying to build a trading system is like trying to invent the next 10x battery technology could end up golden dust in the end as well. You're distracting people from proper cost benefit analysis and assessment of risk/reward.
Programming getting into high frequency trading is "high risk, higher reward". It would be better to use our Neural Networks to find risk factors for prostate cancer you'll get in 25 years, but the money just isn't there. AKA high risk, low (possibly no) reward.