コード例 #1
0
ファイル: BtceWrapper.cs プロジェクト: BradleyDHobbs/CoinTNet
 /// <summary>
 /// Places a sell order
 /// </summary>
 /// <param name="amount">The amount of units to buy</param>
 /// <param name="price">The price per unit</param>
 /// <param name="pair">The currency pair</param>
 /// <returns>Detaisl about the new order</returns>
 public CallResult <OrderDetails> PlaceSellOrder(decimal amount, decimal price, CurrencyPair pair)
 {
     return(CallProxy(() => _proxy.Trade(pair.ToBtcePair(), TradeType.Sell, price, amount),
                      o => new OrderDetails
     {
         Amount = amount,
         Price = price,
         Id = o.OrderId,
         Type = OrderType.Sell
     }));
 }
        public override string DoOrder(CUtility.OrderType type, decimal?cost, decimal amount, ref string orderId, bool marketOrder)
        {
            //throw new NotImplementedException();

            /*
             * potremmo evitare di fare ordini se non vengono smazzati gli eventuali precedenti
             */
            return("");

            try
            {
                if (cost.HasValue)
                {
                    TradeType trade  = type == CUtility.OrderType.Buy ? TradeType.Buy : TradeType.Sell;
                    var       result = _btceApi.Trade(currentPair, trade, cost.Value, amount);
                    orderId          = result.OrderId.ToString(CultureInfo.InvariantCulture);
                    this.LastorderId = orderId;
                    System.Console.WriteLine("Order success");
                    return(orderId);
                }
                else
                {
                    System.Console.WriteLine("Order failed");
                    return("");
                }
            }
            catch (Exception)
            {
                System.Console.WriteLine("Order error");
                return("");

                throw;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: wishhhmaster/CoinTNet
        static void Main(string[] args)
        {
            var ticker      = BtceApi.GetTicker(BtcePair.btc_usd);
            var trades      = BtceApi.GetTrades(BtcePair.btc_usd);
            var btcusdDepth = BtceApi.GetDepth(BtcePair.usd_rur);
            var fee         = BtceApi.GetFee(BtcePair.usd_rur);

            var btceApi      = new BtceApi("API_KEY", "API_SECRET");
            var info         = btceApi.GetInfo();
            var transHistory = btceApi.GetTransHistory();
            var tradeHistory = btceApi.GetTradeHistory(count: 20);
            var orderList    = btceApi.GetOrderList();
            var tradeAnswer  = btceApi.Trade(BtcePair.btc_usd, TradeType.Sell, 20, 0.1m);
            var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            var ticker      = BtceApi.GetTicker(BtcePair.BtcUsd);
            var trades      = BtceApi.GetTrades(BtcePair.BtcUsd);
            var btcusdDepth = BtceApi.GetDepth(BtcePair.UsdRur);
            var fee         = BtceApi.GetFee(BtcePair.UsdRur);

            var btceApi      = new BtceApi("YOUR-API-KEY", "your_secret_key");
            var info         = btceApi.GetInfo();
            var transHistory = btceApi.GetTransHistory();
            var tradeHistory = btceApi.GetTradeHistory(count: 20);
            var orderList    = btceApi.GetOrderList();
            var tradeAnswer  = btceApi.Trade(BtcePair.BtcUsd, TradeType.Sell, 20, 0.1m);
            var cancelAnswer = btceApi.CancelOrder(tradeAnswer.OrderId);
        }
コード例 #5
0
        /// <summary>
        /// Places orders to follow the conversions
        /// </summary>
        /// <param name="chain"></param>
        /// <param name="realTrading">Whether to place the orders for real or not</param>
        private void FollowChain(List <ArbitrageAction> chain, bool realTrading)
        {
            OnReportProgress("==============================");
            OnReportProgress(DateTime.Now.ToString("HH:mm:ss"));
            for (int i = 1; i < chain.Count; i++)
            {
                if (_mustStop)
                {
                    return;
                }
                var ac      = chain[i].Data;
                var stepMsg = string.Format("Step {1}/{2}  - {0}",
                                            ac.Description, i, chain.Count - 1);
                OnReportProgress(stepMsg);

                int orderId = 0;
                if (realTrading)
                {
                    var orderRes = ac.IsBuyOrder ? _proxy.Trade(ac.Pair, TradeType.Buy, ac.Rate, ac.UnitsCurrency2) : _proxy.Trade(ac.Pair, TradeType.Sell, ac.Rate, ac.UnitsCurrency1);
                    orderId = orderRes.OrderId;
                }
                else
                {
                    orderId = new Random().Next(300);
                }


                OnReportProgress(string.Format("Order #{0} placed. Waiting for its execution", orderId));

                while (!_mustStop)
                {
                    System.Threading.Thread.Sleep(500);
                    var openOrders = _proxy.GetOpenOrders(ac.Pair);
                    if (!openOrders.List.Any(o => o.Key == orderId))
                    {
                        OnReportProgress(string.Format("Order #{0} executed", orderId));
                        break;
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("Waiting for order #{0} to be executed", orderId));
                    }
                }
            }

            OnReportProgress(string.Format("Finished"));
        }