Doxygen
-
class AggregateDataTransform : public sam_trader::transform::DataTransform
- #include <aggregates.h>
Class for aggregating financial data by a desired time span.
Public Functions
-
AggregateDataTransform(BarColumns, sam_trader::TimeSpan const &base, sam_trader::TimeSpan const &desired)
Constructs an AggregateDataTransform instance with the given parameters.
- Parameters:
barColumns – The columns containing financial bar data.
base – The base time span for the financial data.
desired – The desired time span for aggregation.
-
virtual pd::DataFrame transform(pd::DataFrame const&) const final
Transforms the given financial data by aggregating it at the desired time span.
- Parameters:
data – The financial data to transform.
- Returns:
The transformed financial data.
-
virtual std::vector<std::string> getOutputNames() const override
Gets the output names of the transformed financial data.
- Returns:
The output names of the transformed financial data.
Private Members
-
sam_trader::TimeSpan desiredTimeSpan
-
sam_trader::TimeSpan baseTimeSpan
The desired time span for aggregation.
-
AggregateDataTransform(BarColumns, sam_trader::TimeSpan const &base, sam_trader::TimeSpan const &desired)
-
struct Bar
- #include <aggregates.h>
Struct representing a financial bar.
-
struct DataTransform
- #include <data_transform.h>
An abstract base class representing a data transform operation.
Subclassed by sam_trader::transform::AggregateDataTransform, sam_trader::transform::FibRetracementModel, sam_trader::transform::TAModel
Public Types
-
using Ptr = std::unique_ptr<DataTransform>
A unique pointer to a DataTransform object.
Public Functions
-
inline DataTransform(BarColumns prices, ColumnPrefix config)
Constructs a DataTransform object with the given BarColumns and ColumnPrefix.
- Parameters:
prices – The BarColumns to use for the transform.
config – The ColumnPrefix for the transform.
-
virtual pd::DataFrame transform(pd::DataFrame const&) const = 0
Transforms the input DataFrame and returns the transformed DataFrame.
- Parameters:
data – The DataFrame to transform.
- Returns:
The transformed DataFrame.
-
virtual std::vector<std::string> getOutputNames() const = 0
Returns the output names of the transform.
- Returns:
The output names of the transform.
-
virtual ~DataTransform() = default
Virtual destructor for the DataTransform class.
-
using Ptr = std::unique_ptr<DataTransform>
-
struct FibRetracementModel : public sam_trader::transform::DataTransform
Public Functions
-
inline explicit FibRetracementModel(BarColumns priceNames, Args const &args)
Constructs a new instance of the FibRetracementModel.
- Parameters:
priceNames – The column names of the prices.
args – The arguments for the FibRetracementModel.
-
virtual std::vector<std::string> getOutputNames() const override
Gets the names of the output columns.
- Returns:
The names of the output columns.
Public Members
-
int64_t depth = -1
-
inline explicit FibRetracementModel(BarColumns priceNames, Args const &args)
-
struct Registry
Public Functions
-
inline int registerTransform(std::string const &name, FunctionInterface const &func)
-
inline FunctionInterface get(std::string const &name) const
Gets a transformation function from the registry.
- Parameters:
name – The name of the transformation function.
- Throws:
std::runtime_error – if the transformation function is not in the registry.
- Returns:
The transformation function.
Public Members
-
RegistryWrapper impl
-
inline int registerTransform(std::string const &name, FunctionInterface const &func)
-
struct RegistryWrapper
- #include <registry.h>
A struct to wrap the registry for transformation functions.
Public Static Attributes
-
static std::unordered_map<std::string, FunctionInterface> registry
Registers a transformation function with the registry.
- Param name:
The name of the transformation function.
- Param func:
The transformation function.
- Return:
The status of the registration.
-
static std::unordered_map<std::string, FunctionInterface> registry
-
class TAModel : public sam_trader::transform::DataTransform
- #include <ta_model.h>
@A class that extends the DataTransform class, and is used to apply technical indicators on OHLCV data.
Public Functions
-
TAModel(BarColumns barColumns, ColumnPrefix columnPrefix, std::string const &name, std::vector<double> _options = {})
@Constructs a new TAModel instance.
- Parameters:
barColumns – A BarColumns instance containing the column names of the OHLCV data.
columnPrefix – The prefix to be used in the names of the columns generated by the technical indicator.
name – The name of the technical indicator.
_options – A vector of doubles containing the options of the technical indicator.
-
virtual std::vector<std::string> getOutputNames() const override
@Returns a vector of strings containing the names of the columns generated by the technical indicator.
- Returns:
A vector of strings containing the names of the columns generated by the technical indicator.
-
~TAModel() override = default
-
std::unordered_map<std::string, std::vector<double>> makeOutput(pd::DataFrame const &bars, std::vector<std::string> const &output_names) const
@Constructs a map of vectors of doubles containing the outputs generated by the technical indicator.
- Parameters:
bars – A DataFrame instance containing the OHLCV data.
output_names – A vector of strings containing the names of the columns generated by the technical indicator.
- Returns:
A map of vectors of doubles containing the outputs generated by the technical indicator.
-
std::tuple<std::unordered_map<std::string, std::vector<double>>, int64_t, std::shared_ptr<arrow::Array>> unzip(ColumnPrefix const &columnPrefix, pd::DataFrame const &bars) const
@Unzips a DataFrame instance into a tuple containing a map of vectors of doubles containing the outputs generated by the technical indicator, an int64_t value, and a shared_ptr to an Array instance.
- Parameters:
columnPrefix – The prefix to be used in the names of the columns generated by the technical indicator.
bars – A DataFrame instance containing the OHLCV data.
- Returns:
A tuple containing a map of vectors of doubles containing the outputs generated by the technical indicator, an int64_t value, and a shared_ptr to an Array instance.
-
virtual pd::DataFrame transform(pd::DataFrame const &bars) const override
@Applies the technical indicator on the OHLCV data contained in a DataFrame instance.
- Parameters:
bars – A DataFrame instance containing the OHLCV data.
- Returns:
A DataFrame instance containing the OHLCV data and the columns generated by the technical indicator.
Protected Attributes
-
const ti_indicator_info *info
-
std::vector<double> options
-
mutable std::vector<const double*> inputs
-
mutable std::vector<double*> outputs
-
TAModel(BarColumns barColumns, ColumnPrefix columnPrefix, std::string const &name, std::vector<double> _options = {})
-
namespace pd
-
namespace sam_trader
-
namespace transform
Typedefs
-
using DataTransformList = std::vector<DataTransform::Ptr>
A vector of DataTransform::Ptr objects.
-
using Args = std::vector<double>
A type alias for the arguments of a transformation function.
-
using FunctionInterface = std::function<std::unique_ptr<DataTransform>(BarColumns, Args const&)>
A type alias for the function interface of a transformation function.
Functions
-
std::set<std::string> extractNames()
@Extracts the names of all the Technical Indicators.
- Returns:
A set containing the names of all the Technical Indicators.
-
using DataTransformList = std::vector<DataTransform::Ptr>
-
namespace string_literals
A class for performing Fibonacci retracement on price data.
- file aggregates.cpp
- #include “aggregates.h”
- file aggregates.h
- #include “../common/timespan.h”#include “data_transform.h”#include “pandas_arrow.h”
- file data_transform.h
- #include “common/namespace.h”#include “memory”
Contains the definition of the DataTransform class and related types.
- file fib_retrace.cpp
- #include “fib_retrace.h”#include “pandas_arrow.h”#include “span”
- file fib_retrace.h
- #include “registry.h”#include “ta_model.h”
- file registry.h
- #include “any”#include “data_transform.h”#include “functional”
Contains definitions for the Transform Registry.
Defines
-
REGISTER_TRANSFORM(Class, name)
Macro to register a transformation class with the registry.
The global registry of transformation functions.
- Parameters:
Class – The class to be registered.
name – The name of the class in the registry.
-
REGISTER_TRANSFORM(Class, name)
- file ta_model.cpp
- #include “ta_model.h”#include “boost/algorithm/algorithm.hpp”#include “glog/logging.h”#include “pandas_arrow.h”
- file ta_model.h
- #include <cmath>#include <mutex>#include “arrow/array.h”#include “common/macros.h”#include “data_transform.h”#include “stdexcept”#include “string”#include “tulip/indicators.h”#include “unordered_map”#include “vector”
- dir sam/trading_sim/cpp
- dir sam
- dir sam/trading_sim/cpp/src
- dir sam/trading_sim
- dir sam/trading_sim/cpp/src/transforms