public OrderModel PostBestSellOrderFictive(CurrencyPair currencyPair, double USDT = 0) { OrderModel order = new OrderModel(); double bestPricePerCoin = 0; double amountQuote = 0; bestPricePerCoin = FindBestPrice(currencyPair, OrderType.Sell); amountQuote = USDT; //PushMessage("SOLD!", // $"Currency: {currencyPair}\\n" + // $"USDT: {string.Format("{0:0.00}$", USDT)}\\n" + // $"At: {bestPricePerCoin}\\n" + // $"Profit: {string.Format("{0:0.00}%", 0 * 100)}"); order.CurrencyPair = currencyPair; order.OrderType = OrderType.Buy; order.AmountBase = 0; order.AmountQuote = amountQuote; order.PricePerCoin = bestPricePerCoin; order.IdOrder = 0; return(order); }
/// <summary> /// Gets a data summary of a specific market. /// </summary> /// <param name="markets"></param> /// <param name="currencyPair"></param> /// <returns></returns> public IMarketData GetMarket(IDictionary <CurrencyPair, IMarketData> markets, CurrencyPair currencyPair) { IMarketData market = (from m in markets where m.Key.BaseCurrency == currencyPair.BaseCurrency && m.Key.QuoteCurrency == currencyPair.QuoteCurrency select m.Value).Single(); return(market); }
public IList <ITrade> MCGetTrades(CurrencyPair currencyPair, DateTime startTime, DateTime endTime) { return(PoloniexClient.Markets.GetTrades(currencyPair, startTime, endTime)); }
/// <summary> /// /// </summary> /// <param name="currencyPair"></param> /// <param name="depth"></param> /// <returns></returns> public IOrderBook GetOpenOrders(CurrencyPair currencyPair, uint depth) { return(PoloniexClient.Markets.GetOpenOrdersSync(currencyPair, depth)); }
public IList <ITrade> GetTrades(CurrencyPair currencyPair) { return(client.Trading.GetTrades(currencyPair)); }
public IList <ITrade> GetTrades(CurrencyPair currencyPair, DateTime startTime, DateTime endTime) { return(client.Trading.GetTrades(currencyPair, startTime, endTime)); }
public ulong PostOrder(CurrencyPair currencyPair, OrderType type, double pricePerCoin, double amountQuote) { return(client.Trading.PostOrder(currencyPair, type, pricePerCoin, amountQuote)); }
public OrderModel PostBestSellOrder(CurrencyPair currencyPair, bool realTrade, double USDT = 0, ulong previousIdOrder = 0) { if (!realTrade) { return(PostBestSellOrderFictive(currencyPair, USDT)); } var tradeId = new ulong(); OrderModel order = new OrderModel(); double bestPricePerCoin = 0; double bestPricePerCoinTemp = 0; double amountQuote = 0; // Quantité de la monnaie que je possède double profitMade = 0; IList <TradingTools.ITrade> trades = null; // Procéder à la vente do { try { bestPricePerCoin = FindBestPrice(currencyPair, OrderType.Sell); amountQuote = InitPost(currencyPair, bestPricePerCoin, OrderType.Sell, USDT); if (amountQuote == 0) { Debug.WriteLine(string.Format("\nY'A RIEN À VENDRE !!!")); return(null); } // ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### // ###################################################################################################### tradeId = PostOrder(currencyPair, bestPricePerCoin, amountQuote, OrderType.Sell); } catch (Exception ex) { Debug.WriteLine(ex); } }while (tradeId == 0); // Tant que tout n'est pas vendu while ((from x in GetBalances() where x.Type == currencyPair.QuoteCurrency select x.QuoteOnOrders).SingleOrDefault() > 0) { try { bestPricePerCoinTemp = FindBestPrice(currencyPair, OrderType.Sell, amountQuote); if (bestPricePerCoin != bestPricePerCoinTemp) // empêche de me détrôner moi-même { bestPricePerCoin = bestPricePerCoinTemp; Debug.WriteLine($"\nnew bestPrice: {bestPricePerCoin}"); amountQuote = (from x in GetBalances() where x.Type == currencyPair.QuoteCurrency select x.QuoteOnOrders).SingleOrDefault(); if (amountQuote > 0) { // Si erreur retournée = "Total must be at least 1", le move se fait pas et ça loop...... tradeId = MoveOrder(currencyPair, tradeId, bestPricePerCoin, amountQuote); } Debug.WriteLine(string.Format("MoveOrder: amountQuote = {0}", amountQuote)); } Thread.Sleep(SLEEP_BETWEEN_MOVEORDER); } catch (Exception ex) { Debug.WriteLine(ex); } } System.Media.SystemSounds.Exclamation.Play(); Debug.WriteLine("SELL COMPLETED!\n"); //if (previousIdOrder != 0) //{ // trades = GetTrades(currencyPair); // profitMade = (trades.Where(x => x.IdOrder == tradeId).FirstOrDefault().PricePerCoin - // trades.Where(x => x.IdOrder == previousIdOrder).FirstOrDefault().PricePerCoin) / // trades.Where(x => x.IdOrder == previousIdOrder).FirstOrDefault().PricePerCoin; //} trades = GetTrades(currencyPair); profitMade = (GetLastTrade(trades, OrderType.Sell) - GetLastTrade(trades, OrderType.Buy)) / GetLastTrade(trades, OrderType.Buy); PushMessage("SOLD!", $"Currency: {currencyPair}\\n" + $"USDT: {string.Format("{0:0.00}$", (from x in GetBalances() where x.Type == currencyPair.BaseCurrency select x.QuoteAvailable).SingleOrDefault())}\\n" + $"At: {bestPricePerCoin}\\n" + $"Profit: {string.Format("{0:0.00}%", profitMade * 100)}"); order.CurrencyPair = currencyPair; order.OrderType = OrderType.Buy; order.AmountBase = 0; order.AmountQuote = amountQuote; order.PricePerCoin = bestPricePerCoin; order.IdOrder = ulong.Parse(tradeId.ToString()); return(order); }
public IList <MarketTools.ITrade> MCGetTrades(CurrencyPair currencyPair, DateTime startTime, DateTime endTime) { return(MC.MCGetTrades(currencyPair, startTime, endTime)); }
public IList <TradingTools.ITrade> GetTrades(CurrencyPair currencyPair, DateTime startTime, DateTime endTime) { return(TC.GetTrades(currencyPair, startTime, endTime)); }
public IList <TradingTools.ITrade> GetTrades(CurrencyPair currencyPair) { return(TC.GetTrades(currencyPair)); }
public IMarketData GetCurrency(IDictionary <CurrencyPair, IMarketData> markets, CurrencyPair currencyPair) { return(MC.GetMarket(markets, currencyPair)); }
public IMarketData GetCurrency(CurrencyPair currencyPair) { return(MC.GetMarket(currencyPair)); }
public bool Equals(CurrencyPair b) { return(b.BaseCurrency == BaseCurrency && b.QuoteCurrency == QuoteCurrency); }
public IOrderBook GetOpenOrders(CurrencyPair currencyPair, uint depth) { return(MC.GetOpenOrders(currencyPair, depth)); }
public TickerChangedEventArgs(CurrencyPair currencyPair, MarketData marketData) { CurrencyPair = currencyPair; MarketData = marketData; }
public OrderModel PostBestBuyOrder(CurrencyPair currencyPair, bool realTrade, double USDT = 0) { if (!realTrade) { return(PostBestBuyOrderFictive(currencyPair, USDT)); } var tradeId = new ulong(); OrderModel order = new OrderModel(); double bestPricePerCoin = 0; double bestPricePerCoinTemp = 0; double amountQuote = 0; // Quantité de la monnaie à acheter // Procéder à l'achat do { try { bestPricePerCoin = FindBestPrice(currencyPair, OrderType.Buy); amountQuote = InitPost(currencyPair, bestPricePerCoin, OrderType.Buy, USDT); if (amountQuote == 0) { Debug.WriteLine(string.Format("\nY'A RIEN À ACHETER !!!")); return(null); } // ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### DANGER ### // ###################################################################################################### tradeId = PostOrder(currencyPair, bestPricePerCoin, amountQuote, OrderType.Buy); } catch (Exception ex) { Debug.WriteLine(ex); } }while (tradeId == 0); // Tant que tout n'est pas acheté while ((from x in GetBalances() where x.Type == currencyPair.BaseCurrency select x.QuoteOnOrders).SingleOrDefault() > 0) { try { bestPricePerCoinTemp = FindBestPrice(currencyPair, OrderType.Buy, amountQuote); if (bestPricePerCoin != bestPricePerCoinTemp) // empêche de me détrôner moi-même { bestPricePerCoin = bestPricePerCoinTemp; Debug.WriteLine($"\nnew bestPrice {bestPricePerCoin}"); amountQuote = Utilities.TruncateDouble((from x in GetBalances() where x.Type == currencyPair.BaseCurrency select x.QuoteOnOrders).SingleOrDefault() / bestPricePerCoin); if (amountQuote > 0) { tradeId = MoveOrder(currencyPair, tradeId, bestPricePerCoin, amountQuote); } Debug.WriteLine(string.Format("MoveOrder: amountQuote = {0}", amountQuote)); } Thread.Sleep(SLEEP_BETWEEN_MOVEORDER); } catch (Exception ex) { Debug.WriteLine(ex); } } System.Media.SystemSounds.Exclamation.Play(); Debug.WriteLine("BUY COMPLETED!\n"); PushMessage("BOUGHT!", $"Currency: {currencyPair}\\n" + $"USDT: {string.Format("{0:0.00}$", (from x in GetBalances() where x.Type == currencyPair.QuoteCurrency select x.USDT_Value).SingleOrDefault())}\\n" + $"At: {bestPricePerCoin}"); order.CurrencyPair = currencyPair; order.OrderType = OrderType.Buy; order.AmountBase = 0; order.AmountQuote = amountQuote; order.PricePerCoin = bestPricePerCoin; order.IdOrder = ulong.Parse(tradeId.ToString()); return(order); }