Exemple #1
0
        public double getPairVolume(Globals.Coin coinFrom, Globals.Coin coinTo)
        {
            string pair = reformCoinPair(coinFrom.marketSymbol, coinTo.marketSymbol);
            string resp = ExchangeAuxilaries.SendWebRequest(
                apiUrl + "/api/v1/ticker/24hr",
                apiSecret,
                "GET",
                new CustomDict <string, string>
            {
                { "X-MBX-APIKEY", apiKey }
            },
                new CustomDict <string, string>
            {
                { "symbol", pair.ToUpper() }
            }, null
                );

            if (resp == null)
            {
                throw new Exception("null response for getPairVolume");
            }
            JObject assets = JObject.Parse(resp);

            return(double.Parse(assets["quoteVolume"].ToString()));
        }
Exemple #2
0
        public Globals.Balance GetBalance(Globals.Coin coin)
        {
            bool contains = false;

            foreach (Globals.Coin c in markets) /*Logger.debugMsg(string.Format("comparing {0} {1}", c.ToString(), coin.ToString()));*/ if {
                (c == coin) { contains = true; break; }
            }
Exemple #3
0
 public Transaction(UInt32 id, DateTime time, Globals.Coin coinSold, double amountSold, Globals.Coin coinBought, double amountBought)
 {
     this.id           = id;
     this.time         = time;
     this.coinSold     = coinSold;
     this.coinBought   = coinBought;
     this.amountSold   = amountSold;
     this.amountBought = amountBought;
 }
        public static string pricesToString(CustomDict <string, double> prices, Globals.Coin displayPricesIn)
        {
            string result = string.Empty;

            foreach (KeyValuePair <string, double> pair in prices)
            {
                result += pair.Key + "=" + pair.Value + " " + displayPricesIn.marketSymbol + "\n";
            }
            return(result);
        }
Exemple #5
0
 public double GetMinTradeAmount(Globals.Coin from, Globals.Coin to)
 {
     if (from == ProfitRealizationCoin)
     {
         return(minPRCtradeAmount);
     }
     else
     {
         return(minPRCtradeAmount / GetRatio(from.marketSymbol, to.marketSymbol));
     }
 }
Exemple #6
0
        public static void Main()
        {
            Globals.Coin btc  = new Globals.Coin("Bitcoin", "btc");
            Globals.Coin ltc  = new Globals.Coin("Litecoin", "ltc");
            Globals.Coin usdt = new Globals.Coin("USDT", "usdt");

            BinanceAPIClient binanceAPI = new BinanceAPIClient
            {
                FiatCoin = usdt,
                ProfitRealizationCoin = btc,
                markets =
                {
                    new Globals.Coin(Globals.COIN_SYMBOL_TO_NAME[Globals.ltc],  Globals.ltc),
                    new Globals.Coin(Globals.COIN_SYMBOL_TO_NAME[Globals.usdt], Globals.usdt),
                    new Globals.Coin(Globals.COIN_SYMBOL_TO_NAME[Globals.btc],  Globals.btc),
                },

                minPRCtradeAmount = 0.002,
                pricePrecision    = new CustomDict <string, int> {
                    { string.Format("{0}{1}", Globals.ltc, Globals.btc), 6 },
                    { string.Format("{0}{1}", Globals.btc, Globals.usdt), 2 },
                },
                amountPrecision = new CustomDict <string, int> {
                    { string.Format("{0}{1}", Globals.ltc, Globals.btc), 2 },
                    { string.Format("{0}{1}", Globals.btc, Globals.usdt), 6 },
                },
                minIncreaseForBuying = new CustomDict <string, double> {
                    { string.Format("{0}{1}", Globals.ltc, Globals.btc), 0.003 },
                    { string.Format("{0}{1}", Globals.btc, Globals.usdt), 0.003 },
                },
            };

            double ltcToSell = 3.5;
            double ltcToBtc;

            Globals.consoleMsg("<type>i</type>curr. free balance of btc=<type>d</type>" + binanceAPI.GetBalance(btc).free + "\n");
            Globals.consoleMsg("<type>i</type>curr. in-trade balance of btc=<type>d</type>" + binanceAPI.GetBalance(btc).inTrade + "\n");
            Globals.consoleMsg("<type>i</type>curr. trade price of ltc in btc=<type>d</type>" + (ltcToBtc = binanceAPI.GetRatio(ltc.marketSymbol, btc.marketSymbol)) + "\n");
            Globals.consoleMsg(string.Format("<type>i</type>selling {0} ltc for {1} btc", ltcToSell, ltcToBtc));
            Transaction t = binanceAPI.PerformTrade(ltc, btc, ltcToSell, ltcToSell * ltcToBtc, 1 / (Math.Pow(10, binanceAPI.amountPrecision[binanceAPI.reformCoinPairLower(ltc.marketSymbol, btc.marketSymbol)] - 1)));

            Globals.consoleMsg("<type>i</type>resulting transaction: <type>d</type>" + t.ToString() + "\n");
        }