// ************************************************************ // CONSTRUCTORS // ************************************************************ #region // Constructor 1 : Full fledged public BloombergFetcher(DBID Dbid, string Ticker, Dictionary <string, string> FieldNames, DateTime StartDate, DateTime EndDate, Dictionary <String, Double> Scaling, List <string> OverrideFields, List <string> OverrideValues, E_PRICING_OPTION PricingOption = E_PRICING_OPTION.PRICING_OPTION_PRICE, E_PERIODICITY_SELECTION PeriodicitySelection = E_PERIODICITY_SELECTION.DAILY, E_PERIODICITY_ADJUSTMENT PeriodicityAdjustment = E_PERIODICITY_ADJUSTMENT.ACTUAL, E_NON_TRADING_DAY_FILL_OPTION NonTradingDayFillOption = E_NON_TRADING_DAY_FILL_OPTION.ACTIVE_DAYS_ONLY, E_NON_TRADING_DAY_FILL_METHOD NonTradingDayFillMethod = E_NON_TRADING_DAY_FILL_METHOD.PREVIOUS_VALUE, string OverrideCurrency = "") { // Set the DBID for the security _dbid = Dbid; // Set the security tickers _bloombergTicker = Ticker; // Set the fields to be queried _fieldNames = FieldNames; // Set the start date of time series _fromDate = StartDate; // Set the start date time series _toDate = EndDate; // Set the scaling to be applied _scaling = Scaling; // Set the override fields overrideFields = OverrideFields; // Set the override values overrideValues = OverrideValues; // Set the pricing option (price or yield) Option_PricingOption = PricingOption; // Set the periodicity (daily, weekly, monthly...) Option_PeriodicitySelection = PeriodicitySelection; // Set the periodicity adjustment (actual, calendar, fiscal) Option_PeriodicityAdjustement = PeriodicityAdjustment; // Set the NA fill option Option_NonTradingDayFillOption = NonTradingDayFillOption; // Set the NA fill method (previous data, etc.) Option_NonTradingDayFillMethod = NonTradingDayFillMethod; // Override the currency (do not use) Option_OverrideCurrency = OverrideCurrency; // Tell base which request type we're instaciating requestType = REQUEST_TYPE_HISTORICAL; }
public bool Equals(TezDatabaseGameItem other) { if (object.ReferenceEquals(other, null)) { return(false); } return(DBID.Equals(other.DBID)); }
public virtual void close() { DBID.close(); DBID = null; this.category = null; this.NID = null; this.CID = null; this.TAGS = null; }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); if (!s.StreamAttributeOpt("name", ref Name, Predicates.IsNotNullOrEmpty) && s.IsReading) { Name = string.Format("Condition{0}", DBID.ToString()); } s.StreamableElements("Param", Parameters); }
// Constructor 3 : Ticker, Fields, Start and End dates, Periodicity public BloombergFetcher(DBID Dbid, string Ticker, Dictionary <string, string> FieldNames, DateTime StartDate, DateTime EndDate, Dictionary <String, Double> Scaling, E_PERIODICITY_SELECTION PeriodicitySelection) : this(Dbid : Dbid, Ticker : Ticker, FieldNames : FieldNames, StartDate : StartDate, EndDate : EndDate, Scaling : Scaling, OverrideFields : new List <string>(), OverrideValues : new List <string>(), PricingOption : E_PRICING_OPTION.PRICING_OPTION_PRICE, PeriodicitySelection : PeriodicitySelection, // --------- >> difference from Constructor 2 PeriodicityAdjustment : E_PERIODICITY_ADJUSTMENT.ACTUAL, NonTradingDayFillOption : E_NON_TRADING_DAY_FILL_OPTION.ALL_CALENDAR_DAYS, NonTradingDayFillMethod : E_NON_TRADING_DAY_FILL_METHOD.PREVIOUS_VALUE, OverrideCurrency : "") { }
/// <summary> /// Retrieves the reference data for a given DBID (well-defined problem). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="TableName"></param> /// <param name="inputTicker"></param> /// <param name="fieldNames"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public IDtoken Reference(DBID DBID) { string table = myDB.Reference.ToString(); // Build mySQL Select string string mySQLSelect = "SELECT * from " + table + " where DBID = " + DBID.ToInt(); // Connect and Request using (var connection = new MySqlConnection(connectionString)) { List <IDtoken> sqlResults = (List <IDtoken>)connection.Query <IDtoken>(mySQLSelect); return(sqlResults.FirstOrDefault()); } }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); var db = (MegaloScriptDatabase)s.Owner; if (!s.StreamAttributeOpt("name", ref Name, Predicates.IsNotNullOrEmpty) && s.IsReading) { Name = string.Format("Action{0}", DBID.ToString()); } if (db.SerializeProtoActionReference(s, "template", ref Template) && Template == null) { throw new System.IO.InvalidDataException(string.Format( "Action '{0}' references undefined proto action {1}", Name, Template)); } s.StreamAttributeEnumOpt("flags", ref Flags, f => f != 0); Parameters.Serialize(s); }
/// <summary> /// Select data from a table in the "myDB" schema.. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="DBID"></param> /// <param name="fieldNames"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public List <T> Select <T>(DBID DBID, List <string> fieldNames, DateTime startDate, DateTime endDate) where T : IGenericDatabaseLine { // Determine type of <T> and create instance var type = typeof(T); var Tobj = (T)Activator.CreateInstance(type); // Identify table to be addressed string table = Tobj.GetTable(); //Check dates DateTime myStartDate = (startDate == DateTime.MinValue) ? myStartDate = new DateTime(2013, 12, 31) : myStartDate = startDate; DateTime myEndDate = (startDate == DateTime.MinValue) ? myEndDate = DateTime.Today : myEndDate = endDate; // Check fields if (fieldNames.Count == 0) { fieldNames = new List <string>() { "*" }; } // Build string with columns to select string columnsForSQL = this.joinString(fieldNames, " ,", false); // Build string with start date string startDateForRequest = this.buildDateString(myStartDate); // Build string with end date string endDateForRequest = this.buildDateString(myEndDate); // Build mySQL Select string string mySQLSelect = "SELECT " + columnsForSQL + " from " + table + " where DBID = '" + (uint)DBID.ToInt() + "' and Date >= " + startDateForRequest + " and Date <= " + endDateForRequest + " ORDER BY Date;"; // Connect and Request using (var connection = new MySqlConnection(connectionString)) { var sqlResults = (List <T>)connection.Query <T>(mySQLSelect); return((List <T>)sqlResults); } }
// Full fledged public EquityIndexStrangleStrategy(DateTime valuationDate, MarkitEquityUnderlying underlying, int numberStrangles, Period spacing, Calendar calendar, DBID callStrikeDBID, DBID putStrikeDBID, DBID underlyingDBID, Dictionary <int, DBID> strangleMtM_DBID) { // Set the date this.valuationDate = valuationDate; // Set the underlying _underlying = underlying; // Set the strategy properties _numberStrangles = numberStrangles; _spacing = spacing; _calendar = calendar; // Set the identification (to locate data in the DB) _callStrikeID = callStrikeDBID; _putStrikeID = putStrikeDBID; _underlyingID = underlyingDBID; strangleMTM_Tokens = strangleMtM_DBID; }
// ************************************************************ // OUTPUT METHODS // ************************************************************ /* * public List<InterestRate_Line> ToList(DBID dbid) * { * * // Instanciate a new line * InterestRate_Line myLine = new InterestRate_Line(); * * // Identify table to be addressed * List<string> fields = myLine.GetDataFields(); * * // Output container * List<InterestRate_Line> output = new List<InterestRate_Line>(); * * // Loop around lines * foreach(KeyValuePair<DateTime, myElement> item in data) * { * output.Add(new InterestRate_Line(item.Key, dbid, item.Value.data)); * } * * // Return * return output; * * } */ public List <T> ToList <T>(DBID dbid) where T : GenericDatabaseLine { // Determine type of <T> and create instance var type = typeof(T); T Tobj = (T)Activator.CreateInstance(type); // Identify table to be addressed List <string> fields = Tobj.GetDataFields(); // Output container List <T> output = new List <T>(); // Loop around lines foreach (KeyValuePair <DateTime, myElement> item in data) { T myLine = (T)Activator.CreateInstance(type, item.Key, dbid, item.Value.data); output.Add(myLine); } // Return return(output); }
protected List <T> Fetch_Bloomberg <T>(DBID dbid_, String externalID_, Dictionary <String, String> Fields, DateTime startDate_, DateTime endDate_, Dictionary <String, Double> scaling_) where T : GenericDatabaseLine { Dictionary <string, double> Scaling = new Dictionary <string, double>() { { "Open", 1.0 }, { "High", 1.0 }, { "Low", 1.0 }, { "Close", 1.0 }, { "Volume", 1.0 }, { "Bid", 1.0 }, { "Ask", 1.0 }, { "AdjustedClose", 1.0 } }; Dictionary <string, string> BloombergDict = new Dictionary <string, string> { { "Bid", "PX_BID" }, // Modifie de BID à PX_BID ... même chose pour l'ask { "Ask", "PX_ASK" }, { "Open", "PX_OPEN" }, { "High", "PX_HIGH" }, { "Low", "PX_LOW" }, { "Close", "PX_LAST" }, { "Volume", "VOLUME" }, { "AdjustedClose", "" } }; // Fetch var myBbergFetcher = new BloombergFetcher <T>(dbid_, externalID_, Fields, startDate_, endDate_, scaling_); //var myBbergFetcher = new BloombergFetcher<T>(dbid_, externalID_, BloombergDict, startDate_, endDate_, Scaling); // Return return(myBbergFetcher.Fetch()); }
/// <summary> /// Checks for equality of card data /// </summary> /// <param name="other">The other card</param> /// <returns>true if and only if the database IDs match</returns> public bool Equals(CardData other) { return(DBID.Equals(other.DBID)); }
public override int GetHashCode() { return(DBID.GetHashCode()); }
// ************************************************************ // CONSTRUCTOR // ************************************************************ #region Constuctors // Generic //public EquityIndexStrangleStrategy() { } // No Date public EquityIndexStrangleStrategy(MarkitEquityUnderlying underlying, int numberStrangles, Period spacing, Calendar calendar, DBID callStrikeDBID, DBID putStrikeDBID, DBID underlyingDBID, Dictionary <int, DBID> strangleMtM_DBID) : this(new DateTime(), underlying, numberStrangles, spacing, calendar, callStrikeDBID, putStrikeDBID, underlyingDBID, strangleMtM_DBID) { }