public CoinList(HttpClient client, Profile profile, int index, bool getOrderDepth) { ListOfCoins = new List<Coin>(); _client = client; UsedProfile = profile; // 0 == highest bid price, 1 == recent trade price, 2 = lowest ask price _bidRecentAsk = index; _getOrderDepth = getOrderDepth; _po = new ParallelOptions { CancellationToken = new CancellationTokenSource().Token, MaxDegreeOfParallelism = Environment.ProcessorCount * 4, }; }
private Profile GetProfileFromOldHashrates(OldHashrates hashratesTxt) { Profile profile = new Profile(); foreach (KeyValuePair<string, double> hashrate in hashratesTxt.HashRateList) { CustomAlgo algo = new CustomAlgo { Name = hashrate.Key.ToUpperInvariant(), HashRate = hashrate.Value, Wattage = hashratesTxt.WattageList[hashrate.Key], }; // I was a fool for naming the keys differently :D switch (hashrate.Key) { case "MyriadGroestl": algo.Use = hashratesTxt.CheckedHashRates["MyrGroestl"]; break; case "Nist5": algo.Use = hashratesTxt.CheckedHashRates["NIST5"]; break; case "Heavy": algo.Use = hashratesTxt.CheckedHashRates["Hefty"]; break; case "ScryptJane15": algo.Use = hashratesTxt.CheckedHashRates["Jane15"]; break; case "ScryptJane14": algo.Use = hashratesTxt.CheckedHashRates["Jane14"]; break; case "ScryptJane13": algo.Use = hashratesTxt.CheckedHashRates["Jane13"]; break; default: algo.Use = hashratesTxt.CheckedHashRates[hashrate.Key]; break; } // Grabbing these new items from the default list foreach (CustomAlgo defaultAlgo in GetDefaultProfileList()["Default"].CustomAlgoList) { if (defaultAlgo.Name == algo.Name) { algo.SynonymsCsv = defaultAlgo.SynonymsCsv; algo.Style = defaultAlgo.Style; algo.Target = defaultAlgo.Target; } } profile.CustomAlgoList.Add(algo); } return profile; }
private Dictionary<string, Profile> GetDefaultProfileList() { CustomAlgo groestl = new CustomAlgo { Use = true, Name = "GROESTL", SynonymsCsv = "", HashRate = 7.7, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo myrgroestl = new CustomAlgo { Use = true, Name = "MYR-GROESTL", SynonymsCsv = "MYRIADGROESTL", HashRate = 12.9, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo fugue = new CustomAlgo { Use = true, Name = "FUGUE", SynonymsCsv = "FUGUE256", HashRate = 93.9, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo jha = new CustomAlgo { Use = true, Name = "JHA", SynonymsCsv = "JACKPOT", HashRate = 5.6, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo nist5 = new CustomAlgo { Use = true, Name = "NIST5", SynonymsCsv = "", HashRate = 8.4, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo heavy = new CustomAlgo { Use = true, Name = "HEAVY", SynonymsCsv = "HEFTY,HEFTY1,HEAVYCOIN", HashRate = 13.1, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo x11 = new CustomAlgo { Use = true, Name = "X11", SynonymsCsv = "", HashRate = 2.6, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo x13 = new CustomAlgo { Use = true, Name = "X13", SynonymsCsv = "", HashRate = 2.0, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo x15 = new CustomAlgo { Use = true, Name = "X15", SynonymsCsv = "", HashRate = 1.5, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo quark = new CustomAlgo { Use = true, Name = "QUARK", SynonymsCsv = "", HashRate = 4.5, Wattage = 0, Style = "Classic", Target = 24 }; CustomAlgo qubit = new CustomAlgo { Use = true, Name = "QUBIT", SynonymsCsv = "", HashRate = 3.9, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo keccak = new CustomAlgo { Use = true, Name = "KECCAK", SynonymsCsv = "", HashRate = 163.1, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo scrypt = new CustomAlgo { Use = true, Name = "SCRYPT", SynonymsCsv = "", HashRate = 0.28, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo scryptn = new CustomAlgo { Use = true, Name = "SCRYPTN", SynonymsCsv = "SCRYPT-N,SCRYPT-ADAPTIVE-NFACTOR", HashRate = 0.14, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo scryptjane15 = new CustomAlgo { Use = true, Name = "SCRYPTJANE15", SynonymsCsv = "CHACHA (NF15)", HashRate = 0.0009, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo scryptjane14 = new CustomAlgo { Use = true, Name = "SCRYPTJANE14", SynonymsCsv = "CHACHA (NF14)", HashRate = 0.0034, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo scryptjane13 = new CustomAlgo { Use = true, Name = "SCRYPTJANE13", SynonymsCsv = "CHACHA (NF13)", HashRate = 0.0095, Wattage = 0, Style = "Classic", Target = 32 }; CustomAlgo cryptonight = new CustomAlgo { Use = true, Name = "CRYPTONIGHT", SynonymsCsv = "", HashRate = 0.00022, Wattage = 0, Style = "CryptoNight", Target = 0 }; CustomAlgo sha256 = new CustomAlgo { Use = false, Name = "SHA256", SynonymsCsv = "SHA-256", HashRate = 0, Wattage = 0, Style = "Classic", Target = 32 }; BindingList<CustomAlgo> algoList = new BindingList<CustomAlgo> { groestl, myrgroestl, fugue, jha, nist5, heavy, x11, x13, x15, quark, qubit, keccak, scrypt, scryptn, scryptjane15, scryptjane14, scryptjane13, cryptonight, sha256 }; Profile defaultProfile = new Profile { FiatOfChoice = 0, FiatPerKwh = 0.1, Multiplier = 1, CustomAlgoList = algoList }; Dictionary<string, Profile> defaultProfileList = new Dictionary<string, Profile> { {"Default", defaultProfile} }; return defaultProfileList; }
public List<Coin> CalculatePrices(bool useWeightedCalculation, bool useFallThroughPrice, bool calcFiat, bool use24HDiff, Profile profileToUse) { List<Coin> coinList = JsonControl.DeepCopyTrick<List<Coin>>(ListOfCoins); Parallel.ForEach(coinList, coin => { foreach (CustomAlgo algo in profileToUse.CustomAlgoList) { if (CheckUsedAlgo(coin.Algo, algo)) { coin.UsedInCoinlist = true; coin.CalcProfitability(algo.HashRate, useWeightedCalculation, useFallThroughPrice, profileToUse.Multiplier, algo.Style, algo.Target, use24HDiff); if (calcFiat) { double fiatElectricityCost = (algo.Wattage/1000)*24*profileToUse.FiatPerKwh; switch (profileToUse.FiatOfChoice) { case 1: coin.ElectricityCost = (fiatElectricityCost/_eurPrice); coin.BtcPerDay -= coin.ElectricityCost; break; case 2: coin.ElectricityCost = (fiatElectricityCost/_gbpPrice); coin.BtcPerDay -= coin.ElectricityCost; break; case 3: coin.ElectricityCost = (fiatElectricityCost/_cnyPrice); coin.BtcPerDay -= coin.ElectricityCost; break; default: coin.ElectricityCost = (fiatElectricityCost/_usdPrice); coin.BtcPerDay -= coin.ElectricityCost; break; } coin.UsdPerDay = coin.BtcPerDay*_usdPrice; coin.EurPerDay = coin.BtcPerDay*_eurPrice; coin.GbpPerDay = coin.BtcPerDay*_gbpPrice; coin.CnyPerDay = coin.BtcPerDay*_cnyPrice; } break; } } }); return coinList.AsParallel().Where(coin => coin.UsedInCoinlist).ToList(); }