示例#1
0
        public override string DoOrder(CUtility.OrderType type, decimal?cost, decimal amount, ref string orderId, bool marketOrder)
        {
            //throw new NotImplementedException();

            return("");

            /*
             * potremmo evitare di fare ordini se non vengono smazzati gli eventuali precedenti
             */

            IMtGoxExchange mtGoxExchange = new MtGoxExchange();

            mtGoxExchange.APIKey    = Api;
            mtGoxExchange.APISecret = Secret;
            OrderType           ordertype = type == CUtility.OrderType.Buy ? OrderType.Bid : OrderType.Ask;
            OrderCreateResponse response  = mtGoxExchange.CreateOrder(currency, ordertype, (double)amount, null);

            if (response.Result == ResponseResult.Success)
            {
                orderId = response.OID.ToString();
                System.Console.WriteLine("Order success");
                return(response.OID.ToString());
            }
            else
            {
                orderId = "";
                System.Console.WriteLine("Order failed");
                return("");
            }
        }
示例#2
0
        public override void GetWallet()
        {
            //throw new NotImplementedException();

            try
            {
                IMtGoxExchange mtGoxExchange = new MtGoxExchange();
                mtGoxExchange.APIKey    = Api;
                mtGoxExchange.APISecret = Secret;
                var info = mtGoxExchange.GetAccountInfo();
                this.Fee = (decimal)info.TradeFee;
                var wallets = info.Wallets;
                this.TotCoins = (decimal)wallets.BTC.Balance.Value;
                this.TotMoney = (decimal)wallets.USD.Balance.Value;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        public override bool GetTicker()
        {
            try
            {
                IMtGoxExchange mtGoxExchange = new MtGoxExchange();
                mtGoxExchange.APIKey    = Api;
                mtGoxExchange.APISecret = Secret;

                var ticker = mtGoxExchange.GetTicker(currency);
                this.Buy    = (decimal)ticker.AskValue;    // sell 292 (i valori sono invertiti perchè gli ordini hanno buy > sell)
                this.Sell   = (decimal)ticker.BidValue;    // buy 291
                this.Date   = ticker.TimeStamp;
                this.Volume = (decimal)ticker.VolumeValue; //decimal.Parse(ticker.Volume);

                OnTicker();

                return(true);
            }
            catch (Exception)
            {
                throw;
                return(true);
            }
        }