コード例 #1
0
ファイル: BitfinexMethod.cs プロジェクト: 18317027820/Bitcoin
 async public void InstantUpdate_OrderBook(string id)
 {
     Queue <string> buffer   = AccessWebSocket._bufferPool[id];
     OrderBookInfo  snapShot = (OrderBookInfo)AccessWebSocket._snapShotPool[id];
     Task           tsk      = new Task(() => { while (buffer.Count == 0)
                                                {
                                                    ;
                                                }
                                                snapShot.Update(JsonConvert.DeserializeObject <PairInfo>(buffer.Dequeue())); });
     await tsk;
 }
コード例 #2
0
        static void Main(string[] args)
        {
            string         apiKey    = ConfigurationManager.AppSettings["ApiKey"];
            string         secretKey = ConfigurationManager.AppSettings["SecretKey"];
            OrderBookInfo  BTC       = new OrderBookInfo();
            BitfinexMethod method    = new BitfinexMethod("", "");

            BTC = method.GetSnapShot_OrderBook("tBTCUSD", "tBTCUSD");
            method.InstantUpdate_OrderBook("tBTCUSD");
            //Main thread to update the info at a constant frequncy
            while (true)
            {
                Thread.Sleep(1000);
                Console.WriteLine("The current price of BTC is " + BTC.asks[0].price);
            }
        }
コード例 #3
0
ファイル: BitfinexMethod.cs プロジェクト: 18317027820/Bitcoin
        public OrderBookInfo GetSnapShot_OrderBook(string symbol, string id)
        {
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("event", "subscribe");
            args.Add("channel", "book");
            args.Add("symbol", symbol);
            args.Add("prec", "P0");
            args.Add("freq", "F0");
            args.Add("len", "25");
            string        request = JsonConvert.SerializeObject(args);
            OrderBookInfo res     = GetSnapShot <OrderBookInfo>(request, symbol);

            AccessWebSocket._snapShotPool[id] = res;
            return(res);
        }