Class DataStore
Provides a fast in-memory datastore
[ProtoContract]
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class DataStore : DataStoreBase, IDataStore, ICloneable
- Inheritance
-
DataStore
- Implements
- Inherited Members
- Extension Methods
Properties
CanPersist
Returns true.
public override bool CanPersist { get; }
Property Value
HasTrades
Returns true if the datastore has any trades.
public override bool HasTrades { get; }
Property Value
Methods
Clear()
Clears the datastore.
public override void Clear()
Clone()
Returns a copy of this datastore. The internal data objects are shallow copies since they are typically read-only.
public DataStore Clone()
Returns
GetGlobalVariables()
Returns global variables.
protected override VariableDictionary GetGlobalVariables()
Returns
GetInstruments()
Returns the instruments in the datastore.
protected override InstrumentCollection GetInstruments()
Returns
GetNextTradeId()
Returns the next trade id.
protected override long GetNextTradeId()
Returns
GetPricing(long, string, DateTime)
Returns pricing for the specified position on the specified date.
protected override Bar GetPricing(long positionId, string symbol, DateTime date)
Parameters
Returns
GetRisk(long, DateTime)
Returns risk for the specified position on the specified date.
protected override double GetRisk(long positionId, DateTime date)
Parameters
Returns
GetRoll(long, DateTime)
Returns a roll if any for the specified position on the specified date.
protected override Roll GetRoll(long positionId, DateTime date)
Parameters
Returns
GetStartAndEndDates()
Returns the start and end dates of data within the datastore.
protected override DateRange GetStartAndEndDates()
Returns
GetStrategyNames()
Returns the strategy names within the datastore.
protected override IEnumerable<string> GetStrategyNames()
Returns
GetStrategyVariables(string)
Returns strategy variables for the specified strategy.
protected override VariableDictionary GetStrategyVariables(string strategyName)
Parameters
strategyName
string
Returns
GetSymbols()
Returns the symbols within the datastore.
protected override IEnumerable<string> GetSymbols()
Returns
GetTradeDates()
Returns an enumerable of dates on which there are trades.
protected override IEnumerable<DateTime> GetTradeDates()
Returns
GetTrades()
Returns all trades within the datastore.
protected override IEnumerable<Trade> GetTrades()
Returns
GetTrades(DateTime)
Returns all the trades on a specified date. This does not include time of day.
protected override IEnumerable<Trade> GetTrades(DateTime date)
Parameters
date
DateTime
Returns
Load(Stream)
Loads a datastore from the specified stream.
public static DataStore Load(Stream stream)
Parameters
stream
Stream
Returns
Load(string)
Loads the specified datastore file from disk.
public static DataStore Load(string fileName)
Parameters
fileName
string
Returns
Merge(IDataStore)
Merges the specified datastore into the existing one.
public override void Merge(IDataStore dataStore)
Parameters
dataStore
IDataStore
Save(Stream, PersistenceFormat)
Saves this datastore to a stream using the specified persistence format.
public void Save(Stream stream, PersistenceFormat format)
Parameters
stream
Streamformat
PersistenceFormat
Save(string)
Saves the datastore to disk using the specified file name.
public override void Save(string fileName)
Parameters
fileName
string
Save(string, PersistenceFormat, bool)
Saves the datastore to disk using the specified parameters.
public void Save(string fileName, PersistenceFormat format, bool compress)
Parameters
fileName
stringformat
PersistenceFormatcompress
bool
Subset(IEnumerable<long>)
Returns a new datastore excluding the specified trade ids. This is typically used to created a new datastore without trades rejected by a previous money manager.
public DataStore Subset(IEnumerable<long> rejectedTrades)
Parameters
rejectedTrades
IEnumerable<long>
Returns
Subset(DateTime, DateTime)
Returns a subset of this datastore with information between the specified start and end dates inclusive.
public DataStore Subset(DateTime startDate, DateTime endDate)
Parameters
Returns
Subset(string)
Returns a new datastore containing just trades for the specified strategy.
public DataStore Subset(string strategyName)
Parameters
strategyName
string
Returns
Exceptions
WriteGlobalVariables(VariableDictionary)
Writes the specified global variables dictionary to the datastore.
protected override void WriteGlobalVariables(VariableDictionary variables)
Parameters
variables
VariableDictionary
WritePricing(long, Bar)
Writes pricing for the specified position.
protected override void WritePricing(long positionId, Bar bar)
Parameters
WriteRisk(long, DateTime, double)
Writes risk for the specified position.
protected override void WriteRisk(long positionId, DateTime date, double risk)
Parameters
WriteRoll(long, Roll)
Writes the specified roll.
protected override void WriteRoll(long positionId, Roll roll)
Parameters
WriteStrategyVariables(string, VariableDictionary)
Writes the specified strategy variables.
protected override void WriteStrategyVariables(string strategyName, VariableDictionary variables)
Parameters
strategyName
stringvariables
VariableDictionary
WriteTrade(Trade)
Writes the specified trade.
protected override void WriteTrade(Trade trade)
Parameters
trade
Trade