Progress report: It's been nearly 2 weeks since I started this project and I'm happy with the progress so far. I'm finishing some sanity checks on the simulator to have some degree of confidence on the results. Below is a sample output of a dummy strategy. Stop-loss is hardwired to be max of 2% equity per trade. Sample order log from strategy on 6 months of 1H data from EUR/USD: (equity variation in attachment) ['06/19/12 04:00:00': EUR/USD [1.260290], Equity: 999.68, Open PnL: 0.00 (0.32) [Open Short] ['06/19/12 13:00:00': EUR/USD [1.260700], Equity: 999.37, Open PnL: -4.10 (0.32) [Close Short] ['06/19/12 14:00:00': EUR/USD [1.261300], Equity: 994.95, Open PnL: 0.00 (0.32) [Open Long] ['06/21/12 01:00:00': EUR/USD [1.266350], Equity: 994.64, Open PnL: 50.50 (0.32) [Close Long] ['06/21/12 02:00:00': EUR/USD [1.266000], Equity: 1044.82, Open PnL: 0.00 (0.32) [Open Short] ['06/24/12 23:00:00': EUR/USD [1.253600], Equity: 1044.51, Open PnL: 124.00 (0.31) [Close Short] ['06/25/12 00:00:00': EUR/USD [1.253500], Equity: 1168.19, Open PnL: 0.00 (0.31) [Open Long] ['06/25/12 06:00:00': EUR/USD [1.252200], Equity: 1167.88, Open PnL: -13.00 (0.31) [Close Long] ['06/25/12 07:00:00': EUR/USD [1.249720], Equity: 1154.57, Open PnL: 0.00 (0.31) [Open Short] ['06/26/12 06:00:00': EUR/USD [1.249490], Equity: 1154.26, Open PnL: 2.30 (0.31) [Close Short] ['06/26/12 07:00:00': EUR/USD [1.249990], Equity: 1156.24, Open PnL: 0.00 (0.31) [Open Long] ['06/26/12 12:00:00': EUR/USD [1.247540], Equity: 1155.93, Open PnL: -23.12 (0.31) [Close Stop-loss] (...) ['11/21/12 19:00:00': EUR/USD [1.281950], Equity: 1539.83, Open PnL: 0.00 (0.32) [Open Long] ['11/27/12 14:00:00': EUR/USD [1.292960], Equity: 1539.51, Open PnL: 110.10 (0.32) [Close Long] ['11/27/12 15:00:00': EUR/USD [1.291530], Equity: 1649.29, Open PnL: 0.00 (0.32) [Open Short] ['11/28/12 22:00:00': EUR/USD [1.294860], Equity: 1648.96, Open PnL: -32.99 (0.32) [Close Stop-loss] ['11/28/12 22:00:00': EUR/USD [1.294860], Equity: 1615.65, Open PnL: 0.00 (0.32) [Open Short] ['11/29/12 00:00:00': EUR/USD [1.294100], Equity: 1615.33, Open PnL: 7.60 (0.32) [Close Short] ['11/29/12 01:00:00': EUR/USD [1.294360], Equity: 1622.61, Open PnL: 0.00 (0.32) [Open Long] ['12/03/12 22:00:00': EUR/USD [1.305190], Equity: 1622.28, Open PnL: 108.30 (0.33) [Close outstanding] Backtest report: Initial equity: 1000.00 Final equity: 1730.58 Commissions: -104.66 Total trades: 83 Max drawdown: 24.02% Win rate: 37.95% Sharpe Ratio: 2.05
Since OP is busy working on his system at the moment, I have a related question. Do you guys use real time quotes to generate buy/sell signals or do you aggregate them into, say, 1sec OHLC bars? If you use real time quotes then you get an unevenly spaced time series. How do you deal with it?
Progress report: Still trying to weed out some bugs in the simulator. I actually found a nasty one on the way the stop-loss and drawdown were being calculated (they were based on the close value of a data sample and not accounting for the full price range). These are being fixed now. I've also started to build my first ghost. The real headaches are about to begin.
Real-time. Line them up in order, using the last quote on other legs as a reference in between new ticks.
use realtime. create an array of bar objects and then as quotes come in set the appropriate bar's attributes
mmm .. bars as opposed to ticks? If you need a high/low or vol range, why not just calc it off a tick window.
you're right. actually i use esper which does do a window. but I remember I did create a list of bars and set those with ticks for something somewhere, maybe it was for static data ticks
I probably did not formulate my question correctly. I download quotes from a broker in real time. From here I can aggregate real time quotes into (e.g. 1sec) OHLC bars and pass them to Strategy System to analyze bars to generate buy/sell signals. For example, I want to generate the signals based on the past 10 minutes SMA, which is 600 seconds. So I allocate a buffer of 600 doubles which will hold 10 min worth of bars. The other way is that I can pass real time quotes into Strategy System for analysis to generate buy/sell signals. However, my buffer of 600 will hold the quotes for more or less than 10 min because the quotes come sometimes faster and sometimes slower. Hence I get uneven time series, but I want the signal to be based on exactly 10 min. How do you deal with that?
this is what I was referring to with a list of bars Code: class BarList(object): def __init__ (self,barsecs,runningtime): totlap=86400.0 self.barsecs = barsecs self.totcount = totlap / barsecs self.bars = [ Bar() for i in self.totcount ] def newTick (self,tick): runningtime = tick.timestamp self.bucket = runningtime / barsecs