public void TestBuildVircurexPublicUrl() { string url = VircurexExchange.BuildUrl(VircurexExchange.Method.orderbook, VircurexExchange.Format.Json); Assert.AreEqual("https://api.vircurex.com/api/orderbook.json", url); }
public static void Main() { try { using (BterExchange bter = new BterExchange()) { using (CoinExExchange coinEx = new CoinExExchange()) { PublicPrivateKeyPair cryptsyConfiguration = LoadPublicPrivateKeyPair(CRYPTSY_CONFIGURATION_FILENAME); using (CryptsyExchange cryptsy = new CryptsyExchange() { PublicKey = cryptsyConfiguration.PublicKey, PrivateKey = cryptsyConfiguration.PrivateKey } ) { PublicPrivateKeyPair vaultOfSatoshiConfiguration = LoadPublicPrivateKeyPair(VAULT_OF_SATOSHI_CONFIGURATION_FILENAME); using (VoSExchange vaultOfSatoshi = new VoSExchange() { PublicKey = vaultOfSatoshiConfiguration.PublicKey, PrivateKey = vaultOfSatoshiConfiguration.PrivateKey } ) { using (VircurexExchange vircurex = new VircurexExchange()) { DoAnalysis(new List <IExchange>() { vaultOfSatoshi, bter, coinEx, cryptsy, vircurex }); } } } } } } catch (ExchangeConfigurationException e) { Console.WriteLine(e.Message); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public static void Main() { try { using (BterExchange bter = new BterExchange()) { using (CoinExExchange coinEx = new CoinExExchange()) { PublicPrivateKeyPair cryptsyConfiguration = LoadPublicPrivateKeyPair(CRYPTSY_CONFIGURATION_FILENAME); using (CryptsyExchange cryptsy = new CryptsyExchange() { PublicKey = cryptsyConfiguration.PublicKey, PrivateKey = cryptsyConfiguration.PrivateKey } ) { PublicPrivateKeyPair vaultOfSatoshiConfiguration = LoadPublicPrivateKeyPair(VAULT_OF_SATOSHI_CONFIGURATION_FILENAME); using (VoSExchange vaultOfSatoshi = new VoSExchange() { PublicKey = vaultOfSatoshiConfiguration.PublicKey, PrivateKey = vaultOfSatoshiConfiguration.PrivateKey } ) { using (VircurexExchange vircurex = new VircurexExchange()) { DoAnalysis(new List<IExchange>() { vaultOfSatoshi, bter, coinEx, cryptsy, vircurex }); } } } } } } catch (ExchangeConfigurationException e) { Console.WriteLine(e.Message); Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public void TestParseVircurexBuildToken() { DateTime time = new DateTime(2014, 1, 20, 12, 13, 14); using (VircurexExchange exchange = new VircurexExchange()) { VircurexExchange.Method method = VircurexExchange.Method.create_order; string timestamp = exchange.FormatDateTime(time); string id = timestamp + "-" + 3; string username = "******"; string secret = "123456789"; exchange.PublicKey = username; exchange.PrivateKeys[method] = secret; string expected = "8e00a25d5cd41db0d481873376473ec7deded6008020c15755f46b103528a282"; string actual = exchange.BuildToken(method, new List <KeyValuePair <string, string> >(), timestamp, id); Assert.AreEqual(expected, actual); } }
private static void TestVircurex() { using (VircurexExchange vircurex = new VircurexExchange()) { Wallet btcWallet = null; vircurex.PublicKey = "rnicoll"; vircurex.DefaultPrivateKey = "topsecret"; vircurex.GetMyActiveOrders(VircurexExchange.OrderReleased.Released).Wait(); // Try creating, releasing then deleting an order VircurexMarketId marketId = new VircurexMarketId("VTC", "BTC"); VircurexOrderId unreleasedOrderId = vircurex.CreateUnreleasedOrder(marketId, OrderType.Sell, 1m, 0.005m).Result; VircurexOrderId releasedOrderId = vircurex.ReleaseOrder(unreleasedOrderId).Result; vircurex.CancelOrder(releasedOrderId).Wait(); foreach (Wallet wallet in vircurex.GetAccountInfo().Result.Wallets) { if (wallet.CurrencyCode == "BTC") { btcWallet = wallet; } } if (null == btcWallet) { Console.WriteLine("BTC wallet not found."); } else { Console.WriteLine("BTC balance: " + btcWallet.Balance + "BTC"); } // vircurex.GetOrderExecutions(new VircurexOrderId(5)).Wait(); } }
public void TestParseVircurexBuildTokenMessage() { DateTime time = new DateTime(2014, 1, 20, 12, 13, 14); using (VircurexExchange exchange = new VircurexExchange()) { VircurexExchange.Method method = VircurexExchange.Method.create_order; string timestamp = exchange.FormatDateTime(time); string id = timestamp + "-" + 3; string username = "******"; string secret = "123456789"; exchange.PublicKey = username; exchange.PrivateKeys[method] = secret; string expected = "123456789;MY_USER_NAME;" + timestamp + ";" + id + ";create_order"; string actual = exchange.BuildTokenMessage(method, new List <KeyValuePair <string, string> >(), timestamp, id); Assert.AreEqual(expected, actual); } }
public static void Main(string[] argv) { ApiKeySection configSection = GetRoamingConfiguration(); using (VoSExchange vaultOfSatoshi = new VoSExchange() { PublicKey = configSection.VaultOfSatoshi.PublicKey, PrivateKey = configSection.VaultOfSatoshi.PrivateKey }) { using (VircurexExchange vircurex = new VircurexExchange() { PublicKey = configSection.Vircurex.PublicKey, DefaultPrivateKey = configSection.VaultOfSatoshi.PrivateKey }) { while (true) { MarketDepth bestDogeBtcAsk = GetBestAsk(vircurex, new VircurexMarketId("DOGE", "BTC")).Result; if (bestDogeBtcAsk == null || bestDogeBtcAsk.Price == 0.0m) { Console.WriteLine("No valid DOGE/BTC price available."); Console.ReadKey(); return; } CalculateArbitrageResult(vaultOfSatoshi, bestDogeBtcAsk, "USD"); CalculateArbitrageResult(vaultOfSatoshi, bestDogeBtcAsk, "CAD"); Thread.Sleep(60000); } } } }
public void UpdateAllPrices() { if (prices.Length == 0) { return; } List <Task> tasks = new List <Task>(); int currencyCount = prices.GetLength(0); Dictionary <MarketId, ExchangePrice> vircurexPrices = new Dictionary <MarketId, ExchangePrice>(); HashSet <string> vircurexQuoteCurrencyCodes = new HashSet <string>(); VircurexExchange vircurex = null; // Start the data fetch running in parallel; non-Vircurex first for (int baseCurrencyIdx = 0; baseCurrencyIdx < currencyCount; baseCurrencyIdx++) { for (int quoteCurrencyIdx = 0; quoteCurrencyIdx < currencyCount; quoteCurrencyIdx++) { if (baseCurrencyIdx == quoteCurrencyIdx) { continue; } foreach (MarketPrice marketPrice in this.prices[baseCurrencyIdx, quoteCurrencyIdx]) { // Can only update prices on markets which are directly tradable; other markets // infer their prices from the underlying exchange prices. // As such, ignore any non-exchange-price types. ExchangePrice exchangePrice = marketPrice as ExchangePrice; if (null == exchangePrice) { continue; } if (exchangePrice.Exchange is VircurexExchange) { VircurexMarketId marketId = new VircurexMarketId(currencyCodes[baseCurrencyIdx], currencyCodes[quoteCurrencyIdx]); vircurexQuoteCurrencyCodes.Add(marketId.QuoteCurrencyCode); vircurexPrices[marketId] = exchangePrice; vircurex = (VircurexExchange)marketPrice.Exchange; } else { tasks.Add(exchangePrice.UpdatePriceAsync()); } } } } // Perform data fetch for Vircurex currencies; these can be // done in a batch, so we do them once the rest of the data // requests are running foreach (string quoteCurrencyCode in vircurexQuoteCurrencyCodes) { Dictionary <MarketId, Book> books = vircurex.GetMarketOrdersAlt(quoteCurrencyCode).Result; foreach (MarketId marketId in books.Keys) { ExchangePrice exchangePrice; if (vircurexPrices.TryGetValue(marketId, out exchangePrice)) { exchangePrice.MarketDepth = books[marketId]; } } } // Wait for all tasks to finish before we exit foreach (Task task in tasks) { task.Wait(); } }