Building an ATS - Logbook

Quote from 2rosy:

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

So you have an array of bars, the length of each bar defined by barsecs, then the array size is (86400 seconds) / (barsecs seconds) bars. When new tick arrives you calculate to which bar the tick belongs to and you update that bar with new tick's data.

So you download real time data but you use bars for analysis, right?
 
Quote from Random.Capital:

Why?

Markets don't trade on constant-time, why the urge to bucket into constant-time buckets?

I would want to know the quotes arrival rate for the past 10 min, for example.
 
Quote from tiagor:

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. :)

Interesting thread tiagor.

Alot of people are troubled by the idea of coding an infrastructure before you have a trading strategy but I approached this the same way you are. The idea being that you need the mechanisms anyway and you can work out a strategy once you have the modules working right. Some of the stuff you are writing is also needed if you want a backtesting module and it makes sense to start out with very simple strategies while you are still developing and debugging.

It is pretty exciting when you have data and have your code running and start testing simple strategies. Its worth the effort to spend alot of time studying and coding accepted measures of performance so you can discuss outcomes with other people (Sharpe etc) in terms they will understand. It is also worth the time to validate the accuracy of the performance measures that you code by canning a reference data set for which performance has been measured by others for a very very simple strategy.

The first time my ATS made a real trade and worked it made about $60.00 and I couldn't stop grinning for that whole day and the next. Amazing satisfaction even if it didn't make me rich. Even if your ATS only pays for your lunch it is still fun and nothing is stopping you from doing some discretionary trading in parallel.

One thing though, don't be tempted to run your ATS unattended for a good long time until you've had time to watch it work through quite a variety of different market conditions. You probably don't need to be told this but make sure you really stay on top of updates to the API made by the broker. They *will* break something occasionally.

I'll be watching your thread. Good luck and thanks for sharing.
 
Quote from Random.Capital:

Why?

Markets don't trade on constant-time, why the urge to bucket into constant-time buckets?

Agreed.

If you really insist on having all the quotes from the last 10 minutes, though, just stuff the quotes into some sort of FIFO queue (in C++ this could be std::queue, std::list or std::deque). Every time you get a tick, examine and pop all the quotes which are older than ten minutes. Something like

Code:
void tick()
{
  while (true)
  {
    Quote q = theQueue.peek();
    if (currentTime() - q.time() <= tenMinutes) break;
    theQueue.pop();
  }
}

Your stuff should all be running on ticks. If you need bars for some particular task, just reconstruct them from the quotes.

This thread is pretty fun, I enjoy reading the posts here.
 
Quote from hft_boy:



If you really insist on having all the quotes from the last 10 minutes, though, just stuff the quotes into some sort of FIFO queue (in C++ this could be std::queue, std::list or std::deque). Every time you get a tick, examine and pop all the quotes which are older than ten minutes.

That's an idea. Then the queue size will vary throughout the time.
 
Quote from vincegata:

...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.
... 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...
As above, use a List or similar. Put the ticks into the list over the 10 mins, then when the first 10 mins expires, calc the average. From there on, re-calc the average every second or whatever, while the list is still being populated with new ticks, and, discard the ticks that are now older than 10 mins ... thus maintaining the window. *you may need to get familiar with locking for this to not crash.

That being said, I don't think there is any efficacy in using a 10 min sma for really anything at all. Sorry to be a dick ..
 
Quote from Rationalize:

As above, use a List or similar. Put the ticks into the list over the 10 mins, then when the first 10 mins expires, calc the average. From there on, re-calc the average every second or whatever, while the list is still being populated with new ticks, and, discard the ticks that are now older than 10 mins ... thus maintaining the window. *you may need to get familiar with locking for this to not crash.

That being said, I don't think there is any efficacy in using a 10 min sma for really anything at all. Sorry to be a dick ..

I got it about the "window" concept. THX to you and previous posters too.

You do not use any of MA for your strategies? Or it's 10 min SMA that troubles you, I just used 10 min as an example.
 
Quote from vincegata:

I got it about the "window" concept. THX to you and previous posters too.

You do not use any of MA for your strategies? Or it's 10 min SMA that troubles you, I just used 10 min as an example.
No MAs at all really. Occasionally a vwap over the day, but nothing where each trade is assigned the same weight. Scoring all trades with the same weight would imply that everyone knows what they are doing & all trades are equally informed. This is, in my view, ridiculously fanciful.
 
Quote from vincegata:


You do not use any of MA for your strategies? Or it's 10 min SMA that troubles you, I just used 10 min as an example.

There is nothing about MAs that requires fixed-time buckets.

I can see the rational behind fixed-price and fixed-volume and fixed-tick-count bars, all of which will produce variable-time bars, but fixed-time bars have never really made sense to me.
 
Back
Top