void IDataminingDatabase.addIndicator(WalkerIndicator indicator, string instrument, string fieldId) { var collection = mongodb.getDB().GetCollection("prices"); long start = database.getFirstTimestamp(); long end = database.getLastTimestamp(); string name = "Indicator " + indicator.getName() + " " + instrument + " " + fieldId; progress.setProgress(name, 0); int done = 0; long count = 0; var docs = collection.FindAs <BsonDocument>(Query.And(Query.Exists(fieldId), Query.EQ("instrument", instrument), Query.LT("timestamp", end), Query.GTE("timestamp", start))).SetSortOrder(SortBy.Ascending("timestamp")); docs.SetFlags(QueryFlags.NoCursorTimeout); count = docs.Count(); foreach (var doc in docs) { progress.setProgress(name, Convert.ToInt32(Convert.ToDouble(done) / Convert.ToDouble(count) * 100d)); done++; indicator.setNextData(doc["timestamp"].AsInt64, doc[fieldId].AsDouble); collection.FindAndModify(new FindAndModifyArgs() { Query = Query.EQ("_id", doc["_id"]), Update = Update.Set(indicator.getName() + "_" + fieldId, indicator.getIndicator().value) }); } progress.remove(name); }
public void setNewPrice(double[] prices) { double mid = (prices[(int)PriceDataIndeces.Ask] + prices[(int)PriceDataIndeces.Bid]) / 2d; indicator.setNextData(Convert.ToInt64(prices[(int)PriceDataIndeces.Date]), mid); }