public void CaVirtexBTC_CoinbaseBTC() { //buy CaVirtex BTC -> Sell Coinbase BTC -> Loop money back to CaVirtex //market_keys 1 -> 10 -> 55 -> 56 List <int> path = new List <int>(); path.Add(1); path.Add(10); path.Add(55); path.Add(56); MarketDifference therate = GetArbitrageRate(path); //update firebase /*Hashtable hstemp = new Hashtable(); * hstemp.Add("buying", buying); * hstemp.Add("selling", selling); * hstemp.Add("lasttrade", lasttrade); * hstemp.Add("updated", DateTime.UtcNow.ToString("hh:mm:ss")); * hstemp.Add("theindex", 0); * * Hashtable hstemp2 = new Hashtable(); * hstemp2.Add("coinbase", hstemp); * * fb.UpdateMarket(hstemp2);*/ //buy Coinbase BTC -> Sell CaVirtex BTC -> Loop money back to CaVirtex }
public void CaVirtexBTC_KrakenBTC_KrakenLTC_CaVirtexBTC() { //buy CaVirtex BTC -> Sell Coinbase BTC -> Loop money back to CaVirtex //market_keys 7 -> 16 -> 24 -> 6 List <int> path = new List <int>(); path.Add(7); path.Add(16); path.Add(24); path.Add(6); MarketDifference therate = GetArbitrageRate(path); }
private MarketDifference GetArbitrageRate(List <int> path) { MarketDifference arbitragerate = new MarketDifference(); arbitragerate.isvoid = false; DataTable dtmarketdata = Bitcoin_Notify_DB.SPs.ViewMarketDataAll().GetDataSet().Tables[0]; DataColumn[] keyColumns1 = new DataColumn[1]; keyColumns1[0] = dtmarketdata.Columns["market_key"]; dtmarketdata.PrimaryKey = keyColumns1; DataTable dtmarkets = Bitcoin_Notify_DB.SPs.ViewMarketsAll().GetDataSet().Tables[0]; DataColumn[] keyColumns2 = new DataColumn[1]; keyColumns2[0] = dtmarkets.Columns["market_key"]; dtmarkets.PrimaryKey = keyColumns2; DataTable dtnodes = Bitcoin_Notify_DB.SPs.ViewExchangeCurrenciesAll().GetDataSet().Tables[0]; DataColumn[] keyColumns3 = new DataColumn[1]; keyColumns3[0] = dtnodes.Columns["exchange_currency_key"]; dtnodes.PrimaryKey = keyColumns3; //set first buy data int startingmarket = path[0]; int startingnode = Convert.ToInt32(dtmarkets.Rows.Find(startingmarket)["source"]); Value startingamount = new Value(); startingamount.amount = 1; startingamount.currency = Convert.ToInt32(dtnodes.Rows.Find(startingnode)["currency"]); Value currentamount = new Value(); currentamount = startingamount; currentamount.isvoid = false; //calculate percentage rate foreach (int marketkey in path) { Market currentmarket = GetMarketInfo(dtmarkets, dtnodes, dtmarketdata, marketkey); currentamount = CalculateTransaction(currentamount, currentmarket, false); //calculate static fees if (currentmarket.fee_static > 0) { switch (currentmarket.source.currency) { case 1: arbitragerate.staticfeeUSD += currentmarket.fee_static; break; case 2: arbitragerate.staticfeeBTC += currentmarket.fee_static; break; case 3: arbitragerate.staticfeeLTC += currentmarket.fee_static; break; } } //calculate time arbitragerate.time += currentmarket.exchangetime; } arbitragerate.percentage = (currentamount.amount - 1) * 100; arbitragerate.isvoid = currentamount.isvoid; return(arbitragerate); }