sclass MPM { new Set imaginaryPositions; new Set realPositions; Position newShort() { ret new Position().direction(-1); } Position newLong() { ret new Position().direction(1); } abstract class CloseReason {} class LossClose > CloseReason {} class HappyClose > CloseReason {} class RegularClose > CloseReason {} // pullback close settable double fees = 0.12; settable double minReasonableProfit = .1; // in percent before leverage class Position { settable bool real; // -1 (short) or 1 (long) settable int direction; settable double openingTime; settable double openingPrice; simplyCached double openingPriceWithFees() { ret openingPrice*(1-fees/100*direction); } settable double relativeValue; settable double maxRelativeValue; // null when position is open, not null when position was closed settable CloseReason closeReason; } }