public PositionState this[string symbol] { get { PositionState state = null; _positions?.TryGetValue(symbol, out state); return(state); } }
public List <TransactionToken> TokensToNextPositionsStates(AccountState nextState) { var tokens = new List <TransactionToken>(nextState.Symbols.Count); foreach (var symbol in Symbols.Union(nextState.Symbols)) { var token = PositionState.GetConversionToken(this[symbol], nextState[symbol]); tokens.Add(token); } return(tokens); }
public static TransactionToken GetConversionToken(PositionState current, PositionState next) { if (current == null) { return(next.Token); } if (next == null) { return(~current.Token); } return(~current.Token + next.Token); }
public TransactionToken(PositionState pos) : this(pos.Symbol, pos.Volume, pos.Side) { }