Beispiel #1
1
        public static List<CoinInformation> GetCoinInformation(string userAgent = "",
            BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new WebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string apiUrl = GetApiUrl(profitabilityBasis);

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray = JArray.Parse(jsonString);

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
            }

            return result;
        }
Beispiel #2
0
 public static string GetApiUrl(BaseCoin profitabilityBasis)
 {
     string apiUrl = "http://www.coinchoose.com/api.php";
     if (profitabilityBasis == BaseCoin.Litecoin)
         apiUrl = apiUrl + "?base=LTC";
     return apiUrl;
 }
Beispiel #3
0
        public static List <CoinInformation> GetCoinInformation(string userAgent            = "",
                                                                BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new WebClient();

            if (!string.IsNullOrEmpty(userAgent))
            {
                client.Headers.Add("user-agent", userAgent);
            }

            string apiUrl = "http://www.coinchoose.com/api.php";

            if (profitabilityBasis == BaseCoin.Litecoin)
            {
                apiUrl = apiUrl + "?base=LTC";
            }

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray  = JArray.Parse(jsonString);

            List <CoinInformation> result = new List <CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                result.Add(coinInformation);
            }

            return(result);
        }
Beispiel #4
0
        public IEnumerable<CoinInformation> GetCoinInformation(string userAgent = "",
            BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new ApiWebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string apiUrl = GetApiUrl(profitabilityBasis);

            string jsonString = client.DownloadString(apiUrl);

            JObject jsonObject = JObject.Parse(jsonString);

            if (!jsonObject.Value<bool>("Success"))
            {
                throw new CoinApiException(jsonObject.Value<string>("Message"));
            }

            JArray jsonArray = jsonObject.Value<JArray>("Data");

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
            }

            return result;
        }
Beispiel #5
0
 public string GetInfoUrl(BaseCoin profitabilityBasis)
 {
     if (profitabilityBasis == BaseCoin.Litecoin)
         return "http://coinchoose.com/litecoin.php";
     else
         return "http://coinchoose.com/index.php";
 }
Beispiel #6
0
        public IEnumerable <CoinInformation> GetCoinInformation(string userAgent            = "",
                                                                BaseCoin profitabilityBasis = BaseCoin.Bitcoin)
        {
            WebClient client = new ApiWebClient();

            if (!string.IsNullOrEmpty(userAgent))
            {
                client.Headers.Add("user-agent", userAgent);
            }

            string apiUrl = GetApiUrl(profitabilityBasis);

            string jsonString = client.DownloadString(apiUrl);
            JArray jsonArray  = JArray.Parse(jsonString);

            List <CoinInformation> result = new List <CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                {
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
                }
            }

            return(result);
        }
Beispiel #7
0
        public string GetApiUrl(BaseCoin profitabilityBasis)
        {
            string apiUrl = "http://www.coinchoose.com/api.php";

            if (profitabilityBasis == BaseCoin.Litecoin)
            {
                apiUrl = apiUrl + "?base=LTC";
            }
            return(apiUrl);
        }
Beispiel #8
0
 public string GetInfoUrl(BaseCoin profitabilityBasis)
 {
     if (profitabilityBasis == BaseCoin.Litecoin)
     {
         return("http://coinchoose.com/litecoin.php");
     }
     else
     {
         return("http://coinchoose.com/index.php");
     }
 }
Beispiel #9
0
        private void RefreshCoinStats()
        {
            //always load known coins from file
            //CoinChoose may not shown coins it once did if there are no orders
            LoadKnownCoinsFromFile();

            try
            {
                coinInformation = coinApiContext.GetCoinInformation(
                    UserAgent.AgentString,
                    engineConfiguration.StrategyConfiguration.BaseCoin).ToList();
                currentBaseCoin = applicationConfiguration.UseCoinWarzApi ? BaseCoin.Bitcoin : engineConfiguration.StrategyConfiguration.BaseCoin;
            }
            catch (Exception ex)
            {
                //don't crash if website cannot be resolved or JSON cannot be parsed
                if ((ex is WebException) || (ex is InvalidCastException) || (ex is FormatException) || (ex is Coin.Api.CoinApiException))
                {
                    if (applicationConfiguration.ShowApiErrors)
                        ShowCoinApiErrorNotification(ex);
                    return;
                }
                throw;
            }

            LoadListViewValuesFromCoinStats();
            LoadKnownCoinsFromCoinStats();
            RefreshCoinStatsLabel();
            AutoSizeListViewColumns();
            SuggestCoinsToMine();
        }
Beispiel #10
0
 public string GetInfoUrl(BaseCoin profitabilityBasis)
 {
     return(String.Format(@"http://www.coinwarz.com/cryptocurrency", apiKey));
 }
Beispiel #11
0
 public string GetApiUrl(BaseCoin profitabilityBasis)
 {
     return(String.Format(@"http://www.coinwarz.com/v1/api/profitability/?apikey={0}&algo=all", apiKey));
 }
Beispiel #12
0
 public string GetInfoUrl(BaseCoin profitabilityBasis)
 {
     return String.Format(@"http://www.coinwarz.com/cryptocurrency", apiKey);
 }
Beispiel #13
0
 public string GetApiUrl(BaseCoin profitabilityBasis)
 {
     return String.Format(@"http://www.coinwarz.com/v1/api/profitability/?apikey={0}&algo=all", apiKey);
 }