コード例 #1
0
ファイル: plot.py プロジェクト: idogilboa/CryptoProject
import numpy as np
import datetime
from pgportfolio.tools.indicator import max_drawdown, sharpe, positive_count, negative_count, moving_accumulate
from pgportfolio.tools.configprocess import parse_time, check_input_same
from pgportfolio.tools.shortcut import execute_backtest

# the dictionary of name of indicators mapping to the function of related indicators
# input is portfolio changes
INDICATORS = {
    "portfolio value": np.prod,
    "sharpe ratio": sharpe,
    "max drawdown": max_drawdown,
    "positive periods": positive_count,
    "negative periods": negative_count,
    "postive day": lambda pcs: positive_count(moving_accumulate(pcs, 48)),
    "negative day": lambda pcs: negative_count(moving_accumulate(pcs, 48)),
    "postive week": lambda pcs: positive_count(moving_accumulate(pcs, 336)),
    "negative week": lambda pcs: negative_count(moving_accumulate(pcs, 336)),
    "average": np.mean
}

NAMES = {
    "best": "Best Stock (Benchmark)",
    "crp": "UCRP (Benchmark)",
    "ubah": "UBAH (Benchmark)",
    "anticor": "ANTICOR",
    "olmar": "OLMAR",
    "pamr": "PAMR",
    "cwmr": "CWMR",
    "rmr": "RMR",
    "ons": "ONS",
コード例 #2
0
ファイル: plot.py プロジェクト: alextavgen/PGPortfolio
import json
import numpy as np
import datetime
from pgportfolio.tools.indicator import max_drawdown, sharpe, positive_count, negative_count, moving_accumulate
from pgportfolio.tools.configprocess import parse_time, check_input_same
from pgportfolio.tools.shortcut import execute_backtest

# the dictionary of name of indicators mapping to the function of related indicators
# input is portfolio changes
INDICATORS = {"portfolio value": np.prod,
              "sharpe ratio": sharpe,
              "max drawdown": max_drawdown,
              "positive periods": positive_count,
              "negative periods": negative_count,
              "postive day": lambda pcs: positive_count(moving_accumulate(pcs, 48)),
              "negative day": lambda pcs: negative_count(moving_accumulate(pcs, 48)),
              "postive week": lambda pcs: positive_count(moving_accumulate(pcs, 336)),
              "negative week": lambda pcs: negative_count(moving_accumulate(pcs, 336)),
              "average": np.mean}

NAMES = {"best": "Best Stock (Benchmark)",
         "crp": "UCRP (Benchmark)",
         "ubah": "UBAH (Benchmark)",
         "anticor": "ANTICOR",
         "olmar": "OLMAR",
         "pamr": "PAMR",
         "cwmr": "CWMR",
         "rmr": "RMR",
         "ons": "ONS",
         "up": "UP",
         "eg": "EG",