Exemplo n.º 1
0
    def calculate_ret_stats(self, returns_df, ann_factor):
        """
        calculate_ret_stats - Calculates return statistics for an asset's returns including IR, vol, ret and drawdowns

        Parameters
        ----------
        returns_df : DataFrame
            asset returns
        ann_factor : int
            annualisation factor to use on return statistics

        Returns
        -------
        DataFrame
        """
        calculations = Calculations()

        self._rets = returns_df.mean(axis=0) * ann_factor
        self._vol = returns_df.std(axis=0) * math.sqrt(ann_factor)
        self._inforatio = self._rets / self._vol
        self._kurtosis = returns_df.kurtosis(axis=0) / math.sqrt(ann_factor)

        index_df = calculations.create_mult_index(returns_df)
        # max2here = pandas.expanding_max(index_df)
        max2here = index_df.expanding(min_periods=1).max()
        dd2here = index_df / max2here - 1

        self._dd = dd2here.min()
        self._yoy_rets = index_df.resample('A').mean().pct_change()
Exemplo n.º 2
0
    def calculate_ret_stats_from_prices(self, prices_df, ann_factor):
        """Calculates return statistics for an asset's price

        Parameters
        ----------
        prices_df : DataFrame
            asset prices
        ann_factor : int
            annualisation factor to use on return statistics

        Returns
        -------
        DataFrame
        """
        calculations = Calculations()

        self.calculate_ret_stats(calculations.calculate_returns(prices_df),
                                 ann_factor)
Exemplo n.º 3
0
#
# Copyright 2020 Cuemacro
#
# See the License for the specific language governing permissions and limitations under the License.
#

import pandas as pd
import dask.dataframe as dd

from findatapy.timeseries.calculations import Calculations

from tcapy.util.loggermanager import LoggerManager
from tcapy.util.utilfunc import UtilFunc

util_func = UtilFunc()
calculations = Calculations()

file_extension = 'parquet'

csv_output = '/data/csv_output/'

ticker_mkt = ['EURUSD', 'GBPUSD', 'AUDUSD', 'NZDUSD', 'USDCAD', 'USDCHF', 'EURNOK', 'EURSEK', 'USDJPY']

ticker_combined_mkt = ['EURUSD', 'GBPUSD', 'AUDUSD', 'NZDUSD', 'USDCAD', 'USDJPY']

def create_resampled_spot_data(resample_freq='1min', data_vendor='dukascopy'):

    logger = LoggerManager.getLogger(__name__)
    csv_input_folder = '/data/csv_dump/' + data_vendor + '/'

    for ticker in ticker_mkt: