Vector#

For more information, please visit vector.untrade.io.

Pre-installed Packages Available#

Data Processing:

  • numpy (1.26.4)

  • pandas

  • pyarrow

  • scipy

  • statsmodels

Technical Analysis:

  • talib

  • pandas_ta

Machine Learning:

  • scikit-learn

  • tensorflow

  • xgboost

  • lightgbm

Financial:

  • yfinance

  • ccxt

  • alpha_vantage

  • quantstats

  • zipline-reloaded

Utilities:

  • httpx

  • requests

  • websockets

  • joblib

  • tqdm

Development Notes#

  • Additional package requirements should be listed in requirements.txt.

  • Helper files can be created but execution starts from main.py.

  • Trade entries/exits must be marked in trade_type column as LONG, SHORT, CLOSE, REVERSE_LONG, REVERSE_SHORT, or HOLD.

  • Check provided examples for implementation details.

Remember:

There should be no repeated trade_type entries (like LONG, LONG, LONG or SHORT, SHORT, SHORT).

  • A LONG trade_type (LONG) can only be followed by a SHORT trade_type (SHORT) or a reverse SHORT trade_type (REVERSE_SHORT).

  • A SHORT trade_type (SHORT) can only be followed by a LONG trade_type (LONG) or a reverse LONG trade_type (REVERSE_LONG).

  • Hold trade_type (HOLD) can appear between other trade types.

Code Implementation#

import pandas as pd
from enum import Enum

class TradeType(Enum):
    LONG = "LONG"
    SHORT = "SHORT"
    REVERSE_LONG = "REVERSE_LONG"
    REVERSE_SHORT = "REVERSE_SHORT"
    CLOSE = "CLOSE"
    HOLD = "HOLD"

class Strategy:
    def run(self, data: pd.DataFrame) -> pd.DataFrame:
        """
        Execute the strategy on the provided data.

        Args:
            data (pd.DataFrame): Input DataFrame with OHLCV data.

                Expected columns and their data types:

                - datetime: datetime64[ns]
                - open: float64
                - high: float64
                - low: float64
                - close: float64
                - volume: float64

        Returns:
            pd.DataFrame: DataFrame with added indicators and trade types.

                **Required columns:**

                - ``trade_type``: str (``LONG``, ``SHORT``, ``CLOSE``, ``REVERSE_LONG``, ``REVERSE_SHORT``, ``HOLD``)

                **Optional columns:**

                These columns are optional and can be added if needed. They are prices and not trade types.

                - ``TP``: float64 (Take Profit)
                - ``SL``: float64 (Stop Loss)
                - ``TSL``: float64 (Trailing Stop Loss)
        """
        # Implement your strategy logic here
        return data