Beispiel #1
0
        public static void TestCorrectedExtremumsFast(string toolName, int startStop, int endStop, int stopStep,
                                                      int startTrStop, int endTrStop, int trStopStep, int pegTopSize)
        {
            var repository = new HistoryRepository(toolName, false);

            var headers = new List <string> {
                "Stop", "Trailing stop", "Breakeven size"
            };

            headers.AddRange(TradesResult.GetHeaders());
            var table = new List <List <string> >();

            for (int stop = startStop; stop <= endStop; stop += stopStep)
            {
                for (int trStop = Math.Max(startTrStop, stop); trStop <= endTrStop; trStop += trStopStep)
                {
                    for (double breakevenSize = 0.0; breakevenSize <= 0.61; breakevenSize += 0.2)
                    {
                        var strat = new CorrectedExtremumStrategy(stop, pegTopSize, breakevenSize, trStop);

                        var result = strat.Run(repository.Days);
                        result.PrintDepo(@"depo\" + stop.ToString("D4") + "_" + trStop.ToString("D4") + "_" +
                                         ((int)(100 * breakevenSize)).ToString("D2") + ".txt");

                        var currentText = new List <string> {
                            stop.ToString(), trStop.ToString(), breakevenSize.ToEnString()
                        };
                        currentText.AddRange(result.GetTableRow());
                        table.Add(currentText);
                    }
                }
            }

            TablesWriter.PrintExcel("out.xlsx", headers, table);
        }
Beispiel #2
0
        private HiPOSDetailsListListModel GetDataList(string StoreName, DateTime startDate, DateTime endDate)
        {
            decimal num = default(decimal);
            HiPOSDetailsListListModel hiPOSDetailsListListModel = new HiPOSDetailsListListModel();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            HiPOSHelper  hiPOSHelper    = new HiPOSHelper();
            string       format         = "yyyyMMdd";
            TradesResult hishopTrades   = hiPOSHelper.GetHishopTrades(masterSettings.HiPOSAppId, masterSettings.HiPOSMerchantId, StoreName, startDate.ToString(format), endDate.ToString(format), base.CurrentPageIndex, base.CurrentPageSize);

            if (hishopTrades.error == null)
            {
                List <StoreResponse> list = hishopTrades.merchant_trades_response.detail.ToList();
                num = list.Sum((StoreResponse r) => r.count);
                hiPOSDetailsListListModel.rows = new List <Dictionary <string, object> >();
                foreach (StoreResponse item in list)
                {
                    string systemStoreId = this.GetSystemStoreId(item.name);
                    Dictionary <string, object> dictionary = item.ToDictionary();
                    dictionary["total"] = dictionary["total"].ToDecimal(0).F2ToString("f2");
                    dictionary.Add("systemStoreId", systemStoreId);
                    dictionary.Add("DeviceCount", item.devices.Count());
                    foreach (DeviceResponse device in item.devices)
                    {
                        device.total = device.total.F2ToString("f2").ToDecimal(0);
                    }
                    hiPOSDetailsListListModel.rows.Add(dictionary);
                }
            }
            hiPOSDetailsListListModel.sum_amount  = hishopTrades.merchant_trades_response.total.F2ToString("f2").ToDecimal(0);
            hiPOSDetailsListListModel.total       = num.ToInt(0);
            hiPOSDetailsListListModel.recordcount = hishopTrades.merchant_trades_response.items_count;
            return(hiPOSDetailsListListModel);
        }
        public void AddRow(TradeParams parameters, TradesResult result)
        {
            var row = parameters.GetTableRow(paramsFieldNames)
                .Concat(result.GetTableRow(resultsFieldNames))
                .ToList();

            table.Add(row);
        }
        public TradesResult Run(List <Day> days)
        {
            var result = new TradesResult();

            foreach (var day in days)
            {
                var profit = GetDaysDeal(day.FiveMins);
                if (profit == null)
                {
                    continue;
                }

                result.AddDeal(profit);
            }

            return(result);
        }
        public static TradesResult TestTakeProfit(List <List <Tick> > candles, uint timeOffset, int exitMovingSize, int stopLoss, int takeProfit)
        {
            if (timeOffset > TimeFrame)
            {
                throw new Exception("Bad time offset");
            }

            var tradesResult = new TradesResult();

            foreach (var candle in candles)
            {
                int dealResult = GetCandleResult(candle, timeOffset, exitMovingSize, stopLoss, takeProfit);

                if (dealResult == -1)
                {
                    continue;
                }

                tradesResult.AddDeal(dealResult);
            }

            return(tradesResult);
        }
		public static string GetValue(string fieldName, TradesResult result) => mapper[fieldName](result);
 public void PrintDepoWithParamsName(TradeParams parameters, TradesResult result)
 {
     string filename = GetFilenameByParams(parameters);
     File.WriteAllLines(Path.Combine(outputPath, depoPrintsDir, filename), result.GetDepositSizes().Select(s => s.ToString()));
 }