Exemple #1
0
        //public TinyTime6Sec GetNextValidDateTime()
        //{
        //    val.
        //    return tt;
        //}

        public static DateTime GetNextValidDateTime(DateTime t)
        {
            TinyTime6Sec tt = new TinyTime6Sec(t.Ticks);

            tt++;
            return(tt);
        }
Exemple #2
0
        /// <summary>Let create a byteArray for DB storage. We need brfID so we can fill the headers with time and other date related data.</summary>
        public byte[] GetAsBinary(uint briefID)
        {
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            DateTime curTime       = new TinyTime6Sec(briefID);
            TimeSpan sinceStart    = curTime.TimeOfDay - (new TimeSpan(TinyTime6Sec.START_HOUR, 0, 0));
            TimeSpan timeRemaining = (new TimeSpan(TinyTime6Sec.END_HOUR, 0, 0)) - curTime.TimeOfDay;

            ////////////// fill-in header information ///////////////////////
            bw.Write(briefID);                                  // free_BrfID  0    // BrfID stored in UINT format to aid in debugging
            //bw.Write((float)0.0                            ); // free_slot0  1    // can be filled in by the client with tstNo to aid in debugging
            //bw.Write((float)curTime.Year                   ); // cur_yearrr  2    // Removed because is usually the same
            //bw.Write((float)curTime.Month                  ); // cur_Monthh  3    // Removed because is usually the same
            bw.Write((float)curTime.Day);                       // cur_DayNum  4
            bw.Write((float)curTime.Hour);                      // cur_Hourrr  5
            bw.Write((float)curTime.Minute);                    // cur_Minute  6
            bw.Write((float)curTime.Second);                    // cur_Second  7
            //bw.Write((float)curTime.Millisecond            ); // cur_MilliS  8    // Removed because always zero
            bw.Write((float)curTime.DayOfWeek);                 // Day_OfWeek  9
            //bw.Write((float)curTime.DayOfYear              ); // Day_OfYear  10   // Removed - Not really useful for less then a years of data
            bw.Write((float)curTime.TimeOfDay.TotalMinutes);    // Total_Mins  11
            bw.Write((float)curTime.TimeOfDay.TotalSeconds);    // Total_Secs  12
            bw.Write((float)sinceStart.Hours);                  // Hours_Open  13
            bw.Write((float)timeRemaining.Hours);               // Hours_Rema  14
            //bw.Write((float)sinceStart.Minutes             ); // Secon_Open  15   // Removed - Same as curTime.minute
            bw.Write((float)timeRemaining.Minutes);             // Secon_Rema  16   // note: when changing set 17/*nonInxHdrCt*/
            bw.Write(indexes[0].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[2].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[2].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[3].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);

            // Reset the headers by filling them with zero.
            while (bw.BaseStream.Length < 32 * 4)
            {
                bw.Write((float)0.0);
            }

            ////////////// fill-in symbol information ///////////////////////
            for (int s = 0; s < symbCt; s++)
            {
                bw.Write(symbols[s].volume_day); // 0 |float volume_day|carried         |days total volume
                bw.Write(symbols[s].volume_ths); // 1 |float volume_ths|reset+running   |volume for this time period (calculated)
                bw.Write(symbols[s].largTrdPrc); // 2 |float largTrdPrc|reset+running   |price at when largest trade
                bw.Write(symbols[s].price_high); // 3 |float price_high|reset+running   |highest price in period
                bw.Write(symbols[s].price_loww); // 4 |float price_loww|reset+running   |lowest price in period
                bw.Write(symbols[s].price_last); // 5 |float price_last|carried         |last trade price
                bw.Write(symbols[s].price_bidd); // 6 |float price_bidd|carried         |last bid price
                bw.Write(symbols[s].price_askk); // 7 |float price_askk|carried         |last ask price
                bw.Write(symbols[s].volume_bid); // 8 |float volume_bid|carried         |last bid size
                bw.Write(symbols[s].volume_ask); // 9 |float volume_ask|carried         |last ask size
                bw.Write(symbols[s].price_medn); // 10|float price_medn|overwritten     |Statistics median for price
                bw.Write(symbols[s].price_mean); // 11|float price_mean|overwritten     |Statistics mean for price
                bw.Write(symbols[s].price_mode); // 12|float price_mode|overwritten     |Statistics mode for price
                bw.Write(symbols[s].buyy_price); // 13|float buyy_price|carried         |A guess at what the buy price might be.
                bw.Write(symbols[s].sell_price); // 14|float sell_price|carried         |A guess at what the sell price might be.
                bw.Write(symbols[s].largTrdVol); // 15|float largTrdVol|reset+running   |The Size of largest trade
                bw.Write(symbols[s].prcModeCnt); // 16|float prcModeCnt|overwritten     |Statistics mode price count
                bw.Write(symbols[s].vol_at_ask); // 17|float vol_at_ask|reset+running   |Volume at ask price
                bw.Write(symbols[s].vol_no_chg); // 18|float vol_no_chg|reset+running   |Volume with no last change in last size.
                bw.Write(symbols[s].vol_at_bid); // 19|float vol_at_bid|reset+running   |Volume at bid price
                bw.Write(symbols[s].BidUpTicks); // 20|float BidUpTicks|reset+running   |How many times the bid went up.
                bw.Write(symbols[s].BidDnTicks); // 21|float BidDnTicks|reset+running   |How many times the bid went down.
                bw.Write(symbols[s].sale_count); // 22|float sale_count|reset+running   |How many trades did we see.
                bw.Write(symbols[s].extIndex00); // 23|float extIndex00|calculated      |6 sec. calculated ATR
                bw.Write(symbols[s].extIndex01); // 24|float extIndex01|reset+calculated|6 sec. calculated CCI
                bw.Write(symbols[s].extIndex02); // 25|float extIndex02|reset+calculated|6 sec. calculated EMA
                bw.Write(symbols[s].extIndex03); // 26|float extIndex03|reset+calculated|6 sec. calculated Kama
                bw.Write(symbols[s].extIndex04); // 27|float extIndex04|reset+calculated|6 sec. calculated RSI
                bw.Write(symbols[s].extIndex05); // 28|float extIndex05|reset+calculated|6 sec. calculated SMA
                bw.Write(symbols[s].extIndex06); // 29|float extIndex06|reset+calculated|6 sec. calculated SarExt
                bw.Write(symbols[s].extIndex07); // 30|float extIndex07|reset+calculated|6 sec. calculated MACD
                bw.Write(symbols[s].extIndex08); // 31|float extIndex08|reset+calculated|6 sec. calculated Bollinger bands
            }

            byte[] ret = ms.ToArray();
            ms.Dispose();
            //bw.Dispose();
            return(ret);
        }
Exemple #3
0
        /// <summary>Let create a byteArray for DB storage. We need brfID so we can fill the headers with time and other date related data.</summary>
        public byte[] GetAsBinary(uint briefID)
        {
            MemoryStream ms = new MemoryStream();
            BinaryWriter bw = new BinaryWriter(ms);

            DateTime curTime       = new TinyTime6Sec(briefID);
            TimeSpan sinceStart    = curTime.TimeOfDay - (new TimeSpan(TinyTime6Sec.START_HOUR, 0, 0));
            TimeSpan timeRemaining = (new TimeSpan(TinyTime6Sec.END_HOUR, 0, 0)) - curTime.TimeOfDay;

            ////////////// fill-in header information ///////////////////////
            bw.Write(briefID);                                  // free_BrfID  0    // BrfID stored in UINT format to aid in debugging
            //bw.Write((float)0.0                            ); // free_slot0  1    // can be filled in by the client with tstNo to aid in debugging
            //bw.Write((float)curTime.Year                   ); // cur_yearrr  2    // Removed because is usually the same
            //bw.Write((float)curTime.Month                  ); // cur_Monthh  3    // Removed because is usually the same
            bw.Write((float)curTime.Day);                       // cur_DayNum  4
            bw.Write((float)curTime.Hour);                      // cur_Hourrr  5
            bw.Write((float)curTime.Minute);                    // cur_Minute  6
            bw.Write((float)curTime.Second);                    // cur_Second  7
            //bw.Write((float)curTime.Millisecond            ); // cur_MilliS  8    // Removed because always zero
            bw.Write((float)curTime.DayOfWeek);                 // Day_OfWeek  9
            //bw.Write((float)curTime.DayOfYear              ); // Day_OfYear  10   // Removed - Not really useful for less then a years of data
            bw.Write((float)curTime.TimeOfDay.TotalMinutes);    // Total_Mins  11
            bw.Write((float)curTime.TimeOfDay.TotalSeconds);    // Total_Secs  12
            bw.Write((float)sinceStart.Hours);                  // Hours_Open  13
            bw.Write((float)timeRemaining.Hours);               // Hours_Rema  14
            //bw.Write((float)sinceStart.Minutes             ); // Secon_Open  15   // Removed - Same as curTime.minute
            bw.Write((float)timeRemaining.Minutes);             // Secon_Rema  16   // note: when changing set 17/*nonInxHdrCt*/
            bw.Write(indexes[0].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[1].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[2].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[2].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[3].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[4].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.bidSz__0].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[5].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.bidPc__1].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.askPc__2].last);
            bw.Write(indexes[6].tickTypeAttrib[(int)IB_TickType.lastPc_4].last);

            // Reset the headers by filling them with zero.
            while (bw.BaseStream.Length < 32 * 4)
            {
                bw.Write((float)0.0);
            }

            ////////////// fill-in symbol information ///////////////////////
            for (int s = 0; s < symbCt; s++)
            {
                bw.Write(symbols[s].volume_day);
                bw.Write(symbols[s].volume_ths);
                bw.Write(symbols[s].largTrdPrc);
                bw.Write(symbols[s].price_high);
                bw.Write(symbols[s].price_loww);
                bw.Write(symbols[s].price_last);
                bw.Write(symbols[s].price_bidd);
                bw.Write(symbols[s].price_askk);
                bw.Write(symbols[s].volume_bid);
                bw.Write(symbols[s].volume_ask);
                bw.Write(symbols[s].price_medn);
                bw.Write(symbols[s].price_mean);
                bw.Write(symbols[s].price_mode);
                bw.Write(symbols[s].buyy_price);
                bw.Write(symbols[s].sell_price);
                bw.Write(symbols[s].largTrdVol);
                bw.Write(symbols[s].prcModeCnt);
                bw.Write(symbols[s].vol_at_ask);
                bw.Write(symbols[s].vol_no_chg);
                bw.Write(symbols[s].vol_at_bid);
                bw.Write(symbols[s].BidUpTicks);
                bw.Write(symbols[s].BidDnTicks);
                bw.Write(symbols[s].sale_count);
                bw.Write(symbols[s].extIndex00);
                bw.Write(symbols[s].extIndex01);
                bw.Write(symbols[s].extIndex02);
                bw.Write(symbols[s].extIndex03);
                bw.Write(symbols[s].extIndex04);
                bw.Write(symbols[s].extIndex05);
                bw.Write(symbols[s].extIndex06);
                bw.Write(symbols[s].extIndex07);
                bw.Write(symbols[s].extIndex08);
            }

            byte[] ret = ms.ToArray();
            ms.Dispose();
            //bw.Dispose();
            return(ret);
        }
Exemple #4
0
 public static TinyTime6Sec GetNextValidDateTime(TinyTime6Sec tt)
 {
     tt++;
     return(tt);
 }
Exemple #5
0
        public long Ticks()
        {
            DateTime dt = new TinyTime6Sec(val);

            return(dt.Ticks);
        }