public Receiver(string uniqueName, string itemName, ITicker ticker)
 {
     Initialize(uniqueName, itemName);
     this.ticker  = ticker;
     ticker.Tick += OnTick;
     ticker.Start();
 }
示例#2
0
 public OrderBook(ITicker owner)
 {
     Owner   = owner;
     Bids    = new List <OrderBookEntry>();
     Asks    = new List <OrderBookEntry>();
     Updates = new List <OrderBookUpdateInfo>();
 }
示例#3
0
文件: NodeFactory.cs 项目: Sergyu/WMS
        public ITicker NewEndNode <T>(ITicker node) where T : class
        {
            var endNode = new ActionNode <T>();

            ((IOut <T>)node).AddChild(endNode);
            return(endNode);
        }
 public static void Unsubscribe(ITicker ticker)
 {
     if (_instance != null)
     {
         _instance._tikers.Remove(ticker);
     }
 }
示例#5
0
        public static void UpdateHistoryItem(ITicker item)
        {
            TickerHistoryItem last = item.History.Count == 0 ? null : item.History.Last();

            if (item.History.Count > 36000)
            {
                item.History.RemoveAt(0);
            }
            if (last != null)
            {
                if (last.Ask == item.LowestAsk && last.Bid == item.HighestBid && last.Current == item.Last)
                {
                    return;
                }
                item.Change = ((item.Last - last.Current) / last.Current) * 100;
                if (last.Bid != item.HighestBid)
                {
                    item.BidChange = (item.HighestBid - last.Bid) * 100;
                }
                if (last.Ask != item.LowestAsk)
                {
                    item.AskChange = item.LowestAsk - last.Ask;
                }
            }
            item.History.Add(new TickerHistoryItem()
            {
                Time = item.Time, Ask = item.LowestAsk, Bid = item.HighestBid, Current = item.Last
            });
            item.RaiseHistoryItemAdded();
        }
示例#6
0
        /// <summary>Build() 的測試虛設常式</summary>

        public ITicker BuildTest(Builder target)
        {
            ITicker result = target.Build();

            return(result);
            // TODO: 將判斷提示加入 方法 BuilderTest.BuildTest(Builder)
        }
示例#7
0
 public ErrorRateLimiter(int maxErrors, TimeSpan windowLength, TimeSpan blockOutTime, ITicker ticker = null)
 {
     MaxErrors    = maxErrors;
     WindowLength = windowLength;
     BlockOutTime = blockOutTime;
     this.ticker  = ticker ?? ClockTicker.Default;
 }
示例#8
0
        public async Task <IOrder> CheckOrder(string uuid, string symbol)
        {
            var    timestamp   = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
            string totalParams = string.Format("symbol={0}&orderId={1}&timestamp={2}", symbol, uuid, timestamp);
            string sign        = CalculateSignature(totalParams, _config.Secret);

            var data = new Dictionary <string, object> {
                { "symbol", symbol },
                { "orderId", uuid },
                { "timestamp", timestamp },
                { "signature", sign }
            };


            var order = await _binance.GetOrder(_config.ApiKey, data);

            var trades = await GetTrades(symbol, order.time);

            ITicker bnbTicker = null;

            if (symbol.Contains("BTC"))
            {
                bnbTicker = await Ticker("BNBBTC");
            }
            else if (symbol.Contains("ETH"))
            {
                bnbTicker = await Ticker("BNBETH");
            }

            return(new Order(order, trades.Where(t => t.time == order.time), bnbTicker));
        }
示例#9
0
        public StandardBehavior(Entity entiry)
        {
            _Equipment = new InventoryProxy();
            _Bag       = new InventoryProxy();
            var type = entiry.GetVisible().EntityType;

            _Messages = new Queue <string>();

            _FPS = new FPSCounter();

            _UsableSkills = new List <ACTOR_STATUS_TYPE>();

            _EntityImperils = _InitialImperil(type);
            _ActorMind      = new ActorMind(type);

            _DecisionTime = 0.5f;

            _FieldOfVision = new List <IVisible>();

            _Entiry = entiry;

            _Random = Regulus.Utility.Random.Instance;

            //asin(2 / sqrt(2 ^ 2 + 10 ^ 2))

            _Node = _BuildNode();
        }
        public void AddTicker()
        {
            ITicker ticker = _tickerFactory.GetTicker(_newName);

            _tickers.Add(new TickerViewModel(ticker));
            OnPropertyChanged("CanRemoveTicker");
        }
 public static void Subscribe(ITicker ticker)
 {
     if (_instance != null)
     {
         _instance._tikers.Add(ticker);
     }
 }
示例#12
0
文件: NodeFactory.cs 项目: Sergyu/WMS
        public ITicker NewStartNode <T>(T payload, ITicker node) where T : class
        {
            var startNode = new ActionNode <T>();

            startNode.In(new Token <T>(payload));
            startNode.AddChild((IIn <T>)node);
            return(startNode);
        }
示例#13
0
        public TickerManager(int refreshRate = 2, ILogger <ITicker> logger = null)
        {
            _logger  = logger ?? new NullLogger <ITicker>();
            _ticker  = new Ticker(this, refreshRate, logger);
            _entries = new List <ITickerManagerEntry>();

            _ticker.Start();
        }
示例#14
0
 void IParent.Add(ITicker ticker)
 {
     if (_Ticker != null)
     {
         throw new Exception("Inverse nodes only support a single node.");
     }
     _Ticker = ticker;
 }
示例#15
0
 private void Start()
 {
     _textContainer        = GetComponent <TextMeshProUGUI>();
     _textModifiersFactory = new TextModifiersFactory(_textContainer);
     _markersConverter     = new MarkersConverter();
     _ticker         = ticker.GetComponent <ITicker>();
     _ticker.OnTick += RevealNextCharacter;
 }
 public UnboundedLocalCache(Caffeine <K, V> builder, bool isAsync, int concurrencyLevel)
 {
     this.data             = new ConcurrentDictionary <K, V>(concurrencyLevel, builder.InitialCapacity);
     this.statsCounter     = builder.StatsCounter.Get();
     this.removalListener  = builder.RemovalListener;
     this.isRecordingStats = builder.IsRecordingStats;
     this.writer           = builder.Writer;
     this.ticker           = builder.Ticker;
 }
示例#17
0
 private Builder _Add(ITicker ticker)
 {
     if (_Stack.Count <= 0)
     {
         throw new Exception("Can't create an unnested ActionNode, it must be a leaf node.");
     }
     _Stack.Peek().Add(ticker);
     return(this);
 }
示例#18
0
 void ITicker.Reset()
 {
     if (_RunninTicker != null)
     {
         _RunninTicker.Reset();
         _RunninTicker = null;
     }
     _Queue.Clear();
 }
示例#19
0
 void ITicker.Reset()
 {
     if (_RunninTicker != null)
     {
         _RunninTicker.Reset();
         _RunninTicker = null;
     }
     _Queue.Clear();
 }
示例#20
0
        public TickerViewModel(ITicker ticker)
        {
            _ticker      = ticker;
            _name        = _ticker.Name;
            _price       = _ticker.Price;
            _priceChange = 0;

            _ticker.PriceChanged += Price_Changed;
        }
示例#21
0
 public TickerHub(ITicker ticker, DataContext dataContext)
 {
     this.ticker      = ticker;
     this.dataContext = dataContext;
     if (dataContext == null)
     {
         throw new ArgumentNullException("DataContext dataContext == null");
     }
 }
示例#22
0
 //Testing SparkleShare
 #region IDisposable Support
 public void Dispose()
 {
     if (_ticker != null)
     {
         _ticker.PriceChanged -= Price_Changed;
         _ticker.Dispose();
         _ticker = null;
     }
 }
示例#23
0
 public static TickerData FromTicker(ITicker ticker)
 {
     return(new TickerData
     {
         Pair = ticker.Pair,
         BidPrice = ticker.BidPrice,
         AskPrice = ticker.AskPrice,
         LastPrice = ticker.LastPrice
     });
 }
示例#24
0
	/// <summary>
	/// Determines whether this instance has ticker the specified ticker.
	/// </summary>
	/// <returns><c>true</c> if this instance has ticker the specified ticker; otherwise, <c>false</c>.</returns>
	/// <param name="ticker">Ticker.</param>
	public bool HasTicker(ITicker ticker){
            
		for (int i = 0; i < tickerList.Count; i++) {
			TickVO t = tickerList[i] as TickVO;
			if (t.ticker == ticker) {
				return true;
			}
		}
		return false;
	}
示例#25
0
 void UnsubscribeEvents(ITicker prev)
 {
     prev.OrderBook.OnChanged -= OnTickerOrderBookChanged;
     prev.Changed             -= OnTickerChanged;
     prev.HistoryItemAdd      -= OnTickerHistoryItemAdded;
     prev.TradeHistoryAdd     -= OnTickerTradeHistoryAdd;
     prev.UnsubscribeOrderBookUpdates();
     prev.UnsubscribeTickerUpdates();
     prev.UnsubscribeTradeUpdates();
 }
示例#26
0
 string GetDownloadString(ITicker ticker, string address)
 {
     try {
         return(ticker.DownloadString(address));
     }
     catch (Exception e) {
         Console.WriteLine("WebClient exception = " + e.ToString());
         return(string.Empty);
     }
 }
示例#27
0
 /// <summary>
 /// Removes the ticker.
 /// </summary>
 /// <param name="ticker">Ticker.</param>
 public void RemoveTicker(ITicker ticker)
 {
     for (int i = 0; i < tickerList.Count; i++)
     {
         TickVO t = tickerList[i] as TickVO;
         if (t.ticker == ticker)
         {
             t.ticker = null;
         }
     }
 }
示例#28
0
        public void Dispose()
        {
            if (IsBusy)
            {
                Stop();
            }

            ticker = null;

            GC.SuppressFinalize(this);
        }
        /// <summary>
        /// Log into td ameritrade
        /// </summary>
        /// <param name="token">OAuth2 Account Token</param>
        /// <returns>Is Successful</returns>
        public bool Login(string token)
        {
            //Store the token
            _AccountToken = token;

            //Setup Subclasses
            Ticker = new AmeritradeTicker();
            ((AmeritradeTicker)Ticker).SetToken(_AccountToken);

            return(true);
        }
示例#30
0
 /// <summary>
 /// Determines whether this instance has ticker the specified ticker.
 /// </summary>
 /// <returns><c>true</c> if this instance has ticker the specified ticker; otherwise, <c>false</c>.</returns>
 /// <param name="ticker">Ticker.</param>
 public bool HasTicker(ITicker ticker)
 {
     for (int i = 0; i < tickerList.Count; i++)
     {
         TickVO t = tickerList[i] as TickVO;
         if (t.ticker == ticker)
         {
             return(true);
         }
     }
     return(false);
 }
示例#31
0
 public void Remove(ITicker item)
 {
     if (item.IsInTickerListFlag == TickerFlag.TICK_FLAG_IN_LIST)
     {
         item.IsInTickerListFlag = TickerFlag.TICK_FLAG_NONE;
     }
     else if (item.IsInTickerListFlag == TickerFlag.TICK_FLAG_IN_BUFFER)
     {
         item.IsInTickerListFlag = TickerFlag.TICK_FLAG_NONE;
         m_lsAddBuffer.Remove(item);
     }
 }
示例#32
0
        public TICKRESULT Tick(float delta)
        {
            if (_RunninTicker != null)
            {
                var resultRunner = _RunninTicker.Tick(delta);

                if (resultRunner == TICKRESULT.RUNNING)
                {
                    return(TICKRESULT.RUNNING);
                }

                _RunninTicker = null;
                if (resultRunner == TICKRESULT.FAILURE)
                {
                    _Queue.Clear();
                    return(TICKRESULT.FAILURE);
                }

                if (_Queue.Count == 0)
                {
                    return(TICKRESULT.SUCCESS);
                }
            }

            if (_Queue.Count == 0)
            {
                _Reload();
            }

            _CurrentTicker = _Queue.Dequeue();
            var result = _CurrentTicker.Tick(delta);

            if (result == TICKRESULT.FAILURE)
            {
                _Queue.Clear();
                return(TICKRESULT.FAILURE);
            }


            if (result == TICKRESULT.RUNNING)
            {
                _RunninTicker = _CurrentTicker;
                return(TICKRESULT.RUNNING);
            }

            if (_Queue.Count == 0)
            {
                return(TICKRESULT.SUCCESS);
            }

            return(TICKRESULT.RUNNING);
        }
示例#33
0
	/// <summary>
	/// Adds the ticker.
	/// </summary>
	/// <param name="ticker">Ticker.</param>
	/// <param name="delayMSTime">Delay MS time.</param>
	public void AddTicker(ITicker ticker, int delayMSTime = -1){
		uint lastMSTimeStamp = (uint)(Time.realtimeSinceStartup * 1000);
		TickVO tempTicker;
		if (HasTicker(ticker)) {
			//如果已经存在,那么更新下他
			tempTicker = GetTicker(ticker);
		} else {
			//没有则新建一个
			tempTicker = new TickVO();
			tickerList.Add(tempTicker);
		}
		tempTicker.ticker = ticker;
		tempTicker.delayMSTime = delayMSTime;
		tempTicker.lastMSTimeStamp = lastMSTimeStamp;
	}
示例#34
0
        public TICKRESULT Tick(float delta)
        {
            if (_RunninTicker != null)
            {
                var resultRunner = _RunninTicker.Tick(delta);

                if (resultRunner == TICKRESULT.RUNNING)
                    return TICKRESULT.RUNNING;

                _RunninTicker = null;
                if (resultRunner == TICKRESULT.FAILURE)
                {
                    _Queue.Clear();
                    return TICKRESULT.FAILURE;
                }

                if (_Queue.Count == 0)
                {
                    return TICKRESULT.SUCCESS;
                }

            }

            if (_Queue.Count == 0)
            {
                _Reload();
            }

            var ticker = _Queue.Dequeue();
            var result = ticker.Tick(delta);
            if (result == TICKRESULT.FAILURE)
            {
                _Queue.Clear();
                return TICKRESULT.FAILURE;
            }

            if (result == TICKRESULT.RUNNING)
            {
                _RunninTicker = ticker;
                return TICKRESULT.RUNNING;
            }

            if (_Queue.Count == 0)
                return TICKRESULT.SUCCESS;

            return TICKRESULT.RUNNING;
        }
示例#35
0
 public void Add(ITicker ticker)
 {
     _Childs.Add(ticker);
 }
示例#36
0
 void IParent.Add(ITicker ticker)
 {
     if(_Ticker != null)
         throw new Exception("Inverse nodes only support a single node.");
     _Ticker = ticker;
 }
示例#37
0
	/// <summary>
	/// Removes the ticker.
	/// </summary>
	/// <param name="ticker">Ticker.</param>
	public void RemoveTicker(ITicker ticker){
		for (int i = 0; i < tickerList.Count; i++) {
			TickVO t = tickerList[i] as TickVO;
			if (t.ticker == ticker) {
				t.ticker = null;
			}
		}
	}
示例#38
0
	private TickVO GetTicker(ITicker ticker){
        if (tickerList == null) {
            return null;
        }
		for (int i = 0; i < tickerList.Count; i++) {
			TickVO t = tickerList[i] as TickVO;
			if (t.ticker == ticker) {
				return t;
			}
		}
		return null;
	}
示例#39
0
 public void Add(ITicker child)
 {
     _Childs.Add(child);
 }
        public StandardWisdom(Entity entiry)
        {
            _Equipment = new InventoryProxy();
            _Bag = new InventoryProxy();
            var type  = entiry.GetVisible().EntityType;

            _Messages = new Queue<string>();

            _FPS = new FPSCounter();

            _UsableSkills = new List<ACTOR_STATUS_TYPE>();

            _EntityImperils = _InitialImperil(type);
            _ActorMind = new ActorMind(type);

            _DecisionTime = 0.5f;

            _FieldOfVision = new List<IVisible>();

            _Entiry = entiry;

            _Random = Regulus.Utility.Random.Instance;

            //asin(2 / sqrt(2 ^ 2 + 10 ^ 2))

            _Node = _BuildNode();
        }