コード例 #1
0
 /// <summary>
 /// Creates new instance of <see cref="LatestDataRequest"/> object.
 /// </summary>
 /// <param name="symbol">Asset name for data retrieval.</param>
 /// <param name="exchange">Crypto exchange for data retrieval.</param>
 public LatestDataRequest(
     String symbol,
     CryptoExchange exchange)
 {
     Symbol   = symbol.EnsureNotNull(nameof(symbol));
     Exchange = exchange;
 }
コード例 #2
0
        public static (string best, string leastWorst, decimal profit) GetBestPair(
            Dictionary <CryptoExchange, Dictionary <CryptoExchange, Dictionary <string, decimal> > > compare,
            CryptoExchange from,
            CryptoExchange to
            )
        {
            var best       = compare[from][to].MaxBy(x => x.Value).Key;
            var leastWorst = compare[to][from].MaxBy(x => x.Value).Key;
            var profit     =
                (1m + compare[from][to][best])
                * (1m + compare[to][from][leastWorst])
                - 1m;

            return(best, leastWorst, profit);
        }
コード例 #3
0
        public Dictionary <CryptoExchange, Dictionary <string, decimal> > GetAll(CryptoExchange from)
        {
            if (!Exchanges.ContainsKey(from))
            {
                return(null);
            }

            var result = new Dictionary <CryptoExchange, Dictionary <string, decimal> > ( );

            foreach (var to in Exchanges.Keys)
            {
                result[to] = GetPair(from, to);
            }

            return(result);
        }
コード例 #4
0
        public Dictionary <string, decimal> GetPair(CryptoExchange from, CryptoExchange to)
        {
            if (!Exchanges.ContainsKey(from) || !Exchanges.ContainsKey(to))
            {
                return(null);
            }

            var result  = new Dictionary <string, decimal> ( );
            var symbols =
                Exchanges[from].ExchangeData.Keys
                .Intersect(Exchanges[to].ExchangeData.Keys)
                .ToList( );

            foreach (var symbol in symbols)
            {
                var buy  = Exchanges[from].ExchangeData[symbol].BuyPrice;
                var sell = Exchanges[to].ExchangeData[symbol].SellPrice;
                result[symbol] = (sell - buy) / buy;
            }

            return(result);
        }
コード例 #5
0
        public (string best, string leastWorst, decimal profit) GetBestPair(CryptoExchange from, CryptoExchange to)
        {
            var compare = GetAll( );

            return(GetBestPair(compare, from, to));
        }