示例#1
0
        public FillResponse GetFillsByOrderIdSync(String id)
        {
            FillResponse res = null;

            try
            {
                var tmp   = Task.Run(async() => { return(await this.FillsService.GetFillsByOrderIdAsync(id)); }).Result;
                int count = 0;
                foreach (var item in tmp)
                {
                    foreach (var order in item)
                    {
                        count++;
                        res = order;
                    }
                }
                if (count != 1)
                {
                    //throw new Exception("Count 'FillResponse' is not correct");
                }
            }
            catch (Exception ex)
            {
                ex = null;
            }
            return(res);
        }
示例#2
0
        public void AddBuy(String sellId, FillResponse buyOrder)
        {
            var tmp = new TradeData();

            tmp.BuyId    = buyOrder.Order_id.ToString();
            tmp.BuyTime  = buyOrder.Created_at;
            tmp.BuyPrice = buyOrder.Price;
            tmp.buyFee   = buyOrder.Fee;

            tmp.SellId = sellId;
            dic.Add(sellId, tmp);
        }
示例#3
0
        private void Sell(String id)
        {
            decimal       price         = this.trade.TradeStatus.Price;
            FillResponse  fillOrder     = client.GetFillsByOrderIdSync(id);
            SellCoinOrder sellOrder     = PrepareSellOrder(fillOrder, price);
            OrderResponse orderResponse = MakeOrder(sellOrder);

            if (orderResponse != null)
            {
                actualListBuyOrder.Remove(id);
                String sellId = orderResponse.Id.ToString();
                actualListSellOrder.Add(sellId);
                history.AddBuy(sellId, fillOrder);
            }
        }
示例#4
0
        public void AddSell(FillResponse sellOrder)
        {
            try
            {
                TradeData tmp;
                if (dic.TryGetValue(sellOrder.Order_id.ToString(), out tmp) == true)
                {
                    tmp.SellTime  = DateTime.Now;
                    tmp.SellPrice = sellOrder.Price;

                    tmp.Profit    = tmp.SellPrice - tmp.BuyPrice - tmp.buyFee;
                    tmp.TradeTime = tmp.BuyTime - tmp.SellTime;
                }
            }
            catch (Exception ex)
            {
                ex = null;
            }
        }
示例#5
0
        private SellCoinOrder PrepareSellOrder(FillResponse buyOrder, decimal tradePrice)
        {
            decimal add       = ImportantValues.sellProfitPercentageFromBuyPrice / (decimal)100;
            decimal calcPrice = buyOrder.Price + (add * buyOrder.Price);

            //TODO: this line is possible to use only in case that we want get EURO
            #region rounding up on 2 digits
            decimal tmp = calcPrice * 100;
            tmp = Math.Floor(tmp);
            if (tmp % 10 != 0)
            {
                tmp += 1;
            }
            calcPrice = tmp / 100;
            #endregion

            decimal price = (calcPrice > tradePrice) ? calcPrice : tradePrice + ImportantValues.minPriceInEur;

            SellCoinOrder order = new SellCoinOrder();
            order.BuyPrice = price;
            order.Price    = price;
            order.Size     = buyOrder.Size;
            return(order);
        }
 protected void SetResponseIntent(FillResponse fillResponse)
 {
     ReplyIntent.PutExtra(AutofillManager.ExtraAuthenticationResult, fillResponse);
 }