Example #1
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            HistoryBoundList cHistoryList = __cTradeService.Closes;

            int iIndex = comboMode.SelectedIndex;

            switch (iIndex)
            {
            case 0:
                cHistoryList.Filter(txtSymbol.Text, DateTime.MinValue, DateTime.MaxValue);
                break;

            case 1:
                DateTime cStart = DateTime.Today;
                DateTime cStop  = cStart.AddSeconds(86399);
                datePickerStart.Value = cStart;
                datePickerStop.Value  = cStart;
                cHistoryList.Filter(txtSymbol.Text, cStart, cStop);
                break;

            case 2:
                cHistoryList.Filter(txtSymbol.Text, datePickerStart.Value, datePickerStop.Value.AddSeconds(86399));
                break;
            }
        }
Example #2
0
        internal static void Save(TradeBoundList openTrades, HistoryBoundList history, string file)
        {
            int iIndex = file.LastIndexOf(".");

            if (iIndex > -1)
            {
                string sOpenFile  = file.Substring(0, iIndex) + "_open.csv";
                string sCloseFile = file.Substring(0, iIndex) + "_close.csv";

                File.WriteAllText(sOpenFile, ProcessOpenTrades(openTrades), Encoding.UTF8);
                File.WriteAllText(sCloseFile, ProcessHistorys(history), Encoding.UTF8);
            }
        }
Example #3
0
        private static string ProcessHistorys(HistoryBoundList trades)
        {
            StringBuilder cBuilder = new StringBuilder(1024 * 1024);

            cBuilder.Append("NO.").Append(',').Append("SymbolID").Append(',').Append("Category").Append(',').Append("Action").Append(',').Append("Volume").Append(',').Append("Price").Append(',').Append("Profit").Append(',').Append("Fee").Append(',').Append("Tax").Append(',').Append("Trading time").Append(',').AppendLine("Description");

            int iCount = trades.Count - 1;              //內建的歷史資料用來統計總和放在最後一筆

            for (int i = 0; i < iCount; i++)
            {
                _TradeInfo cTrade = trades.GetItemAt(i);
                cBuilder.Append(cTrade.Ticket).Append(',').Append(cTrade.SymbolId).Append(',').Append(cTrade.Category).Append(',').Append(cTrade.Action).Append(',').Append(cTrade.Contracts).Append(',').Append(cTrade.Price).Append(',').Append(cTrade.Profit).Append(',').Append(cTrade.Fee).Append(',').Append(cTrade.Tax).Append(',').Append(cTrade.Time).Append(',').AppendLine(cTrade.Comment);
            }
            return(cBuilder.ToString());
        }
Example #4
0
        private static string ProcessHistorys(HistoryBoundList trades)
        {
            int iCount = trades.Count - 1;              //內建的歷史資料用來統計總和放在最後一筆

            if (iCount > 0)
            {
                _TradeInfo[] cItems = new _TradeInfo[iCount];
                for (int i = 0; i < iCount; i++)
                {
                    cItems[i] = trades.GetItemAt(i);
                }

                return(JsonConvert.SerializeObject(cItems, Formatting.Indented));
            }
            return("[]");
        }
Example #5
0
        internal TradeService()
        {
            __cQueue  = new Queue <ResponseEvent>(64);
            __cCloses = new HistoryBoundList(512);
            __cOpens  = new TradeBoundList(64, true);
            __cTrusts = new TradeBoundList(32);

            __cTradeTimer           = new Timer();
            __cTradeTimer.Elapsed  += TradeTimer_onElapsed;
            __cTradeTimer.AutoReset = false;
            __cTradeTimer.Interval  = 500;

            __cUpdateTimer           = new Timer();
            __cUpdateTimer.Elapsed  += UpdateTimer_onElapsed;
            __cUpdateTimer.AutoReset = false;
            __cUpdateTimer.Interval  = 500;
        }