Forums  > Software  > Trading Agents Classes  
     
Page 1 of 1
Display using:  

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2005-02-11 14:34

just this morning I was thinking about this...i would like to build some classes that model trading agents, strategies, orders, PL, ....etc....probably a lot has been done on this, but, what I'd like to model is A trader/investment manager that has a strategy, a market of focus, and who executes orders as part of a tactical framework for implementing a strategy.

I want the following concepts/classes/structs/enums ironed out....

class MarketState

class PredictionModelParams

enum OrderType

class Order

class Strategy

class Agent

An agent uses a strategy, a strategy involves placing orders based on Market States and predicted model parameters, PL is produced, etc etc....I have some basic ideas, but....at the end of the day, what I'd like to do is to use the framework to "test" strategies in a way that I don't need to change the interface of the testing framework.

this must be very six months ago and there must be a ton of free classes floating around...

Feel free to add, comment, or point links to this, otherwise I'll continue to just add a bunch of ideas myself.

 


Chiral is Tyler Durden

dgn2


Total Posts: 2054
Joined: May 2004
 
Posted: 2005-02-11 15:54

Here is a hierarchy of agents – albeit with some academic sounding names – presented in the book “Trading & Exchanges”. This is where I started when I was trying to define agents for my own modeling attempts. I don’t yet have the kind of simulation environment you are thinking about, but I am sure someone here does.

Some of these objects, classes and methods for the strategy development are being developed where I work.


...WARNING: I am an optimal f'er

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2005-02-11 15:59
thanks dgn2, and, I beg to differ, "Gambler" doesn't sound too academic for me....then again, i was an academic....

Chiral is Tyler Durden

dgn2


Total Posts: 2054
Joined: May 2004
 
Posted: 2005-02-11 16:06

I recently started this process by defining a set of trading simulation objects, classes (i.e.,  trade->position->instrument->child trading book->parent trading book, etc...) and methods. I have yet to do the order types, but the idea is that you want to be able to pass a liquidity demanding or liquidity supplying key and have the simulation do the appropriate orders (starting with just simple limit and market orders).


...WARNING: I am an optimal f'er

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2005-02-11 16:09

I'm sure you are way up on the curve....as you can see....

 


class MarketConditions;
class ModelParameterEstimates;

enum BuySell{Buy,Sell};
enum OrderType{Limit,Market,/*other types that I don't know*/};
struct Order
{
 CTime theOrderPlacementTime;
 BuySell theBuySell;
 OrderType theOrderType;
 CString theSymbol;
 double theOrderSize;
 CTime theOrderExecutionTime;
 bool theExecution;
 CTime theOrderExpiration;
 double theUnitTransactionCost;
 
}


class Strategy{
public:
 Strategy();


 void PlaceOrders(CTime& PresentTime,MarketConditions& theMarket,ModelParameterEstimates& theParams);
 bool Executed();
 double Cost();


public:
};


class Agent{
 Agent(Strategy& theStrategy);
 Agent();
 Agent(Agent& a);

 double ProfitAndLoss(CTime& StartTime,CTime& EndTime);
 double Position(CTime& theTime);
 double PositionValue(CTime& theTime);

 //other stuff.....
};

//a=a etc....

 

I haven't gotten very far and I can see that it can rapidly spiral into an unweildy mess unless I have an army of OO designers....

 


Chiral is Tyler Durden

kr
Founding Member
NP Raider
Total Posts: 3561
Joined: Apr 2004
 
Posted: 2005-02-11 16:19

I have some thoughts on this, and think it's an interesting project, but rather than start with the ubermodel I think it's better to start very small and see what you need.  Just to track back a little, I think Farmer's comment that "microstructure matters" is really where it's at.  I like microstructure theory because I think there are statistical-mechanics things you can do.  But you should really familiarize yourself with the early theory first, to get a feel for the different stylized models - i.e. walk before you run.  The idiot's guide is the poorly-written O'Hara microstructure book... really, it's not good, but I don't think there's a better source which includes the main stuff in such a short book.  If I had time I'd braise this thing for a while and cook up my own lecture notes.


my bank got pwnd

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2005-02-11 16:22
anyway, anyone who is interested in doing a collaboration on this...you know, maybe spending 10 minutes a day....maybe something can be constructed that would be useful for a number of purposes.

Chiral is Tyler Durden

kr
Founding Member
NP Raider
Total Posts: 3561
Joined: Apr 2004
 
Posted: 2005-02-11 16:37
I will try to get my copy of O'Hara to Kinko's, drop off a copy w/ you v voskesenya mozhet byt... will be like lec notes for a class.  I am a bit inspired to build this kind of thing and apply some of the patterns stuff I am absorbing thru MJ's book.  Plus, even though other forum members might recommend against it, I want to digest some of the Farmer material on this.  My purpose for this is to make better decisions on illiquid positions, where the market moves much faster than the trade frequency - i.e. I don't want to do the OANDA thing all over again, thought I'd buy their book to try some of this stuff out.  Another thing, on some of the illiquid equity I own in the p.a., I get a big kick out of watching robots update their quotes and play mineseeker.  You put in a limit, they move their limit, you move your limit, they move theirs... very amusing.

Just to improve my credibility, which isn't very good on NP projects, I've been spending 90mins/day since Jan on various C++ projects.  Foolishly I have also committed myself to CFA L2 (it was a bet!), anyhow point is that I am locking myself down to various things right now and can schedule/diversify into perhaps one more motivating project.  This would be a good one.

my bank got pwnd

etuka2


Total Posts: 155
Joined: Jun 2004
 
Posted: 2005-02-11 18:19
Nonius: I would be interested in this project. If it suits, let me know what you have, at etukanpgmailcom

kr: Is that Doyne Farmer on microstructure, or crazy Farmer from w/mot?

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2005-02-11 18:21

D. Farmer just wrote a paper about microstructure dynamics relating zero intelligence assumptions about agents and how it can "predict" spread and vol dynamics....I think that is what he is referring to.

All I have so far is what is here....really nothing, but, I have been thinking about it in my head..haven't written things down.


Chiral is Tyler Durden

kr
Founding Member
NP Raider
Total Posts: 3561
Joined: Apr 2004
 
Posted: 2005-02-11 18:22
most definitely not MP - I mean DF as related to the 'zero intel traders' thread elsewhere

my bank got pwnd

etuka2


Total Posts: 155
Joined: Jun 2004
 
Posted: 2005-02-11 19:29
I'll go and look for the paper from that thread, then.

etuka2


Total Posts: 155
Joined: Jun 2004
 
Posted: 2005-02-11 19:42
Just read the thread. It funny.

etuka2


Total Posts: 155
Joined: Jun 2004
 
Posted: 2005-02-11 19:44
Anyway, as Kr says, best to start with a concrete implementation of something, get a feel for the important stuff, then start abstracting away. There was talk of doing a adaptive agents simulation at SantaFe, that I came across some time ago. I couldn't find exactly what I was looking for, but I did find this, which seems to be related or a follow-up and maybe interesting.

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2011-04-29 22:36
this has cropped up again for me.

what I'm attempting to do is build a simple quasi agent based simulation engine. envisage a directed graph whose nodes represent leveraged investors. let's say the bottom nodes, ie, leaves, are traded securities, ie, stocks, bonds etc. first layer above consists of leveraged funds that invest in those traded securities. second layer consists of funds that invest in those funds. third layer consists of investors in those fund of funds; some of those final investors might be hedging products such as CPPI and some might be leveraged themselves.

I think simulate over delta T the changes in prices at the bottom layer. then, owing to:
1. immediate demands of margin calls of financing agents, ie, banks.
2. liquidity needs of investors who enter redemptions (or sell assets).

there is a ripple down domino effect to the bottom leaves. but, an adjustment occurs as follows.

if the rippling down creates redemptions + margin call requests by financing agents for some of the funds that invest in the securiites, and creates subscriptions and margin call requests by some of the funds

then, the investment manager agents enter sell orders for portfolios of securities to drum up liquidity or buy orders to utilize excess liquidity.
I'd then keep a simple order book for each security below and if the net order is sell, then I'd adjust the downward the prices of those securities. anyone seen anything like this? amongst some other technical issues, one question I'd have is....how to model how much to shock down the security prices?

Chiral is Tyler Durden

MrMagoo


Total Posts: 191
Joined: Jan 2008
 
Posted: 2011-04-30 16:44
I suggest you to read chapter 6 ( " Herding in Finance, Stock Market Crashes, Frenzies and Bank Runs" ) of the ( 2001 ) book "Asset Pricing under Asymmetric Information" by Markus Brunnermeier, Oxford Press, for an overview.

Yes, it is neoclassical finance Hammertime , but this chapter has a nice survey , with market-microstructure insights and ideas you can fine-tune, or modify to your agent sim.


edit :

download this chapter for free : http://www.princeton.edu/~markus/research/papers/book_chapter6.pdf


"One who says it can't be done should not interrupt the person doing it."

Nonius
Founding Member
Nonius Unbound
Total Posts: 12681
Joined: Mar 2004
 
Posted: 2011-04-30 23:10
thanks. the book is available electronically too; I'll check it out.

Chiral is Tyler Durden
Previous Thread :: Next Thread 
Page 1 of 1