void CoinToMonitor_onPriceUpdate( Coin coin) { TradingPair bestEthPair = coin.Best(Coin.ethereum, sellVsBuy: true); decimal currentValue = bestEthPair.bidPrice; decimal goalInEth = coinToTargetEthPrice[coin]; if (currentValue >= goalInEth) { // Alarm when the price increases above the goal decimal percentProfit = currentValue / goalInEth - 1; decimal usd = currentValue * ethToUsd; Console.WriteLine($@" ============================================================== Price is up for {coin.fullName} ({currentValue} ETH / {usd:C}), make {percentProfit:p2}... GO GO GO! ============================================================== "); // Only alarm once coin.onPriceUpdate -= CoinToMonitor_onPriceUpdate; } else { Console.Write("."); } }
public void Idex() { ExchangeMonitorConfig config = new ExchangeMonitorConfig(ExchangeName.Idex); monitor = new ExchangeMonitor(config); Coin omg = Coin.FromName("OmiseGO"); TradingPair pair = omg.Best(Coin.ethereum, true); Assert.IsTrue(pair.askPrice > 0); }
public void AEX() { ExchangeMonitorConfig config = new ExchangeMonitorConfig(ExchangeName.AEX); monitor = new ExchangeMonitor(config); Coin ardor = Coin.FromName("Ardor"); TradingPair pair = ardor.Best(Coin.bitcoin, true); Assert.IsTrue(pair.askPrice > 0); }
public void CryptopiaMyWish() { ExchangeMonitorConfig config = new ExchangeMonitorConfig(ExchangeName.Cryptopia); monitor = new ExchangeMonitor(config); Coin wish = Coin.FromName("MyWish"); TradingPair pair = wish.Best(Coin.bitcoin, true); Assert.IsTrue(pair.askPrice > 0); }
public void BitcoinPairs() { monitor = new ExchangeMonitor( new ExchangeMonitorConfig( ExchangeName.Binance, ExchangeName.Cryptopia, ExchangeName.Kucoin)); Coin ark = Coin.FromName("Ark"); TradingPair pair = Coin.bitcoin.Best(ark, true); Assert.IsTrue(pair == null); TradingPair otherPair = ark.Best(Coin.bitcoin, true); Assert.IsTrue(otherPair != null); }
public void CryptopiaClosedBooks() { monitor = new ExchangeMonitor( new ExchangeMonitorConfig(exchangeName)); Coin doge = Coin.FromName("Dogecoin"); Assert.IsTrue(doge != null); Coin monero = Coin.FromName("Monero"); Assert.IsTrue(monero != null); TradingPair pair = monero.Best(doge, true); Assert.IsTrue(pair == null || pair.isInactive); Coin omg = Coin.FromName("OmiseGo"); Assert.IsTrue(omg != null); TradingPair omgPair = omg.Best(doge, true); Assert.IsTrue(omgPair == null || omgPair.isInactive); }
void AddMonitor( string coinFullName) { Coin coinToMonitor = Coin.FromName(coinFullName); decimal goalInEth; { // Target a tiny price increase so that the test completes quickly TradingPair bestEthPair = coinToMonitor.Best(Coin.ethereum, sellVsBuy: true); decimal originalValue = bestEthPair.bidPrice; goalInEth = originalValue * 1.0001m; decimal usd = originalValue * ethToUsd; Console.WriteLine($"Goal for {coinToMonitor.fullName}: {goalInEth} ETH (original: {originalValue} / {usd:C})"); } coinToTargetEthPrice.Add(coinToMonitor, goalInEth); // Add USD (Goal: Alarm when USD and ETH are up) // Should just mean adding GDax coinToMonitor.onPriceUpdate += CoinToMonitor_onPriceUpdate; }
List <string> DescribeCoin( object coinName, out Coin coin) { List <string> results = new List <string>(); results.Add((string)coinName); // A results.Add(null); // B results.Add(null); // C results.Add(null); // D results.Add(null); // E const int bestBidBTC = 5; results.Add(""); // F const int bestBidBTCUSD = 6; results.Add(""); // G const int bestBidBTCExchange = 7; results.Add(""); // H const int bestAskBTC = 8; results.Add(""); // I const int bestAskBTCUSD = 9; results.Add(""); // J const int bestAskBTCExchange = 10; results.Add(""); // K const int bestBidETH = 11; results.Add(""); // L const int bestBidETHUSD = 12; results.Add(""); // M const int bestBidETHExchange = 13; results.Add(""); // N const int bestAskETH = 14; results.Add(""); // O const int bestAskETHUSD = 15; results.Add(""); // P const int bestAskETHExchange = 16; results.Add(""); // Q coin = Coin.FromName((string)coinName); if (coin == null) { return(results); } TradingPair bestBtcBid = coin.Best(Coin.bitcoin, true); if (bestBtcBid != null) { results[bestBidBTC] = bestBtcBid.bidPrice.ToString(); TradingPair bestBtcUsdBid = Coin.bitcoin.Best(Coin.usd, true); if (bestBtcUsdBid != null) { results[bestBidBTCUSD] = (bestBtcUsdBid.bidPrice * bestBtcBid.bidPrice).ToString(); } results[bestBidBTCExchange] = bestBtcBid.exchange.exchangeName.ToString(); } TradingPair bestBtcAsk = coin.Best(Coin.bitcoin, false); if (bestBtcAsk != null) { results[bestAskBTC] = bestBtcAsk.askPrice.ToString(); TradingPair bestBtcUsdAsk = Coin.bitcoin.Best(Coin.usd, false); if (bestBtcUsdAsk != null) { results[bestAskBTCUSD] = (bestBtcUsdAsk.askPrice * bestBtcAsk.askPrice).ToString(); } results[bestAskBTCExchange] = bestBtcAsk.exchange.exchangeName.ToString(); } TradingPair bestEthBid = coin.Best(Coin.ethereum, true); if (bestEthBid != null) { results[bestBidETH] = bestEthBid.bidPrice.ToString(); TradingPair bestEthUsdBid = Coin.ethereum.Best(Coin.usd, true); if (bestEthUsdBid != null) { results[bestBidETHUSD] = (bestEthUsdBid.bidPrice * bestEthBid.bidPrice).ToString(); } results[bestBidETHExchange] = bestEthBid.exchange.exchangeName.ToString(); } TradingPair bestEthAsk = coin.Best(Coin.ethereum, false); if (bestEthAsk != null) { results[bestAskETH] = bestEthAsk.askPrice.ToString(); TradingPair bestEthUsdAsk = Coin.ethereum.Best(Coin.usd, false); if (bestEthUsdAsk != null) { results[bestAskETHUSD] = (bestEthUsdAsk.askPrice * bestEthAsk.askPrice).ToString(); } results[bestAskETHExchange] = bestEthAsk.exchange.exchangeName.ToString(); } return(results); }
AboutCoin DescribeCoin( object coinName) { AboutCoin about = new AboutCoin(); Coin coin = Coin.FromName((string)coinName); if (coin == null) { return(about); } if (coin.hasValidTradingPairs == false) //&& coin.coinMarketCapData == null) { return(null); } about.columns[(int)Column.CoinName] = coin.fullName; TradingPair bestBtcBid = coin.Best(Coin.bitcoin, true); if (bestBtcBid != null) { about.columns[(int)Column.BestBidBTC] = bestBtcBid.bidPrice.ToString(); about.columns[(int)Column.BestBidBTCExchange] = bestBtcBid.exchange.exchangeName.ToString(); TradingPair bestBtcUsdBid = Coin.bitcoin.Best(Coin.usd, true); if (bestBtcUsdBid != null) { about.columns[(int)Column.BestBidBTCUSD] = (bestBtcUsdBid.bidPrice * bestBtcBid.bidPrice).ToString(); } } TradingPair bestBtcAsk = coin.Best(Coin.bitcoin, false); if (bestBtcAsk != null) { about.columns[(int)Column.BestAskBTC] = bestBtcAsk.askPrice.ToString(); about.columns[(int)Column.BestAskBTCExchange] = bestBtcAsk.exchange.exchangeName.ToString(); TradingPair bestBtcUsdAsk = Coin.bitcoin.Best(Coin.usd, false); if (bestBtcUsdAsk != null) { about.columns[(int)Column.BestAskBTCUSD] = (bestBtcUsdAsk.askPrice * bestBtcAsk.askPrice).ToString(); } } TradingPair bestEthBid = coin.Best(Coin.ethereum, true); if (bestEthBid != null) { about.columns[(int)Column.BestBidETH] = bestEthBid.bidPrice.ToString(); about.columns[(int)Column.BestBidETHExchange] = bestEthBid.exchange.exchangeName.ToString(); TradingPair bestEthUsdBid = Coin.ethereum.Best(Coin.usd, true); if (bestEthUsdBid != null) { about.columns[(int)Column.BestBidETHUSD] = (bestEthUsdBid.bidPrice * bestEthBid.bidPrice).ToString(); } } TradingPair bestEthAsk = coin.Best(Coin.ethereum, false); if (bestEthAsk != null) { about.columns[(int)Column.BestAskETH] = bestEthAsk.askPrice.ToString(); about.columns[(int)Column.BestAskETHExchange] = bestEthAsk.exchange.exchangeName.ToString(); TradingPair bestEthUsdAsk = Coin.ethereum.Best(Coin.usd, false); if (bestEthUsdAsk != null) { about.columns[(int)Column.BestAskETHUSD] = (bestEthUsdAsk.askPrice * bestEthAsk.askPrice).ToString(); } } TradingPair bestUsdBid = coin.Best(Coin.usd, true); if (bestUsdBid != null) { about.columns[(int)Column.BestBidUSD] = bestUsdBid.bidPrice.ToString(); about.columns[(int)Column.BestBidUSDExchange] = bestUsdBid.exchange.exchangeName.ToString(); } TradingPair bestUsdAsk = coin.Best(Coin.usd, false); if (bestUsdAsk != null) { about.columns[(int)Column.BestAskUSD] = bestUsdAsk.askPrice.ToString(); about.columns[(int)Column.BestAskUSDExchange] = bestUsdAsk.exchange.exchangeName.ToString(); } if (coin.coinMarketCapData != null) { about.columns[(int)Column.MarketCapUSD] = coin.coinMarketCapData.market_cap_usd ?? "?"; } return(about); }