Ejemplo n.º 1
0
        public static void AddRow(int index, string date)
        {
            Row    row  = RowList.Get(index);
            string rowS = date + ";" + row.EntryTriangle.Symbol1.Name + ";" +
                          row.EntryTriangle.Symbol1.MarketData.Ask.ToString() + ";" +
                          row.EntryTriangle.Symbol1.MarketData.Bid.ToString() + ";" +
                          row.EntryTriangle.Symbol1.MarketData.Quantity.ToString() + ";" +
                          row.EntryTriangle.Symbol2.Name.ToString() + ";" +
                          row.EntryTriangle.Symbol2.MarketData.Ask.ToString() + ";" +
                          row.EntryTriangle.Symbol2.MarketData.Bid.ToString() + ";" +
                          row.EntryTriangle.Symbol2.MarketData.Quantity.ToString() + ";" +
                          row.EntryTriangle.Symbol3.Name.ToString() + ";" +
                          row.EntryTriangle.Symbol3.MarketData.Ask.ToString() + ";" +
                          row.EntryTriangle.Symbol3.MarketData.Bid.ToString() + ";" +
                          row.EntryTriangle.Symbol3.MarketData.Quantity.ToString() + ";" + row.EntryTriangle.CalculateArbitrage().ToString() + "\n";

            sb.Append(rowS);



            //lastIndex += 1;
            //xlWorkSheet.Cells[lastIndex, 1] = row.EntryTriangle.Symbol1.Name;
            //xlWorkSheet.Cells[lastIndex, 2] = row.EntryTriangle.Symbol1.MarketData.Ask;
            //xlWorkSheet.Cells[lastIndex, 3] = row.EntryTriangle.Symbol1FactorAsset;
            //xlWorkSheet.Cells[lastIndex, 4] = row.EntryTriangle.Symbol2.Name;
            //xlWorkSheet.Cells[lastIndex, 5] = row.EntryTriangle.Symbol2.MarketData.Bid;
            //xlWorkSheet.Cells[lastIndex, 6] = row.EntryTriangle.Symbol2FactorAsset;
            //xlWorkSheet.Cells[lastIndex, 7] = row.EntryTriangle.Symbol3.Name;
            //xlWorkSheet.Cells[lastIndex, 8] = row.EntryTriangle.Symbol3.MarketData.Bid;
            //xlWorkSheet.Cells[lastIndex, 9] = row.EntryTriangle.Symbol3FactorAsset;
            //xlWorkSheet.Cells[lastIndex, 10] = row.EntryTriangle.CalculateArbitrage();
        }
Ejemplo n.º 2
0
        public static void OpenPosition(int index, string date,
                                        double sm1Ask, double sm1Bid, double sm2Ask, double sm2Bid, double sm3Ask, double sm3Bid)
        {
            Row row = RowList.Get(index);

            if (!row.EntryTriangle.isOpen)
            {
                MapRow(index, date, sm1Ask, sm1Bid, sm2Ask, sm2Bid, sm3Ask, sm3Bid);
                row.EntryTriangle.isOpen = true;
            }
        }
Ejemplo n.º 3
0
        public static string GetRow(int i)
        {
            string output = "Entry";
            Row    row    = RowList.Get(i);

            output += "," + row.EntryTriangle.Symbol1.Name;

            output += "," + row.EntryTriangle.Symbol2.Name;

            output += "," + row.EntryTriangle.Symbol3.Name;

            return(output);
        }
Ejemplo n.º 4
0
        public static string MapRow(int rowIndex, string date,
                                    double sm1Ask, double sm1Bid, double sm2Ask, double sm2Bid, double sm3Ask, double sm3Bid)
        {
            Row row = RowList.Get(rowIndex);

            row.EntryTriangle.Symbol1.MarketData.Ask = sm1Ask;
            row.EntryTriangle.Symbol1.MarketData.Bid = sm1Bid;
            row.EntryTriangle.Symbol2.MarketData.Ask = sm2Ask;
            row.EntryTriangle.Symbol2.MarketData.Bid = sm2Bid;
            row.EntryTriangle.Symbol3.MarketData.Ask = sm3Ask;
            row.EntryTriangle.Symbol3.MarketData.Bid = sm3Bid;
            row.EntryTriangle.SetFactorValue();
            ExcelWriter.AddRow(rowIndex, date);
            if (row.EntryTriangle.CalculateArbitrage() > 0 && !row.EntryTriangle.isOpen)
            {
                return(row.EntryTriangle.Symbol1.Name + "," + row.EntryTriangle.Symbol1FactorAsset + "," +
                       row.EntryTriangle.Symbol2.Name + "," + row.EntryTriangle.Symbol2FactorAsset + ","
                       + row.EntryTriangle.Symbol3.Name + "," + row.EntryTriangle.Symbol3FactorAsset);
            }
            else
            {
                return("-1");
            }
        }
Ejemplo n.º 5
0
 public static int FillList()
 {
     ExcelWriter.initalizeDocument();
     return(RowList.initalizeList());
 }
Ejemplo n.º 6
0
        public static void ReadFile()
        {
            Excel.Application xlApp       = new Excel.Application();
            Excel.Workbook    xlWorkbook  = xlApp.Workbooks.Open(@"C:\Users\Burak Dal\source\repos\ReadExcel\ReadExcel\bin\Debug\Meta.xlsx");
            Excel._Worksheet  xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range       xlRange     = xlWorksheet.UsedRange;
            int colCount = xlRange.Columns.Count;
            int rowCount = xlRange.Rows.Count;

            for (int i = 2; i <= rowCount; i++)
            {
                string
                    id = null, sym1f = null, sym1 = null,
                    sym2 = null, sym2f = null, sym3 = null, sym3f = null,
                    sym4 = null, sym4f = null, sym5 = null, sym5f = null,
                    sym6 = null, sym6f = null;

                if (xlRange.Cells[i, 1] != null && xlRange.Cells[i, 1].Value2 != null)
                {
                    id = xlRange.Cells[i, 1].Value2.ToString();
                }
                if (xlRange.Cells[i, 2] != null && xlRange.Cells[i, 2].Value2 != null)
                {
                    sym1 = xlRange.Cells[i, 2].Value2.ToString();
                }
                if (xlRange.Cells[i, 4] != null && xlRange.Cells[i, 4].Value2 != null)
                {
                    sym1f = xlRange.Cells[i, 4].Value2.ToString();
                }
                if (xlRange.Cells[i, 6] != null && xlRange.Cells[i, 6].Value2 != null)
                {
                    sym2 = xlRange.Cells[i, 6].Value2.ToString();
                }
                if (xlRange.Cells[i, 8] != null && xlRange.Cells[i, 8].Value2 != null)
                {
                    sym2f = xlRange.Cells[i, 8].Value2.ToString();
                }
                if (xlRange.Cells[i, 10] != null && xlRange.Cells[i, 10].Value2 != null)
                {
                    sym3 = xlRange.Cells[i, 10].Value2.ToString();
                }
                if (xlRange.Cells[i, 12] != null && xlRange.Cells[i, 12].Value2 != null)
                {
                    sym3f = xlRange.Cells[i, 12].Value2.ToString();
                }
                if (xlRange.Cells[i, 15] != null && xlRange.Cells[i, 15].Value2 != null)
                {
                    sym4 = xlRange.Cells[i, 15].Value2.ToString();
                }
                if (xlRange.Cells[i, 17] != null && xlRange.Cells[i, 17].Value2 != null)
                {
                    sym4f = xlRange.Cells[i, 17].Value2.ToString();
                }
                if (xlRange.Cells[i, 19] != null && xlRange.Cells[i, 19].Value2 != null)
                {
                    sym5 = xlRange.Cells[i, 19].Value2.ToString();
                }
                if (xlRange.Cells[i, 21] != null && xlRange.Cells[i, 21].Value2 != null)
                {
                    sym5f = xlRange.Cells[i, 21].Value2.ToString();
                }
                if (xlRange.Cells[i, 23] != null && xlRange.Cells[i, 23].Value2 != null)
                {
                    sym6 = xlRange.Cells[i, 23].Value2.ToString();
                }
                if (xlRange.Cells[i, 25] != null && xlRange.Cells[i, 25].Value2 != null)
                {
                    sym6f = xlRange.Cells[i, 23].Value2.ToString();
                }

                var entry = new EntryTriangle(sym1, sym2, sym3, sym1f, sym2f, sym3f);
                var close = new CloseTriangle(sym4, sym5, sym6, sym4f, sym5f, sym6f);
                var row   = new Row(entry, close, id);
                RowList.Add(row);
            }
        }