Table of Contents

Class DataStoreBase

Namespace
Balsam.Data
Assembly
Balsam.Backtester.dll

An abstract base class that defines the contract that must be implemented by all backtester databases. This class implements IDataStore but only exposes a few public methods, hiding the low level functionality that is not needed by users.

public abstract class DataStoreBase : IDataStore
Inheritance
DataStoreBase
Implements
Derived
Inherited Members
Extension Methods

Properties

CanPersist

Returns true if the datastore can be persisted to disk.

public abstract bool CanPersist { get; }

Property Value

bool

HasTrades

Returns true if the DataStore has trades.

public abstract bool HasTrades { get; }

Property Value

bool

Methods

Clear()

Clears the datastore.

public abstract void Clear()

GetGlobalVariables()

Returns the global variables dictionary.

protected abstract VariableDictionary GetGlobalVariables()

Returns

VariableDictionary

GetInstruments()

Returns a collection of all the instruments contained in the datastore.

protected abstract InstrumentCollection GetInstruments()

Returns

InstrumentCollection

GetNextTradeId()

Gets the first valid trade id.

protected abstract long GetNextTradeId()

Returns

long

GetPricing(long, string, DateTime)

Returns the closing price for the specified position or symbol on the specified date.

protected abstract Bar GetPricing(long positionId, string symbol, DateTime date)

Parameters

positionId long
symbol string
date DateTime

Returns

Bar

GetRisk(long, DateTime)

Gets the risk of the specified position on the specified date.

protected abstract double GetRisk(long positionId, DateTime date)

Parameters

positionId long
date DateTime

Returns

double

GetRoll(long, DateTime)

Gets a roll for the specified position on the specified date.

protected abstract Roll GetRoll(long positionId, DateTime date)

Parameters

positionId long
date DateTime

Returns

Roll

GetStartAndEndDates()

Returns the earliest and latest available dates found within the datastore.

protected abstract DateRange GetStartAndEndDates()

Returns

DateRange

GetStrategyNames()

Returns an enumerable of all the strategy names found in the datastore.

protected abstract IEnumerable<string> GetStrategyNames()

Returns

IEnumerable<string>

GetStrategyVariables(string)

Returns a dictionary of all the variables defined for the specified strategy.

protected abstract VariableDictionary GetStrategyVariables(string strategyName)

Parameters

strategyName string

Returns

VariableDictionary

GetSymbols()

Returns an enumerable of all the symbols found in the datastore.

protected abstract IEnumerable<string> GetSymbols()

Returns

IEnumerable<string>

GetTradeDates()

Returns dates on which there are trades.

protected abstract IEnumerable<DateTime> GetTradeDates()

Returns

IEnumerable<DateTime>

GetTrades()

Returns an enumerable of all the trades in the datastore.

protected abstract IEnumerable<Trade> GetTrades()

Returns

IEnumerable<Trade>

GetTrades(DateTime)

Returns an enumerable of all the trades found in the datastore for the specified date.

protected abstract IEnumerable<Trade> GetTrades(DateTime date)

Parameters

date DateTime

Returns

IEnumerable<Trade>

Merge(IDataStore)

Merges the specified datastore into the existing one.

public abstract void Merge(IDataStore dataStore)

Parameters

dataStore IDataStore

Save(string)

Saves the datastore using the specified file name.

public abstract void Save(string fileName)

Parameters

fileName string

WriteGlobalVariables(VariableDictionary)

Writes global variables to the datastore.

protected abstract void WriteGlobalVariables(VariableDictionary variables)

Parameters

variables VariableDictionary

WritePricing(long, Bar)

Writes pricing for the specified tradeId to the datastore.

protected abstract void WritePricing(long positionId, Bar bar)

Parameters

positionId long
bar Bar

WriteRisk(long, DateTime, double)

Writes risk to the datastore.

protected abstract void WriteRisk(long positionId, DateTime date, double risk)

Parameters

positionId long
date DateTime
risk double

WriteRoll(long, Roll)

Writes the specified roll to the datastore.

protected abstract void WriteRoll(long positionId, Roll roll)

Parameters

positionId long
roll Roll

WriteStrategyVariables(string, VariableDictionary)

Writes the specified strategy variables to the datastore.

protected abstract void WriteStrategyVariables(string strategyName, VariableDictionary variables)

Parameters

strategyName string
variables VariableDictionary

WriteTrade(Trade)

Writes the specified trade to the datastore.

protected abstract void WriteTrade(Trade trade)

Parameters

trade Trade