예제 #1
0
 private void OnPriceUpdate(IScriptTick e)
 {
     if (PriceUpdate != null)
     {
         PriceUpdate(this, e);
     }
 }
예제 #2
0
        public IScriptTick GetTicker(IScriptMarket market)
        {
            IScriptTick ticker = null;

            Console.Out.WriteLine("GetTicker");

            try
            {
                Market  instrument = _markets.Find(c => c.PrimaryCurrency == market.PrimaryCurrency && c.SecondaryCurrency == market.SecondaryCurrency);
                JObject response   = (JObject)Call("GetLevel1", new ApexL1SnapshotRequest(1, instrument.InstrumentId));

                ticker = new Ticker(response, market.PrimaryCurrency, market.SecondaryCurrency);

                if (_level2Subscriptions.Contains(market.PrimaryCurrency + market.SecondaryCurrency) == false)
                {
                    Call("SubscribeLevel1", new ApexSubscribeLevel1(1, instrument.InstrumentId));
                    _level1Subscriptions.Add(market.PrimaryCurrency + market.SecondaryCurrency);
                }
            }
            catch (Exception e)
            {
                OnError(e.Message);
            }

            return(ticker);
        }
        private void AssertTick(IScriptTick tick)
        {
            Assert.IsNotNull(tick, "Bad API response");
            Assert.IsTrue(tick.Close > 0.0M, "Close price is zero");

            if (tick.BuyPrice != 0.0M)
            {
                Assert.IsTrue(tick.BuyPrice > tick.SellPrice, "Buy and sell price reversed");
            }
        }
        public IScriptTick GetTicker(IScriptMarket market)
        {
            IScriptTick ticker = null;

            try
            {
                var response = Query(false, "/spot/v3/instruments/", new Dictionary <string, string>()
                {
                    { "market", market.SecondaryCurrency.ToUpper() + "-" + market.PrimaryCurrency.ToUpper() },
                });

                if (response != null && response.Value <bool>("success"))
                {
                    ticker = new Ticker(response.Value <JObject>("result"), market.PrimaryCurrency, market.SecondaryCurrency);
                }
            }
            catch (Exception e)
            {
                OnError(e.Message);
            }

            return(ticker);
        }