예제 #1
0
        public PairPos createPair(PairSignal oneSignal)
        {
            Equities etfLeg = this.equityDict[oneSignal.EtfTID];
            Equities stkLeg = this.equityDict[oneSignal.StkTID];

            PairPos newPair = new PairPos(etfLeg, stkLeg);

            return(newPair);

            // blah blah
            //foreach (var KeyValuePair in this.TickerSymbolDict)
            //{
            //    // skip etf
            //    if ((KeyValuePair.Key & 1) == 1)
            //        continue;

            //    PairPos newPair = new PairPos();
            //    newPair.PairBeta = 0;   // beta initialize

            //    int tmpEtfTID = (KeyValuePair.Key & 1024) + 1;      // clear all digits in 1 to 9. Aka, clear stk infomation
            //    newPair.pairEtfLeg.TickerID = tmpEtfTID;
            //    try
            //    {
            //        newPair.pairEtfLeg.Symbol = this.TickerSymbolDict[tmpEtfTID];
            //    }
            //    catch (Exception)
            //    {
            //        throw;
            //    }
            //    newPair.pairStkLeg.TickerID = KeyValuePair.Key;
            //    newPair.pairStkLeg.Symbol = KeyValuePair.Value;

            //    this.PairPosDict.Add(KeyValuePair.Key, newPair);
            //}
        }
예제 #2
0
        public PairPos(Equities etf, Equities stk)
        {
            this.EtfLeg = etf;
            this.StkLeg = stk;

            this.sScore            = new double[4];
            this.currHoldingPeriod = -1;
            this.thisPairStatus    = PairType.nullType;
        }
예제 #3
0
        // read csv symbol to dictionary
        // the logic of this part is determined by the structure of the symbol file
        // etf: odd tickerID, stk: even tickerID
        public void readSymbols(string csvDir)
        {
            try
            {
                using (var reader = new StreamReader(csvDir))
                {
                    List <string> listA = new List <string>();
                    List <string> listB = new List <string>();

                    var title = reader.ReadLine();  // jump over the title

                    while (!reader.EndOfStream)
                    {
                        var line  = reader.ReadLine();
                        var cells = line.Split(',');
                        int etfID = Convert.ToInt32(cells[0]);
                        int stkID = Convert.ToInt32(cells[2]);

                        int tmpTickerID = new int();
                        // digit 0: stk 0 ; etf 1
                        if (stkID == 0)
                        {
                            tmpTickerID = tmpTickerID | 1;
                        }
                        // digit from 1 to 9: stk ID
                        tmpTickerID = tmpTickerID | (stkID << 1);
                        // digit from 10 to 13: etf ID
                        tmpTickerID = tmpTickerID | (etfID << 10);
                        Equities tmpEquity = new Equities(tmpTickerID, cells[3]);
                        this.equityDict.Add(tmpTickerID, tmpEquity);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("File doesn't exist: {0}", csvDir);
                throw (e);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine("General Exception");
                throw (e);
            }
        }
예제 #4
0
        // read csv symbol to dictionary
        // the logic of this part is determined by the structure of the symbol file
        // etf: odd tickerID, stk: even tickerID
        public void readSymbols(string csvDir)
        {
            try
            {
                using (var reader = new StreamReader(csvDir))
                {
                    List<string> listA = new List<string>();
                    List<string> listB = new List<string>();

                    var title = reader.ReadLine();  // jump over the title

                    while (!reader.EndOfStream)
                    {
                        var line = reader.ReadLine();
                        var cells = line.Split(',');
                        int etfID = Convert.ToInt32(cells[0]);
                        int stkID = Convert.ToInt32(cells[2]);

                        int tmpTickerID = new int();
                        // digit 0: stk 0 ; etf 1
                        if (stkID == 0)
                        {
                            tmpTickerID = tmpTickerID | 1;
                        }
                        // digit from 1 to 9: stk ID
                        tmpTickerID = tmpTickerID | (stkID << 1);
                        // digit from 10 to 13: etf ID
                        tmpTickerID = tmpTickerID | (etfID << 10);
                        Equities tmpEquity = new Equities(tmpTickerID, cells[3]);
                        this.equityDict.Add(tmpTickerID, tmpEquity);
                    }
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("File doesn't exist: {0}", csvDir);
                throw (e);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine("General Exception");
                throw (e);
            }
        }
예제 #5
0
파일: PairObj.cs 프로젝트: cub-/MyPairs
        public PairPos(Equities etf, Equities stk)
        {
            this.EtfLeg = etf;
            this.StkLeg = stk;

            this.sScore = new double[4];
            this.currHoldingPeriod = -1;
            this.thisPairStatus = PairType.nullType;
        }