Esempio n. 1
0
        public void UpdatePairData(PoloniexAPI.CurrencyPair pair, Dictionary <string, double> ruleVariables)
        {
            if (pairData == null)
            {
                pairData = new List <PairData>();
            }

            double[] vars = new double[PairData.varNames.Length];

            for (int i = 0; i < PairData.varNames.Length; i++)
            {
                double tempVar = 0;
                ruleVariables.TryGetValue(PairData.varNames[i], out tempVar);
                vars[i] = tempVar;
            }

            for (int i = 0; i < pairData.Count; i++)
            {
                if (pairData[i].quoteName == pair.QuoteCurrency)
                {
                    pairData[i] = new PairData(pair.QuoteCurrency, pair.BaseCurrency, vars);
                    return;
                }
            }
        }
Esempio n. 2
0
        public static List <PoloniexAPI.MarketTools.ITrade> GetTrades(PoloniexAPI.CurrencyPair pair, DateTime startTime, DateTime endTime)
        {
            int startTimeUNIX = (int)DateTimeHelper.DateTimeToUnixTimestamp(startTime);
            int endTimeUNIX   = (int)DateTimeHelper.DateTimeToUnixTimestamp(endTime);

            return(GetTrades(pair, startTimeUNIX, endTimeUNIX));
        }
Esempio n. 3
0
        public static List <PoloniexAPI.MarketTools.ITrade> GetTrades(PoloniexAPI.CurrencyPair pair, int startTime, int endTime)
        {
            startTime = (int)DateTimeHelper.GetServerTime(startTime);
            endTime   = (int)DateTimeHelper.GetServerTime(endTime);
            string response = QueryGet("https://poloniex.com/public?command=returnTradeHistory&currencyPair=" + pair + "&start=" + startTime + "&end=" + endTime);

            return(ParseTrades(response));
        }
Esempio n. 4
0
        public static void BlockPair(PoloniexAPI.CurrencyPair pair, bool state)
        {
            mainForm.strategyControl1.SetBlockedPairData(pair, state);
            mainForm.strategyControl1.Invalidate();

            PairSummariesManager.SetPairBlock(pair, state);
            UpdatePairSummaries();
        }
Esempio n. 5
0
 public void SetToNoData()
 {
     lock (this) {
         pair       = null;
         MarkedUser = false;
         priceData  = null;
     }
 }
Esempio n. 6
0
        public void AddPairData(PoloniexAPI.CurrencyPair pair)
        {
            if (pairData == null)
            {
                pairData = new List <PairData>();
            }

            pairData.Add(new PairData(pair.QuoteCurrency, pair.BaseCurrency));

            UpdateModulesScreen();
        }
Esempio n. 7
0
 public static bool UnmarkPairUser(PoloniexAPI.CurrencyPair pair)
 {
     if (PairSummariesManager.MarkPairSummary(pair, false))
     {
         UpdatePairSummaries();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 8
0
        public static void ForceBuy(string[] parameters)
        {
            if (parameters == null || parameters.Length != 2)
            {
                throw new Exception("Wrong Parameters");
            }

            PoloniexAPI.CurrencyPair pair = new PoloniexAPI.CurrencyPair("BTC", parameters[1].ToUpper());
            if (!Trading.Manager.ForceBuy(pair))
            {
                throw new Exception("Specified currency does not exist");
            }
        }
Esempio n. 9
0
        public void SetBlockedPairData(PoloniexAPI.CurrencyPair pair, bool state)
        {
            if (pairData == null)
            {
                pairData = new List <PairData>();
            }

            for (int i = 0; i < pairData.Count; i++)
            {
                if (pairData[i].quoteName == pair.QuoteCurrency)
                {
                    pairData[i].blocked = state;
                    return;
                }
            }
        }
Esempio n. 10
0
        // --------------------------

        public void UpdatePair(PoloniexAPI.CurrencyPair pair, PoloniexAPI.TickerChangedEventArgs[] tickers, bool marked)
        {
            if (pair == null)
            {
                return;
            }
            if (tickers == null || tickers.Length == 0)
            {
                return;
            }

            this.pair       = pair;
            this.MarkedUser = marked;

            lock (this) {
                List <PoloniexAPI.TickerChangedEventArgs> tempList = new List <PoloniexAPI.TickerChangedEventArgs>();
                long startTime = tickers.Last().Timestamp - (GraphTimeframe * 3600 + 900);
                long lastTime  = 0;

                bool doneSkip = false;

                for (int i = 0; i < tickers.Length; i++)
                {
                    if (!doneSkip && tickers[i].Timestamp < startTime)
                    {
                        continue;
                    }
                    doneSkip = true;

                    if (tickers[i].Timestamp - 60 < lastTime)
                    {
                        continue;
                    }

                    tempList.Add(tickers[i]);
                    lastTime = tickers[i].Timestamp;
                }

                priceData = tempList.ToArray();
            }

            this.lastPrice = tickers.Last().MarketData.PriceLast;
            this.change24  = tickers.Last().MarketData.PriceChangePercentage * 100;
            this.volume    = tickers.Last().MarketData.Volume24HourBase;
        }
Esempio n. 11
0
        public static IList <PoloniexAPI.MarketTools.IMarketChartData> GetChartData(
            PoloniexAPI.CurrencyPair currencyPair,
            PoloniexAPI.MarketTools.MarketPeriod period,
            DateTime startTime, DateTime endTime)
        {
            int startTimestamp = (int)Utility.DateTimeHelper.DateTimeToUnixTimestamp(startTime);
            int endTimestamp   = (int)Utility.DateTimeHelper.DateTimeToUnixTimestamp(endTime);

            startTimestamp = (int)Utility.DateTimeHelper.GetServerTime(startTimestamp);
            endTimestamp   = (int)Utility.DateTimeHelper.GetServerTime(endTimestamp);

            string response = QueryGet("https://poloniex.com/public?command=returnChartData&currencyPair=" + currencyPair +
                                       "&start=" + startTimestamp +
                                       "&end=" + endTimestamp +
                                       "&period=" + (int)period);

            return(ParseChartData(response));
        }
Esempio n. 12
0
        public static void UnmarkPair(string[] parameters)
        {
            if (parameters == null || parameters.Length != 2)
            {
                throw new Exception("Wrong Parameters");
            }

            Utility.ThreadManager.Register(() => {
                PoloniexAPI.CurrencyPair pair = new PoloniexAPI.CurrencyPair("BTC", parameters[1].ToUpper());
                if (GUI.GUIManager.UnmarkPairUser(pair))
                {
                    CLI.Manager.PrintNote("Removing " + pair.QuoteCurrency + " from display priority.");
                }
                else
                {
                    CLI.Manager.PrintError("Specified currency not found in tracked pairs!");
                }
            }, "Unmark Pair", false);
        }
Esempio n. 13
0
        public static void Resume(string[] parameters)
        {
            if (parameters == null || parameters.Length != 2)
            {
                throw new Exception("Wrong Parameters");
            }

            string param = parameters[1].Trim().ToLower();

            if (param == "all")
            {
                Trading.Manager.ResumeAll();
            }
            else
            {
                PoloniexAPI.CurrencyPair pair = new PoloniexAPI.CurrencyPair("BTC", parameters[1].Trim().ToUpper());
                Trading.Manager.ResumePair(pair);
            }
        }
Esempio n. 14
0
 public static void SetPairSummary(PoloniexAPI.CurrencyPair pair, PoloniexAPI.TickerChangedEventArgs[] tickers, double volume)
 {
     PairSummariesManager.SetPairSummary(pair, tickers, volume);
     UpdatePairSummaries();
 }
Esempio n. 15
0
        // --------------------

        public static List <PoloniexAPI.MarketTools.ITrade> GetTrades(PoloniexAPI.CurrencyPair pair)
        {
            string response = QueryGet("https://poloniex.com/public?command=returnTradeHistory&currencyPair=" + pair.ToString());

            return(ParseTrades(response));
        }
Esempio n. 16
0
 public static void RemovePairSummary(PoloniexAPI.CurrencyPair pair)
 {
     PairSummariesManager.RemovePairSummary(pair);
     UpdatePairSummaries();
 }
Esempio n. 17
0
 public static void UpdateStrategyScreenPair(PoloniexAPI.CurrencyPair pair, Dictionary <string, double> ruleVariables)
 {
     mainForm.strategyControl1.UpdatePairData(pair, ruleVariables);
     mainForm.strategyControl1.Invalidate();
 }
Esempio n. 18
0
        // --------------------------

        public static void AddStrategyScreenPair(PoloniexAPI.CurrencyPair pair)
        {
            mainForm.strategyControl1.AddPairData(pair);
            mainForm.strategyControl1.Invalidate();
        }