Showing posts with label autotrade. Show all posts
Showing posts with label autotrade. Show all posts

1.28.2012

Price Feed Failures

Lately, I have been having trouble keeping a connection to Oanda's pricefeed. I keep getting disconnected and then eventually my programs tolerance level is exceeded and it times out and dies. If you will recall, last year I migrated everything to the cloud. Sadly when I did that migration I failed to replace my fail-over system which alerted me when failures like this occurred so I could take action. Since my desktop was my trading server until that point, it was simple enough to have alerts be generated on it to awaken me even from sleep if necessary.

Due to programming changes I made in separating out the individual bots from the price feeds, the bots themselves are completely unaffected by the price feed failure, at least from a technical standpoint. From a practical standpoint, they will not be getting any updated pricing information, and will therefore not be able to properly manage trades. I think the next step here is to implement some more automatic failovers to potentially other datafeeds if necessary. I have found a couple potential feeds that can work as a failover in a pinch -- the question is would you rather have data that is potentially 10 pips or more off your brokers feed, or no data at all?

In most cases (depending on the strategy) I think having a general idea of where the price is, even if it's a bit off, is better than sitting blind. If we execute trades on the prices generated from the failover feed, we'll chalk up the execution price against the opening price as slippage anyway.

Automatically failing over, and then rotating back to the real feed at some point will be a technical brain teaser to solve. The most interesting piece will be making the transitions transparent to the strategies using the feed. However, I also need to bulk up my alerting system so I am aware of what's going on as needed. This will likely consist of getting email alerts sent to my phone again. As it stands, if I can get the email, I can login and respond to whatever issue may be occurring. Last but not least, I need to figure out why the feed is failing and if possible fix it.

I started what is now a half finished debugging session almost a week ago. There has been with no movement on my end to finish it. The potential for some better trading should hopefully be motivation enough to take a serious look and overhaul the alerting, failover and reporting systems I'm currently using. The importance of this infrastructure can't be understated. Now to find the time to implement.

11.10.2011

Updating the trading framework

It's been some time since I spoke about the engine behind the robots and strategies I trade. I had a wonderful coding marathon last weekend the result of which is many new improvements in the trading framework I am using. Although I solved several issues and cleaned up many things, there remains a piece I haven't quite been able to clean up.

I have the dilemma of writing code that is clean and maintainable, while having client side strategies that are really one-off programs. The server side backend pieces are abstracted away and objectified nicely, but that doesn't help with the client side implementations. Simply stated, I have a template I wish to use for all new strategies. This is easy to do. The trouble comes when I update the template (fixing a bug, adding new cool stuff, etc), the strategies of course don't get this update without me manually merging it across. This is not scalable as the number of strategies grows. The trouble with creating a generic class and having each strategy extend it is that each strategy has unique pieces and I don't believe I can abstract anymore pieces away. This is of course despite the fact each has a common workflow. Creating a generic client class is the answer (unless a programmer out there can shed some light). Regardless this is a wall that is slowing progress on new trading ideas.

2.25.2010

Of Frameworks

When one considers how to approach trading there are alot of upfront choices to be made. Which market to trade? Shall I trade or have someone or something do it for me? What philosophy or strategy will I employ with trading -- aka what edge am I seeking to profit on? My goal is to use fundamental and technical analysis to determine where edges may lie and attempt to profit from them. Since I am human, I am delegating the grunt execution to a machine, and instead employing my time to analysis. This is otherwise known as autotrading.

While there are many packages of there to support such endeavors, I have written my own framework to accomplish this. In a nutshell, I have separated out the execution layer, data layer and logic layers of a trading program. The execution layer takes care of the communication and physical trade execution at my broker. The data layer is separated out to render feeds of price and other information for use by any particular strategy I am running. Finally the logic layer is separated out into individual strategies running within the framework.

It sounds much more complicated than it really is. But having this proper framework allows me to code strategies easily; and then run them thru backtesting or live mode. I suppose I would be remiss if I didn't also mention I did this all in PERL.