コード例 #1
0
        private void Refresh()
        {
            if (_isRefreshing)
            {
                return;
            }

            try
            {
                _isRefreshing = true;
                var config      = _configStore.Config;
                var positionMap = new Dictionary <Broker, BrokerPosition>();
                foreach (var brokerConfig in config.Brokers.Where(b => b.Enabled))
                {
                    var currentBtc       = GetPosition(brokerConfig.Broker);
                    var allowedLongSize  = Math.Max(0, brokerConfig.MaxLongPosition - currentBtc);
                    var allowedShortSize = Math.Max(0, currentBtc + brokerConfig.MaxShortPosition);
                    var pos = new BrokerPosition
                    {
                        Broker           = brokerConfig.Broker,
                        Btc              = currentBtc,
                        LongAllowed      = allowedLongSize > 0,
                        ShortAllowed     = allowedShortSize > 0,
                        AllowedLongSize  = allowedLongSize,
                        AllowedShortSize = allowedShortSize
                    };
                    positionMap.Add(brokerConfig.Broker, pos);
                }

                PositionMap = positionMap;
                LogPositions();
            }
            finally
            {
                _isRefreshing = false;
            }
        }
コード例 #2
0
ファイル: SpreadAnalyzer.cs プロジェクト: simhaonline/rinjani
 private static bool IsAllowed(Quote q, BrokerPosition pos)
 {
     return(q.Side == QuoteSide.Bid ? pos.ShortAllowed : pos.LongAllowed);
 }