Пример #1
0
        public PositionState this[string symbol]
        {
            get
            {
                PositionState state = null;
                _positions?.TryGetValue(symbol, out state);

                return(state);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public TransactionToken(PositionState pos) : this(pos.Symbol, pos.Volume, pos.Side)
 {
 }