Ejemplo n.º 1
0
        public static object CreateMarketDataSource(string ContractHandle, object[] Timestamps, object[] MidPrices, object SpreadOpt)
        {
            double spread = Utils.GetOptionalParameter(SpreadOpt, 0.0);

            Contract cc = XLOM.Get <Contract>(ContractHandle);

            object[] timestamps = Utils.GetVector <object>(Timestamps);
            double[] midprices  = Utils.GetVector <double>(MidPrices);

            int  nData  = timestamps.Length;
            bool oaDate = (timestamps[0].GetType() == typeof(double));

            List <ITimestampedDatum> DataSource = new List <ITimestampedDatum>(nData);

            for (int i = 0; i < nData; ++i)
            {
                DateTimeOffset now = new DateTimeOffset((oaDate ? DateTime.FromOADate((double)timestamps[i]) : DateTime.Parse(timestamps[i].ToString())), new TimeSpan(0, 0, 0));
                DataSource.Add(new Market(now, cc.Id, (decimal)(midprices[i] * (1 - 0.5 * spread)), (decimal)(midprices[i] * (1 + 0.5 * spread))));
            }

            DataSourceInfo dsi = new DataSourceInfo("InMemoryMarketDataSource", cc.Id, cc.Symbol);

            if (XLOM.Contains(dsi.ToString()))
            {
                XLOM.Remove(dsi.ToString());
            }

            return(XLOM.Add(dsi.ToString(), DataSource));
        }
Ejemplo n.º 2
0
        public static string DeleteHandle(object[] HandleNames)
        {
            int removed = 0;

            foreach (string s in HandleNames)
            {
                if (XLOM.Remove(s))
                {
                    removed++;
                }
            }

            return(removed + " objects deleted");
        }
Ejemplo n.º 3
0
        public static object CreateImpliedVolDataSource(int ContractId, object[] Timestamps, double[] ImpliedVols)
        {
            int  nData  = Timestamps.Length;
            bool oaDate = (Timestamps[0].GetType() == typeof(double));

            List <ITimestampedDatum> DataSource = new List <ITimestampedDatum>(nData);

            for (int i = 0; i < nData; ++i)
            {
                DateTimeOffset now = new DateTimeOffset((oaDate ? DateTime.FromOADate((double)Timestamps[i]) :
                                                         DateTime.Parse(Timestamps[i].ToString())), new TimeSpan(0, 0, 0));

                DataSource.Add(new ImpliedVol(now, ContractId, ImpliedVols[i]));
            }

            DataSourceInfo dsi = new DataSourceInfo("InMemoryImpliedVolDataSource", ContractId, "ATMF");

            if (XLOM.Contains(dsi.ToString()))
            {
                XLOM.Remove(dsi.ToString());
            }

            return(XLOM.Add(dsi.ToString(), DataSource));
        }
Ejemplo n.º 4
0
        public static object CreateDepositRateDataSource(string Currency, object[] Timestamps, double[] DepositRates)
        {
            int  nData  = Timestamps.Length;
            bool oaDate = (Timestamps[0].GetType() == typeof(double));

            List <ITimestampedDatum> DataSource = new List <ITimestampedDatum>(nData);

            for (int i = 0; i < nData; ++i)
            {
                DateTimeOffset now = new DateTimeOffset((oaDate ? DateTime.FromOADate((double)Timestamps[i]) :
                                                         DateTime.Parse(Timestamps[i].ToString())), new TimeSpan(0, 0, 0));

                DataSource.Add(new DepositRate(now, Currency, DepositRates[i]));
            }

            DataSourceInfo dsi = new DataSourceInfo("InMemoryDepositRateDataSource", 0, Currency);

            if (XLOM.Contains(dsi.ToString()))
            {
                XLOM.Remove(dsi.ToString());
            }

            return(XLOM.Add(dsi.ToString(), DataSource));
        }
Ejemplo n.º 5
0
        private void DeleteObject(object sender, DataGridViewRowCancelEventArgs e)
        {
            OMKey key = new OMKey((string)e.Row.Cells[0].Value, (string)e.Row.Cells[1].Value, (int)e.Row.Cells[2].Value);

            XLOM.Remove(key.ToString());
        }