Beispiel #1
0
    def __init__(self,
                 targets=None,
                 side=None,
                 sl_threshold=None,
                 is_entry=True,
                 smart=False,
                 **kvargs):

        if 'threshold' in kvargs:
            sl_threshold = kvargs.get('threshold')

        self.sl_threshold = Value(
            sl_threshold
        ) if sl_threshold else EntryExitSettings.DEFAULT_THRESHOLD

        self.side = Side(side.lower()) if side else None
        self.smart = smart
        self.is_entry = is_entry

        self.targets: [Target] = []

        # As an alternative to specifiying array of targets
        if 'target' in kvargs:
            self.targets.append(
                self._create_target(kvargs.get('target'), is_entry))

        if targets:
            self.set_targets(
                [self._create_target(t, is_entry) for t in targets])
Beispiel #2
0
    def __init__(self, symbol, side, asset, status=None, *args, **kvargs):
        self.side = Side(side.lower())
        self.symbol = symbol.upper()
        self.asset = asset.upper()

        self.entry: EntryExitSettings = None
        self.exit: EntryExitSettings = None

        self._init_entry_exit(True, kvargs.get('entry'), self.side)
        self._init_entry_exit(False, kvargs.get('exit'), self.side)

        sl_settings = kvargs.get('stoploss', kvargs.get('sl_settings'))

        self.sl_settings: StopLossSettings = StopLossSettings(
            **sl_settings) if sl_settings else None

        if status:
            self.status = OrderStatus(status.lower())
        else:
            self.status = OrderStatus.ACTIVE if not kvargs.get(
                'entry') else OrderStatus.NEW

        self.cap = float(kvargs.get('cap')) if kvargs.get('cap') else None

        self.id = kvargs.get('id', None)

        if not self.id:
            self.id = str(uuid.uuid4())