Ejemplo n.º 1
0
        private static TSList <TradeData> DeserializeTrades(string[] lines)
        {
            if (lines == null)
            {
                return(null);
            }

            TSList <TradeData> tempTrades = new TSList <TradeData>();

            int cnt = int.Parse(lines[0]);

            for (int i = 0; i < cnt; i++)
            {
                string[] vars = new string[7];

                for (int j = 0; j < 7; j++)
                {
                    vars[j] = lines[i * 7 + 1 + j];
                }

                TradeData td = TradeData.Parse(vars);
                tempTrades.Add(td);
            }

            return(tempTrades);
        }
Ejemplo n.º 2
0
        public static void LoadData()
        {
            // if (PoloniexBot.ClientManager.Simulate) return;

            string[] lines;

            lines = FileManager.ReadFile(DirectoryName + "/" + OpenPositionsFilename);
            if (lines != null)
            {
                Trades = DeserializeTrades(lines);
            }

            lines = FileManager.ReadFile(DirectoryName + "/" + ClosedPositionsFilename);
            if (lines != null)
            {
                TSList <TradeData> tempClosedTrades = DeserializeTrades(lines);

                for (int i = 0; i < tempClosedTrades.Count; i++)
                {
                    tempClosedTrades[i] = new TradeData(
                        tempClosedTrades[i],
                        tempClosedTrades[i].sellAmountQuote,
                        tempClosedTrades[i].sellPrice,
                        tempClosedTrades[i].sellTimestamp);
                }

                DoneTrades = tempClosedTrades;
            }

            UpdateTradesGUI();
        }
Ejemplo n.º 3
0
        public static void ReportBuy(CurrencyPair pair, double amountQuote, double price, long timestamp)
        {
            if (Trades == null)
            {
                Trades = new TSList <TradeData>();
            }

            TradeData tempData = new TradeData(pair, amountQuote, price, timestamp);

            Trades.Add(tempData);

            UpdateTradesGUI();

            SaveData();
        }
Ejemplo n.º 4
0
        public static void ReportSell(CurrencyPair pair, double amountQuote, double price, long timestamp)
        {
            if (Trades == null)
            {
                return;
            }
            if (DoneTrades == null)
            {
                DoneTrades = new TSList <TradeData>();
            }

            for (int i = 0; i < Trades.Count; i++)
            {
                if (Trades[i].pair == pair)
                {
                    DoneTrades.Add(new TradeData(Trades[i], amountQuote, price, timestamp));
                    Trades.RemoveAt(i);
                    UpdateTradesGUI();
                    SaveData();
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        private static List <string> SerializeTrades(TSList <TradeData> trades)
        {
            if (trades == null)
            {
                return(new List <string>());
            }

            List <string> lines = new List <string>();

            List <TradeData> filteredTrades = new List <TradeData>(trades.ToArray());

            while (filteredTrades.Count > 12)
            {
                filteredTrades.RemoveAt(0);
            }

            lines.Add(filteredTrades.Count.ToString());
            for (int i = 0; i < filteredTrades.Count; i++)
            {
                lines.AddRange(filteredTrades[i].Serialize());
            }

            return(lines);
        }
Ejemplo n.º 6
0
 public static void Start()
 {
     calls  = new TSList <float>();
     thread = ThreadManager.Register(Run, "API Call Tracker", false);
 }
Ejemplo n.º 7
0
 static TradeTracker()
 {
     Trades     = new TSList <TradeData>();
     DoneTrades = new TSList <TradeData>();
 }