Skip to content

Latest commit

 

History

History

README.md

mcp

import "github.com/cinar/indicator/mcp"

Index

func CreateStrategy(strategyType StrategyType) (strategy.Strategy, error)

CreateStrategy creates a new strategy instance based on the specified type. It acts as a factory function, mapping a StrategyType to a concrete implementation of the strategy.Strategy interface.

This function is essential for dynamically selecting and initializing the desired trading strategy at runtime. If an unsupported strategy type is provided, it returns an error.

func GetAllStrategyTypes() []string

GetAllStrategyTypes returns a slice of all available strategy types as strings. This list includes base, trend, momentum, and volume strategies, providing a comprehensive set of options for backtesting.

func RunMCPServer() *server.MCPServer

RunMCPServer starts the MCP server for the backtest functionality. It configures the server with the necessary tools and handlers for running backtests.

OhlcvData represents the OHLCV (Open, High, Low, Close, Volume) data required for running a backtest. Each field is a slice of values that correspond to a series of time-based snapshots.

type OhlcvData struct {
    Date    []int64   `json:"date"`
    Opening []float64 `json:"opening"`
    Closing []float64 `json:"closing"`
    High    []float64 `json:"high"`
    Low     []float64 `json:"low"`
    Volume  []float64 `json:"volume"`
}

Response defines the structure of the JSON response for a backtest, containing the list of actions (buy, sell, hold) generated by the strategy.

type Response struct {
    Actions []strategy.Action `json:"actions"`
}

StrategyRequest defines the structure for a backtest request, including the strategy to be used and the OHLCV data for the backtest.

type StrategyRequest struct {
    Strategy StrategyType `json:"strategy"`
    Data     OhlcvData    `json:"data"`
}

StrategyType defines the type of trading strategy to be used in a backtest. It is represented as a string to allow for easy identification and selection.

type StrategyType string

Constants for all supported strategy types. This list includes a variety of strategies from different categories, such as trend, momentum, and volume-based approaches.

const (
    // Base strategies
    StrategyBuyAndHold StrategyType = "buy_and_hold"

    // Momentum strategies
    StrategyAwesomeOscillator StrategyType = "awesome_oscillator"
    StrategyRsi               StrategyType = "rsi"
    StrategyStochasticRsi     StrategyType = "stochastic_rsi"
    StrategyTripleRsi         StrategyType = "triple_rsi"

    // Volume strategies
    StrategyChaikinMoneyFlow     StrategyType = "chaikin_money_flow"
    StrategyEaseOfMovement       StrategyType = "ease_of_movement"
    StrategyForceIndex           StrategyType = "force_index"
    StrategyMoneyFlowIndex       StrategyType = "money_flow_index"
    StrategyNegativeVolumeIndex  StrategyType = "negative_volume_index"
    StrategyWeightedAveragePrice StrategyType = "weighted_average_price"

    // Trend strategies
    StrategyMACD              StrategyType = "macd"
    StrategyAlligator         StrategyType = "alligator"
    StrategyAroon             StrategyType = "aroon"
    StrategyApo               StrategyType = "apo"
    StrategyBop               StrategyType = "bop"
    StrategyCci               StrategyType = "cci"
    StrategyDema              StrategyType = "dema"
    StrategyGoldenCross       StrategyType = "golden_cross"
    StrategyKama              StrategyType = "kama"
    StrategyKdj               StrategyType = "kdj"
    StrategyQstick            StrategyType = "qstick"
    StrategySmma              StrategyType = "smma"
    StrategyTrima             StrategyType = "trima"
    StrategyTripleMaCrossover StrategyType = "triple_ma_crossover"
    StrategyTsi               StrategyType = "tsi"
    StrategyVwma              StrategyType = "vwma"
    StrategyWeightedClose     StrategyType = "weighted_close"
)

Generated by gomarkdoc