Ejemplo n.º 1
0
    def conf_schema(self):
        json = {
            "title": "Compute the R-squared score for regression problems",
            "type": "object",
            "properties": {
                "columns": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": """Two columns used to compute the
                    R-squared score""",
                    "minItems": 2,
                    "maxItems": 2
                }
            },
            "required": ["columns"]
        }

        input_meta = self.get_input_meta()
        if self.INPUT_PORT_NAME in input_meta:
            col_from_inport = input_meta[self.INPUT_PORT_NAME]
            enums = [col for col in col_from_inport.keys()]
            json['properties']['columns']['items']['enum'] = enums
            ui = {}
            return ConfSchema(json=json, ui=ui)
        else:
            ui = {"column": {"ui:widget": "text"}}
            return ConfSchema(json=json, ui=ui)
Ejemplo n.º 2
0
 def conf_schema(self):
     mode_enum = ['full', 'valid', 'same']
     method_enum = ['direct', 'fft', 'auto']
     json = {
         'title': 'Cusignal Correlation Node',
         'type': 'object',
         'description': _CORR_DESC,
         'properties': {
             'mode':  {
                 'type': 'string',
                 'description': _CORR_MODE_DESC,
                 'enum': mode_enum,
                 'default': 'full'
             },
             'method': {
                 'type': 'string',
                 'description': _CORR_METHOD_DESC,
                 'enum': method_enum,
                 'default': 'auto'
             },
             'scale': {
                 'type': 'number',
                 'description': 'Scale output array i.e. out / scale',
                 'default': 1
             },
             'use_cpu': {
                 'type': 'boolean',
                 'description': 'Use CPU for computation via '
                     'scipy::signal.correlate. Default is False and runs '  # noqa: E131,E501
                     'on GPU via cusignal.',
                 'default': False
             },
         },
     }
     return ConfSchema(json=json)
Ejemplo n.º 3
0
 def conf_schema(self):
     json = {
         'title': 'Custom Filter Node.',
         'type': 'object',
         'description': 'Custom filter logic. CAUTION: Only run trusted '
         'code.',  # noqa: E131,E501
         'properties': {
             'pycode': {
                 'type':
                 'string',
                 'title':
                 'Signal Code - pycode',
                 'description':
                 'Enter python code to filter a signal. '
                 'The code must have a function with the following '  # noqa: E131,E501
                 'name and signature: def custom_filter(signal, conf). '
                 'The ``signal`` is a cp or np array. The ``conf`` '
                 'is the node\'s configuration dictionary. Besides '
                 '"pycode" custom conf fields are not not exposed via '
                 'UI. If anything needs to be set do it '
                 'programmatically via TaskSpecSchema. The '
                 '`custom_filter` function must return a processed '
                 'signal of same type as input signal.'
             },
         },
         # 'required': ['pycode'],
     }
     ui = {'pycode': {'ui:widget': 'textarea'}}
     return ConfSchema(json=json, ui=ui)
Ejemplo n.º 4
0
    def conf_schema(self):
        json = {
            "title": "Compute the Maximum Drawdown Matrix Dataframe",
            "type": "object",
            "properties": {
                "window": {
                    'type':
                    "integer",
                    "title":
                    "Window size",
                    "description":
                    """the number of months used to compute the
                    distance and vairance"""
                },
                "negative": {
                    'type': "boolean",
                    "title": "Negative return",
                    "description": """Compute
                     max drawdown on negative return""",
                    "default": False
                }
            },
            "required": ["window"],
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 5
0
    def conf_schema(self):
        json = {
            "title": "Compute the Leverage to match the target volatility",
            "type": "object",
            "properties": {
                "target_vol": {
                    'type': "number",
                    "title": "Target Volativity",
                    "description": """The target volatility to match""",
                    "default": 0.05
                },
                "long_window": {
                    'type': "integer",
                    "title": "Long window size",
                    "description":
                    """the large number of days in the past to compute
                     volatility""",
                    "default": 59
                },
                "short_window": {
                    'type': "integer",
                    "title": "Short window size",
                    "description":
                    """the small number of days in the past to compute
                     volatility""",
                    "default": 19
                }
            },
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 6
0
    def conf_schema(self):
        json = {
            "title": "VerifyNode configure",
            "type": "object",
            "properties": {
                "df1_col": {
                    "type": "string",
                    "description": "dataframe1 column name"
                },
                "df2_col": {
                    "type": "string",
                    "description": "dataframe2 column name"
                }
            },
            "required": ["df1_col", "df2_col"],
        }

        ui = {
            "df1_col": {
                "ui:widget": "text"
            },
            "df2_col": {
                "ui:widget": "text"
            }
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 7
0
 def conf_schema(self):
     mode_enum = ['full', 'valid', 'same']
     json = {
         'title': 'Cusignal Convolution Node',
         'type': 'object',
         'description': _FFTCONV_DESC,
         'properties': {
             'mode': {
                 'type': 'string',
                 'description': _FFTCONV_MODE_DESC,
                 'enum': mode_enum,
                 'default': 'full'
             },
             'axes': {
                 'type': 'array',
                 'items': {
                     'type': 'integer'
                 },
                 'description': _FFTCONV_AXES_DESC,
             },
             'use_cpu': {
                 'type': 'boolean',
                 'description': 'Use CPU for computation via '
                     'scipy::signal.fftconvolve. Default is False and '  # noqa: E131,E501
                     'runs on GPU via cusignal.',
                 'default': False
             },
         },
     }
     return ConfSchema(json=json)
Ejemplo n.º 8
0
    def conf_schema(self):
        json = {
            "title": "PointNode configure",
            "type": "object",
            "properties": {
                "npts":  {
                    "type": "number",
                    "description": "number of data points",
                    "minimum": 10
                },
                "npartitions":  {
                    "type": "number",
                    "description": "num of partitions in the Dask dataframe",
                    "minimum": 1
                }

            },
            "required": ["npts", "npartitions"],
        }

        ui = {
            "npts": {"ui:widget": "updown"},
            "npartitions": {"ui:widget": "updown"}
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 9
0
    def conf_schema(self):
        json = {
            "title": "Aggregate feature across time, get mean and std",
            "type": "object",
            "properties": {},
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 10
0
    def conf_schema(self):
        json = {
            "title": "Hierachical Clustering Node",
            "type": "object",
            "properties": {},
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 11
0
    def conf_schema(self):
        json = {
            "title": "Compute the Sharpe Ratio",
            "type": "object",
            "properties": {},
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 12
0
    def conf_schema(self):
        json = {
            "title": "Persist the dask dataframe",
            "type": "object",
            "properties": {},
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 13
0
    def conf_schema(self):
        json = {
            "title": "Compute the log return dataframe",
            "type": "object",
            "properties": {},
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 14
0
 def conf_schema(self):
     json = {
         "title": "Backtest configure",
         "type": "object",
         "description": """compute the `strategy_returns` by assuming invest
          `signal` amount of dollars for each of the time step.""",
     }
     ui = {
     }
     return ConfSchema(json=json, ui=ui)
Ejemplo n.º 15
0
    def conf_schema(self):
        windows_enum = list(_WINS_CONFIG.keys())

        use_cpu_conf = {
            'use_cpu': {
                'type':
                'boolean',
                'description':
                'use_cpu - Use CPU for computation via '
                'scipy::signal.windows. Default is False and runs on '
                'GPU via cusignal.',
                'default':
                False
            }
        }

        # windows configuration
        win_anyof = []
        for wtype in windows_enum:
            wjson_conf = _DEFAULT_WIN_JSON_CONF.copy()
            wjson_conf_update = _WINS_CONFIG[wtype].get('json_conf', {})
            wjson_conf.update(wjson_conf_update)

            wdesc = '{}\n{}'.format(
                _WINS_CONFIG[wtype]['description'],
                _WINS_CONFIG[wtype].get('desc-return', _DEFAULT_WIN_RETDESC))

            wjson_conf_properties = {
                'window_type': {
                    'type': 'string',
                    'default': wtype,
                    'readOnly': True
                },
                **wjson_conf,
                **use_cpu_conf
            }

            wjson_schema = {
                'title': wtype,
                'description': wdesc,
                'properties': wjson_conf_properties
            }

            win_anyof.append(wjson_schema)

        json = {
            'title': 'Cusignal Correlation Node',
            'type': 'object',
            'default': 'general_cosine',
            'description': 'Filter Window. Parameters updated below based on '
            'selected window.',
            'anyOf': win_anyof,
            'required': ['window_type'],
        }
        return ConfSchema(json=json)
Ejemplo n.º 16
0
    def conf_schema(self):
        json = {
            "title": "Construct the portfolio",
            "type": "object",
            "properties": {
            },
        }

        ui = {
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 17
0
    def conf_schema(self):
        json = {
            "title": "Calculate Sharpe diff",
            "type": "object",
            "properties": {
            },
        }

        ui = {
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 18
0
    def conf_schema(self):
        json = {
            "title": "Pass along the raw dataframe dataframe",
            "type": "object",
            "properties": {
            },
        }

        ui = {
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 19
0
 def conf_schema(self):
     json = {
         "title": "Maximum Value Node configure",
         "type": "object",
         "description": "Compute the maximum value of the key column",
         "properties": {
             "column": {
                 "type": "string",
                 "description": "column to calculate the maximum value"
             }
         },
         "required": ["column"],
     }
     input_meta = self.get_input_meta()
     if self.INPUT_PORT_NAME in input_meta:
         col_from_inport = input_meta[self.INPUT_PORT_NAME]
         enums = [col for col in col_from_inport.keys()]
         json['properties']['column']['enum'] = enums
         ui = {}
         return ConfSchema(json=json, ui=ui)
     else:
         ui = {"column": {"ui:widget": "text"}}
         return ConfSchema(json=json, ui=ui)
Ejemplo n.º 20
0
    def conf_schema(self):
        json = {
            "title": "Calculate the std and mean across assets as features",
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "title": "Feature Name"
                }
            },
        }

        ui = {
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 21
0
    def conf_schema(self):
        json = {
            "title": "Compute the Transaction Cost",
            "type": "object",
            "properties": {
                "cost": {
                    'type': "number",
                    "title": "transaction cost",
                    "default": 2e-4
                },
            },
        }

        ui = {
        }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 22
0
    def conf_schema(self):
        conf_para = get_conf_parameters(self.instanceClass)
        class_doc = self.instanceClass.__doc__
        desc = "" if class_doc is None else class_doc
        init_doc = self.instanceClass.__init__.__doc__
        desc += "" if init_doc is None else init_doc
        json = {
            "title": "NeMo "+self.instanceClass.__name__+" Node",
            "type": "object",
            "description": desc,
            "properties": {

            },
        }
        ui = {
        }
        for f in self.file_fields:
            if f in conf_para:
                ui[f] = {"ui:widget": "FileSelector"}
        for p in conf_para.keys():
            stype = conf_para[p][0]
            if p in self.fix_type:
                stype = self.fix_type[p]
            json['properties'][p] = {
                "type": stype,
                "default": conf_para[p][1]
            }
        if issubclass(self.instanceClass, TrainableNM):
            if share_weight in conf_para:
                print('warning, share_weight parameter name collision')
            json['properties'][share_weight] = {
                "type": 'string',
                "description": """Weight Sharing between Modules: Reuse,
                re-use neural modules between training, evaluation and
                inference graphs; Copy: copy weights betwen modules. subsequent
                update of weights in one module will not affect weights in the
                other module. This means that the weights will get DIFFERENT
                gradients on the update step. Tying: the default one, tie
                weights between two or more modules. Tied weights are identical
                across all modules. Gradients to the weights will be the
                SAME.""",
                "enum": ['Reuse', 'Copy', 'Tying'],
                "default": 'Tying'
            }
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 23
0
 def conf_schema(self):
     mode_enum = ['full', 'valid', 'same']
     method_enum = ['direct', 'fft', 'auto']
     json = {
         'title': 'Cusignal Convolution Node',
         'type': 'object',
         'description': _CONV_DESC,
         'properties': {
             'mode': {
                 'type': 'string',
                 'description': _CONV_MODE_DESC,
                 'enum': mode_enum,
                 'default': 'full'
             },
             'method': {
                 'type': 'string',
                 'description': _CONV_METHOD_DESC,
                 'enum': method_enum,
                 'default': 'auto'
             },
             'normalize': {
                 'type':
                 'boolean',
                 'description':
                 'Scale convolutioni by in2 (typically a '
                 'window) i.e. convolve(in1, in2) / sum(in2). '
                 'Default False.',
                 'default':
                 False
             },
             'use_cpu': {
                 'type':
                 'boolean',
                 'description':
                 'Use CPU for computation via '
                 'scipy::signal.convolve. Default is False and runs on '
                 'GPU via cusignal.',
                 'default':
                 False
             },
         },
     }
     return ConfSchema(json=json)
Ejemplo n.º 24
0
    def conf_schema(self):
        json = {
            "title": "Load stock data",
            "type": "object",
            "properties": {
                "csvfile": {
                    "type": "string",
                    "description": "csv tick data"
                },
                "17assets": {
                    "type": "boolean",
                    "description": "17 assets dataset"
                }
            },
            "required": ["csvfile"],
        }

        ui = {"csvfile": {"ui:widget": "CsvFileSelector"}}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 25
0
    def conf_schema(self):
        json = {
            "title": "Compute the Distance Matrix and Cov df",
            "type": "object",
            "properties": {
                "window": {
                    'type':
                    "integer",
                    "title":
                    "Window size",
                    "description":
                    """the number of months used to compute the
                    distance and vairance"""
                }
            },
            "required": ["window"],
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 26
0
 def conf_schema(self):
     json = {
         'title':
         'IQ Wavefile Node',
         'type':
         'object',
         'description':
         'Load IQ data from a *.wav file. Preferably '
         'install "pysoundfile" to do this. Otherwise uses "wave", '  # noqa: E131,E501
         'but it has not been well tested for variety of ways data '
         'has been stored in *.wav files.',
         'properties': {
             'wavefile': {
                 'type':
                 'string',
                 'description':
                 'IQ Wavefile *.wav. Typically '
                 'recorded snippets of SDR IQ.'  # noqa: E131,E501
             },
             'duration': {
                 'type':
                 'number',
                 'description':
                 'Number of seconds to load. Number of '
                 'frames loaded is dependent on framerate. Default '  # noqa: E131,E501
                 '1 second. Limited to max frames in file. Will '
                 'fail if exceeds GPU memory size.',
                 'default':
                 1.0
             },
             'use_cpu': {
                 'type': 'boolean',
                 'description': 'use_cpu - Returns numpy array if True. '
                 'Default is False and returns Cupy array.',  # noqa: E131,E501
                 'default': False
             },
         },
     }
     ui = {'wavefile': {'ui:widget': 'FileSelector'}}
     return ConfSchema(json=json, ui=ui)
Ejemplo n.º 27
0
 def conf_schema(self):
     mode_enum = ['full', 'valid', 'same']
     boundary_enum = ['fill', 'wrap', 'symm']
     json = {
         'title': 'Cusignal Convolution2D Node',
         'type': 'object',
         'description': _CORR2_DESC,
         'properties': {
             'mode': {
                 'type': 'string',
                 'description': _CORR2_MODE_DESC,
                 'enum': mode_enum,
                 'default': 'full'
             },
             'boundary': {
                 'type': 'string',
                 'description': _CORR2_BOUNDARY_DESC,
                 'enum': boundary_enum,
                 'default': 'fill'
             },
             'fillvalue': {
                 'type': 'number',
                 'description': _CORR2_FILLVAL_DESC,
                 'default': 0
             },
             'use_cpu': {
                 'type':
                 'boolean',
                 'description':
                 'Use CPU for computation via '
                 'scipy::signal.correlate2d. Default is False and runs on '
                 'GPU via cusignal.',
                 'default':
                 False
             },
         },
     }
     return ConfSchema(json=json)
Ejemplo n.º 28
0
 def conf_schema(self):
     json = {
         'title': 'Custom Signal Generator Node.',
         'type': 'object',
         'description': 'Inject signals into greenflow taskgraphs. Use '
         'CAUTION. Only run trusted code.',
         'properties': {
             'pycode': {
                 'type':
                 'string',
                 'title':
                 'Signal Code',
                 'description':
                 'Enter python code to generate signal. '
                 'The code must have a dictionary ``myout`` variable '
                 'with keys: out1 and out2. The out2 port is optional. '
                 'The ``myout`` must be the last line. Keep it simple '
                 'please.'
             },
         },
         # 'required': ['pycode'],
     }
     ui = {'pycode': {'ui:widget': 'textarea'}}
     return ConfSchema(json=json, ui=ui)
Ejemplo n.º 29
0
    def conf_schema(self):
        json = {
            "title": "Generate bootstrap dataframe",
            "type": "object",
            "properties": {
                "samples": {
                    "type": "integer",
                    "description": "Number of samples to bootstrap"
                },
                "partitions": {
                    "type": "integer",
                    "description": "Number of partitions for Dask Dataframe"
                },
                "offset": {
                    "type": "integer",
                    "description": "Sample id offset",
                    "default": 0
                },
            },
            "required": ["samples"],
        }

        ui = {}
        return ConfSchema(json=json, ui=ui)
Ejemplo n.º 30
0
 def conf_schema(self):
     padtype_enum = [
         'constant', 'line', 'mean', 'median', 'maximum', 'minimum'
     ]
     json = {
         'title': 'Polyphase Filter Resample Node',
         'type': 'object',
         'description': _RESAMPLEPOLY_DESC,
         'properties': {
             'new_samplerate': {
                 'type':
                 'number',
                 'description':
                 'Desired sample rate. Specify this or the '
                 'up/down parameters. This is used when `samplerate` '  # noqa: E131,E501
                 'is passed in via ports, otherwise up/down is used. '
                 'If both are set then this takes precedence over '
                 'up/down.'
             },
             'up': {
                 'type': 'integer',
                 'description': 'The upsampling factor.'
             },
             'down': {
                 'type': 'integer',
                 'description': 'The downsampling factor.'
             },
             'axis': {
                 'type': 'integer',
                 'description': 'The axis of `x` that is resampled. '
                 'Default is 0.',  # noqa: E131,E501
                 'default': 0,
                 'minimum': 0,
             },
             'window': {
                 'type':
                 'string',
                 'description':
                 'Desired window to use to design the '
                 'low-pass filter, or the FIR filter coefficients to '  # noqa: E131,E501
                 'employ. Window can be specified as a string, a '
                 'tuple, or a list. If a string choose one of '
                 'available windows. If a tuple refer to '
                 '`cusignal.windows.get_window`. The tuple format '
                 'specifies the first argument as the string name of '
                 'the window, and the next arguments the needed '
                 'parameters. If `window` is a list it is assumed to '
                 'be the FIR filter coefficients. Note that the FIR '
                 'filter is applied after the upsampling step, so it '
                 'should be designed to operate on a signal at a '
                 'sampling frequency higher than the original by a '
                 'factor of `up//gcd(up, down)`. If the port window '
                 'is connected it takes precedence. Default '
                 '("kaiser", 5.0)',
                 'default':
                 '("kaiser", 5.0)'
             },
             'gpupath': {
                 'type':
                 'boolean',
                 'description':
                 'gpupath - Optional path for filter design.'
                 ' gpupath == False may be desirable if filter sizes '  # noqa: E131,E501
                 'are small.',
                 'default':
                 True
             },
             'use_cpu': {
                 'type':
                 'boolean',
                 'description':
                 'use_cpu - Use CPU for computation via '
                 'scipy::signal.resample_poly. Default is False and '  # noqa: E131,E501
                 'runs on GPU via cusignal.',
                 'default':
                 False
             },
             'padtype': {
                 'type':
                 'string',
                 'description':
                 'Only used when `use_cpu` is set. Scipy '
                 'padtype parameter of `resample_poly`. This is not '  # noqa: E131,E501
                 'currently exposed in cusignal.',
                 'enum':
                 padtype_enum,
                 'default':
                 'constant'
             },
             'cval': {
                 'type':
                 'number',
                 'description':
                 'Only used when `use_cpu` is set. Value '
                 'to use if `padtype="constant"`. Default is zero.'  # noqa: E131,E501
             }
         }
     }
     return ConfSchema(json=json)