July 15, 2011 – 11:47 am | by trader
i am now in real time, getting the stream of market data from FX Inside. this stream include market prices and limit order levels. The first thing to do was collect this data in a mysql database. I had some problems but i was finally able to connect the C++ feed program from lucre with my local mysql database and dump the data in there.
Next, every 15 minutes the program take a snapshot the data table, put all the orders with the same price level together and sum its volumes. This is done with php, technology used for now in all this:
Linux
C++
Mysql
Php daemon
at some books or articles about the limit order book theory it says that market not affected by news are affected by microstructure in the form of limit book order imbalances placed by liquidity providers.
Lets suppose the euro/usd is at 1.435 level when the book snapshot was toked and the biggest amount of orders in the limit book is at 1.445, sell order types. What i believe is that 1.445 is a short term support level for the eur/usd. If it gets hitted the market will temporally retrace. I don’t know how much the market will retrace if this support level is hitted, what i do know with more confidence is that it will be hitted because the markets are done to facilitate trading, if a lot of volume is at a certain level the market will go after it.
To summarize, the strategy is:
- get all limit orders information in real time, put them in a database.
- each 15 minutes, sum limit orders that are in the same price levels.
- the price levels with most volume is compared with current market price, the level could be one of the followings:
- resistance
- support
- more buy
- more sell
- exit position when level is reached or when stop loss is hitted.
- wait until the next quarter of hour and start collecting data again to have a new complete 15 minutes snapshot.
- make new trade.
if level is resistance, buy the eur/usd, position liquidation at resistance level. if level is support sell eur/usd, if level more buy, buy eur/usd and if level is labeled as more sell sell the eur/usd and liquidate when the level is reached.
when one leg of a position is open the strategy is locked and can0t make more trades, when the positions closes the strategy will start to collect data again and make new trades. never more than one position at the same time.
as a test, i am going to use a very big stop loss of 500 pips, this of course will have to be adjusted.
as you can see in the next statement the strategy started to run and make trades successfully.
| Open date |
Open side |
Symbol |
Open price |
Size |
Utilized Margin |
Close date |
Close price |
P&L |
P&L in USD |
| 06/21/11 15:49:51 |
Sell |
EUR/USD |
1.44003 |
100000 |
100000 |
06/21/11 16:38:27 |
1.43969 |
34 |
23.6663326 |
| 06/21/11 14:49:41 |
Sell |
EUR/USD |
1.43822 |
100000 |
100000 |
06/21/11 15:08:49 |
1.43796 |
26 |
18.0977837 |
| 06/21/11 14:19:49 |
Sell |
EUR/USD |
1.43691 |
100000 |
100000 |
06/21/11 14:34:22 |
1.43647 |
44 |
30.6270186 |
| 06/21/11 13:49:31 |
Sell |
EUR/USD |
1.43654 |
100000 |
100000 |
06/21/11 14:10:23 |
1.43627 |
27 |
18.7938523 |
| 06/21/11 13:34:17 |
Buy |
EUR/USD |
1.43657 |
100000 |
0 |
06/21/11 13:41:09 |
1.43712 |
55 |
55 |
| 06/21/11 13:04:35 |
Sell |
EUR/USD |
1.43767 |
100000 |
100000 |
06/21/11 13:17:42 |
1.43719 |
48 |
33.411293 |
| 06/20/11 19:05:04 |
Buy |
EUR/USD |
1.43021 |
100000 |
0 |
06/20/11 21:19:21 |
1.43098 |
77 |
77 |
| 06/20/11 18:34:57 |
Sell |
EUR/USD |
1.43114 |
100000 |
100000 |
06/20/11 18:39:53 |
1.43097 |
17 |
11.8331663 |
| 06/20/11 18:04:21 |
Sell |
EUR/USD |
1.43086 |
100000 |
100000 |
06/20/11 18:04:54 |
1.43066 |
20 |
13.9213721 |
| 06/20/11 17:50:02 |
Buy |
EUR/USD |
1.43095 |
100000 |
0 |
06/20/11 18:01:14 |
1.43148 |
53 |
53 |
| 06/20/11 17:04:06 |
Buy |
EUR/USD |
1.43038 |
100000 |
0 |
06/20/11 17:25:45 |
1.43104 |
66 |
66 |
| 06/20/11 16:48:42 |
Sell |
EUR/USD |
1.43177 |
100000 |
100000 |
06/20/11 16:53:36 |
1.43094 |
83 |
57.7736942 |
| 06/20/11 16:36:56 |
Buy |
EUR/USD |
1.43086 |
100000 |
0 |
06/20/11 16:45:34 |
1.4316 |
74 |
74 |
| 06/20/11 15:48:52 |
Sell |
EUR/USD |
1.43224 |
100000 |
100000 |
06/20/11 16:09:01 |
1.43112 |
112 |
77.9596837 |
| 06/20/11 15:34:30 |
Buy |
EUR/USD |
1.43123 |
100000 |
0 |
06/20/11 15:42:22 |
1.43184 |
61 |
61 |
| 06/17/11 14:49:43 |
Sell |
EUR/USD |
1.43033 |
100000 |
100000 |
06/17/11 17:02:53 |
1.43011 |
22 |
15.3135093 |
| 06/17/11 14:20:11 |
Buy |
EUR/USD |
1.42934 |
100000 |
0 |
06/17/11 14:39:43 |
1.42992 |
58 |
58 |
| 06/17/11 13:56:19 |
Sell |
EUR/USD |
1.42818 |
100000 |
100000 |
06/17/11 13:50:03 |
1.42718 |
100 |
69.6068605 |
Note how all the positions are profitable in the sample.
Tags: c++ for trading, financial c++, High frequency business, limit book, lucre, Lucre Capital, microstructure trading, mysql trading, php trade, php trading, visual c++ trading