Beispiel #1
0
        public void UpdateTokenPairRate(TokenPairRateData tokenPairRateData)
        {
            Console.WriteLine("Sending Rate Update to {0} for {1} Bid/Offer {2}/{3}",
                              SessionId, tokenPairKey, tokenPairRateData.BidRate, tokenPairRateData.AskRate);

            _hub.Clients.Client(SessionId).SendAsync("broadcastTokenPairRateUpdate", tokenPairRateData);
        }
Beispiel #2
0
 // This is receiving all rate updates, so it must filter for the appropriate token pair updates
 public void UpdateTokenPairRate(TokenPairRateData tokenPairRateData)
 {
     if (tokenPairRateData.Token1Id.Equals(Token1Id) && tokenPairRateData.Token2Id.Equals(Token2Id))
     {
         tokenPairSubject.OnNext(tokenPairRateData);
     }
 }
Beispiel #3
0
        private void _rateServiceClient_TokenPairRateUpdateReceived(object sender, TokenPairRateUpdateReceivedEventArgs e)
        {
            TokenPairRateData tokenPairRateRecord = e.TokenPairRateRecord;

            if (tokenPairRateRecord != null)
            {
                if (_tokenPairRateSubject != null)
                {
                    _tokenPairRateSubject.OnNext(tokenPairRateRecord);
                }

                //Console.WriteLine("Token Pair Update for {0}/{1}  Bid/Offer {2}/{3}", tokenPairRateRecord.Token1Id, tokenPairRateRecord.Token2Id,
                //    tokenPairRateRecord.BidRate, tokenPairRateRecord.AskRate);
            }
            else
            {
                Console.WriteLine("Token Pair Update with unknown content");
            }
        }
Beispiel #4
0
        public TokenPairRateData GetTokenPairRate(string token1Id, string token2Id)
        {
            TokenPairRateData tokenPairRateData = null;

            // This will need to be changed to a subscription, otherwise there will be a lag on each invocation
            // which is not acceptable.
            // Todo: Replace this with a subscription to a service reference that is listening to the rates rather than
            // asking for the rate and waiting.

            try
            {
                CheckConnectionStatus();

                tokenPairRateData = _rateServiceClient.GetTokenPairRate(token1Id, token2Id);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error: Token Pair Rate Unavailable {0}/{1}", token1Id, token2Id), ex);
            }

            return(tokenPairRateData);
        }
Beispiel #5
0
 public void TokenPairRateUpdate(TokenPairRateData TokenPairRateRecord)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
        static void TestRateManager()
        {
            RateService.RateServiceClient client = new RateServiceClient();

            Console.WriteLine("Get the Token Rate List");

            foreach (TokenRateData t in client.GetTokenRateListAsync().GetAwaiter().GetResult())
            {
                Console.WriteLine("Token {0} Bid/Ask {1}/{2}", t.TokenId, t.BidRate, t.AskRate);
            }


            Console.WriteLine("Testing Token Pair Rate Data for @[email protected]");

            TokenPairRateData tokenPairRateData = client.GetTokenPairRateAsync("@AAPL", "@BT.A").GetAwaiter().GetResult();


            Console.WriteLine("Token Pair Rates");
            Console.WriteLine("Token Pair {0}/{1}  Bid/Offer {2}/{3}", tokenPairRateData.Token1Id, tokenPairRateData.Token2Id,
                              tokenPairRateData.BidRate, tokenPairRateData.AskRate);
            Console.WriteLine("Token1 {0}  Bid/Offer {1}/{2}", tokenPairRateData.Token1Id, tokenPairRateData.Token1BidRate, tokenPairRateData.Token1AskRate);
            Console.WriteLine("Token2 {0}  Bid/Offer {1}/{2}", tokenPairRateData.Token2Id, tokenPairRateData.Token2BidRate, tokenPairRateData.Token2AskRate);

            Console.WriteLine();
            Console.WriteLine("Cross Currency Rates");
            Console.WriteLine("Currency Pair {0}-{1} Bid/Offer {2}/{3}", tokenPairRateData.Currency1, tokenPairRateData.Currency2, tokenPairRateData.CurrencyPairBidRate, tokenPairRateData.CurrencyPairAskRate);
            Console.WriteLine("Token1 Price Currency {0} Bid/Offer {1}/{2}", tokenPairRateData.Currency1, tokenPairRateData.Currency1BidRate, tokenPairRateData.Currency1AskRate);
            Console.WriteLine("Token2 Price Currency {0} Bid/Offer {1}/{2}", tokenPairRateData.Currency2, tokenPairRateData.Currency2BidRate, tokenPairRateData.Currency2AskRate);

            Console.WriteLine("Press Any Key");
            Console.ReadKey();

            Console.WriteLine();
            Console.WriteLine("GetTokenDetail Test @AAPL");

            TokenDetail tokenDetailRecord = client.GetTokenDetailAsync("@AAPL").GetAwaiter().GetResult();

            Console.WriteLine("Token Detail for {0}  TradingView Symbol {1}", tokenDetailRecord.TokenId, tokenDetailRecord.TradingViewSymbol);
            Console.WriteLine("Press Any Key");
            Console.ReadKey();



            //Console.WriteLine("Test the Get List Methods");

            //var assetList = client.GetAssetListAsync().GetAwaiter().GetResult();

            //foreach (string s in assetList)
            //    Console.WriteLine("Asset {0} returned", s);

            //var tokenList = client.GetTokenListAsync().GetAwaiter().GetResult();
            //foreach (string s in tokenList)
            //    Console.WriteLine("Token {0} returned", s);

            //Console.WriteLine("Press any key to continue");
            //Console.ReadKey();

            //Console.WriteLine("Asset Subscription Test");

            #region Test Asset Rate Subscription
            //client.AssetRateUpdateReceived += Client_AssetRateUpdateReceived;
            //client.SubscribeToAssetRateUpdateAsync("GOOG");
            //client.SubscribeToAssetRateUpdateAsync("AAPL");

            //Console.WriteLine("Press any key to continue");
            //Console.ReadKey();

            //client.UnSubscribeToAssetRateUpdateAsync("GOOG");
            //client.UnSubscribeToAssetRateUpdateAsync("AAPL");
            #endregion

            //Console.WriteLine("Token Subscription Test");
            //Console.ReadKey();

            #region Test Token Rate Subscription
            //client.TokenRateUpdateReceived += Client_TokenRateUpdateReceived;

            //client.SubscribeToTokenRateUpdateAsync("@GOOG");
            //client.SubscribeToTokenRateUpdateAsync("@AAPL");

            //Console.WriteLine("Press any key to continue");
            //Console.ReadKey();

            //client.UnSubscribeToTokenRateUpdateAsync("@GOOG");
            //client.UnSubscribeToTokenRateUpdateAsync("@AAPL");
            #endregion

            //Console.WriteLine("Test Completed");


            //Console.WriteLine("Currency Pair Subscription Test");
            //Console.ReadKey();

            //client.CurrencyPairRateUpdateReceived += Client_CurrencyPairRateUpdateReceived;
            //client.SubscribeToCurrencyPairRateUpdateAsync("EUR", "USD");

            //Console.WriteLine("Subscribing to currency pair EUR/USD");
            //Console.ReadKey();

            //client.UnSubscribeToCurrencyPairRateUpdateAsync("EUR", "USD");
            //Console.WriteLine("Unsubscribed from EUR/USD");
            //Console.ReadKey();


            Console.WriteLine("Token Pair Subscription Test");
            Console.ReadKey();

            client.TokenPairRateUpdateReceived += Client_TokenPairRateUpdateReceived;
            client.SubscribeToTokenPairRateUpdateAsync("@AAPL", "@BT.A");
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();

            client.UnSubscribeToTokenPairRateUpdateAsync("@AAPL", "@BT.A");

            Console.WriteLine("Unsubscribed from @AAPL/@BT.A");


            Console.WriteLine("Test completed ...");

            Console.ReadKey();
        }