qstrader icon indicating copy to clipboard operation
qstrader copied to clipboard

More attributes needed in Position class

Open nwillemse opened this issue 8 years ago • 2 comments

There are a few attributes needed in the position class for statistics, etc:

  1. entry_datetime: when the position was first opened
  2. exit_datetime: end the position was closed
  3. trade_pct: trade percentage ( avg_sld / avg_bot -1 )
  4. bars_in_trade: how long the position was open for in terms of bars
  5. mfe: maximum favorable excursion
  6. mae: maximum adverse excursion

Some of these can be calculated later on (i.e in the Statistics class), but I think it might be needed somewhere else in the system and the best place is probably Position class.

I can do some of this, but I believe we have some PR's pending?

nwillemse avatar Aug 04 '16 20:08 nwillemse

Exit is not necessary binary... There is for example partial close and we need a way to handle this

I'm not in favor of this bars_in_trade because you can backtest using tick data.

Not sure if MFE and MAE should be store here.

femtotrader avatar Aug 04 '16 20:08 femtotrader

I believe that what you suggest is more appropriate to trades than to positions.

I don't know if it's been discussed somewhere, but it would be good to separate the trades from the positions, as positions (ie, per instrument) are in my opinion simply a view of the currently open trades P&L. Trades objects could contain a tag attribute (a dict) to allow users to compute views per whatever they want (eg, system name, a spread/combo, sector, etc.). Any thoughts on this?

alexispetit avatar Aug 05 '16 15:08 alexispetit