Package pinkfish

Expand source code
from .fetch import (
    fetch_timeseries,
    select_tradeperiod,
    finalize_timeseries,
    remove_cache_symbols,
    update_cache_symbols,
    get_symbol_metadata
)

from .trade import (
    Direction,
    Margin,
    TradeLog,
    TradeState,
    DailyBal
)

from .pfstatistics import (
    ALPHA_BEGIN,
    SP500_BEGIN,
    get_trading_days,
    currency_metrics,
    stats,
    currency,
    summary,
    optimizer_summary
)

from .plot import (
    plot_equity_curve,
    plot_equity_curves,
    plot_trades,
    plot_bar_graph,
    optimizer_plot_bar_graph
)

from .benchmark import (
    Benchmark
)

from .portfolio import (
    Portfolio,
    technical_indicator
)

from .indicator import (
    SMA,
    EMA,
    CROSSOVER,
    MOMENTUM,
    VOLATILITY,
    ANNUALIZED_RETURNS,
    ANNUALIZED_STANDARD_DEVIATION,
    ANNUALIZED_SHARPE_RATIO
)

from .pfcalendar import (
    calendar
)

from .stock_market_calendar import (
    stock_market_calendar
)

from .analysis import (
    monthly_returns_map,
    holding_period_map,
    prettier_graphs,
    volatility_graphs,
    kelly_criterion
)

from .utility import (
    ROOT,
    import_strategy,
    print_full,
    read_config,
    is_last_row,
    sort_dict,
    set_dict_values,
    find_nan_rows
)

DEBUG = False
"""
bool : True to enable DBG() output.
"""
def DBG(s):
    """
    Debug print.  Enable by setting pf.DEBUG=True.
    """
    if DEBUG:
        print(s)
    else:
        pass

Sub-modules

pinkfish.analysis

Analysis of results …

pinkfish.benchmark

Benchmark for comparision to a strategy.

pinkfish.fetch

Fetch time series data.

pinkfish.indicator

Custom indicators …

pinkfish.itable

Keep track of styles for cells/headers in PrettyTable …

pinkfish.pfcalendar

Adds calendar columns to a timeseries …

pinkfish.pfstatistics

Calculate trading statistics …

pinkfish.plot

Plotting functions.

pinkfish.portfolio

Portfolio backtesting.

pinkfish.stock_market_calendar

Past and Future dates when the stock market is open from 1928 to 2024.

pinkfish.trade

Trading agent.

pinkfish.utility

Utility functions.

Global variables

var DEBUG

bool : True to enable DBG() output.

Functions

def DBG(s)

Debug print. Enable by setting pf.DEBUG=True.

Expand source code
def DBG(s):
    """
    Debug print.  Enable by setting pf.DEBUG=True.
    """
    if DEBUG:
        print(s)
    else:
        pass