NuclearVision wrote@jackB you know people aren't perfect, they did mistakes over time, your code can't anticipate people's decisions which are sometimes ridiculous. People don't do the right things always, otherwise there wouldn't be "loss".
I actually strongly disagree. People's behavior is easy to predict, no one acts randomly.
We all pretty much act in the same way to a certain stimulus, the speed and magnitude of reaction might differ though. Sure some exceptions much exist but collectively you'd expect the same outcome for the same type of experiment; if the outcome is different that's because new information exists, and not because people are acting randomly (the market is always fed with new information).
But again the principle is the same: everyone wants to maximize his net worth. If you can predict (with a statistical model) how the market reacts to different stimulus, you can theoretically beat the market by moving before everyone else. In practice this is much harder to do, but that's why I'm asking those questions.
If you can look at historical data and see how the market reacted to different stimulus (I'm thinking here about technical analysis), and then detect same future trends and make a computer make the trades on your behalf when such trends occur, then maybe profit can be done.