w1ld3r / crypto-signal

The #1 Automated Technical Analysis (TA) & Algo. Trading tool for Coinbase, Bittrex, Binance, and more! (Track over 500+ coins)
http://cryptosignal.dev
MIT License
76 stars 37 forks source link

Conditionals notifiers #45

Closed ppovedam closed 2 years ago

ppovedam commented 2 years ago

Is your feature request related to a problem? Please describe. Hello!

I am trying to enter some conditionals in config.yml. However, although the condition is met, I am not getting any notification. Is there any special syntax for conditionals? My config.yml is so simple and is just a test with one indicator (obviously, I can obtain the same result with only the indicators, but is a simple way to test conditionals). I would be very grateful if you could give me some indications. Please, find enclosed my config.yml:

settings:
    log_level: INFO
    update_interval: 60
    start_worker_interval: 2
    market_data_chunk_size: 1
    timezone: Europe/Paris
    enable_charts: true
    market_pairs:
        - ADA/USDT     

exchanges:
    binance:
        required:
            enabled: true

indicators:
    rsi:
        - enabled: false
    stoch_rsi:
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - stoch_rsi
          hot: 20
          cold: 80
          candle_period: 5m
          period_count: 14
    momentum:
        - enabled: false
     macd:
        - enabled: false         
    obv:
        - enabled: false
    mfi:
        - enabled: false
    ichimoku:
        - enabled: false    
    bollinger:
    - enabled: false
    aroon_oscillator:
    - enabled: false

informants:
    lrsi:
        - enabled: false
    sma:
        - enabled: false       
    ema:
        - enabled: false
    vwap:
        - enabled: false
    bollinger_bands:
        - enabled: false
    ohlcv:
        - enabled: false

conditionals:
  - label: "Signal to buy"
    hot:
      - stoch_rsi: 0

  - label: "Shell"
    cold:
      - stoch_rsi: 0

notifiers:
    telegram:
        required:
            token: xxxxxxx
            chat_id: -xxxxxxx
        optional:
            parse_mode: html
            template: "[{{market}}] {{indicators}} {{status}} {{values}} {{ '\n' -}}" 

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

shiftcryptomyid commented 2 years ago

cek this https://github.com/w1ld3r/crypto-signal/issues/41

shiftcryptomyid commented 2 years ago

can you cek this one

https://github.com/w1ld3r/crypto-signal/issues/41#issuecomment-898749339

ppovedam commented 2 years ago

can you cek this one

#41 (comment)

Thanks, shiftcryptomyid, but I've tried with config.yml proposed in issues 8, 23 and 41 that are supposed to work but when I use conditionals crypto-singal still doesn't send notifications. I use w1ld3r branch

shiftcryptomyid commented 2 years ago

try this config.. i use it to try conditional and its work.. use webhook notifier

settings:
    log_level: INFO
    update_interval: 900
    start_worker_interval: 15
    market_data_chunk_size: 1

exchanges:
    binance:
        required:
            enabled: true
        all_pairs:
            - USDT
            #- BTC
        future: true         
        exclude:
            - USDC
            - PAX
            - BUSD
            - TUSD
            - EUR
            - SUSD
            - GBP
            - UTK

indicators:
    bbp:
        - enabled: true
          candle_period: 3m
          alert_enabled: true
          alert_frequency: always
          period_count: 20
          hot: 0
          cold: 0
          std_dev: 2
          signal:
            - bbp
            - mfi
          hot_label: 'Lower Band'
          cold_label: 'Upper Band'
          indicator_label: 'Bollinger Crossing'
          mute_cold: false
    ma_crossover:
        - enabled: false
    stoch_rsi:
        - enabled: false
    adx:
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 3m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 1m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 5m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 15m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 30m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 1h
          period_count: 14
    rsi:
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 3m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 1m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 5m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 15m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 30m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 1h
          period_count: 14
          mute_cold: false
    stochrsi_cross:
        - enabled: false
    momentum:
        - enabled: false
    macd:
        - enabled: false
    ma_ribbon:
        - enabled: false 
    iiv:
        - enabled: false
    obv:
        - enabled: false
    mfi:
        - enabled: false
    ichimoku:
        - enabled: false

informants:
    lrsi:
        - enabled: false
    sma:
        - enabled: false 
    ema:
        - enabled: false

    vwap:
        - enabled: false
    bollinger_bands:
        - enabled: false
    ohlcv:
        - enabled: true
          signal:
            - high
            - low
            - close
          candle_period: 1m
          period_count: 14

conditionals:
-label: "Signal to buy"
    hot:
      - bbp: 0
      - rsi: 0
      - rsi: 1
      - rsi: 2
      - rsi: 3
      - rsi: 4
      - rsi: 5
      - adx: 0
      - adx: 1
      - adx: 2
      - adx: 3
      - adx: 4
      - adx: 5

-label: "Signal to sell"
    cold:
      - bbp: 0
      - rsi: 0
      - rsi: 0
      - rsi: 1
      - rsi: 2
      - rsi: 3
      - rsi: 4
      - rsi: 5
      - adx: 0
      - adx: 1
      - adx: 2
      - adx: 3
      - adx: 4
      - adx: 5

notifiers:
    webhook:
        required:
            url: https://shiftcrypto.my.id/newtest/newfuture1.php
        optional:
            username: 
            password: 

its take some time and i got this data

[{"values": [{"rsi": "54.91"}, {"rsi": "54.91"}, {"bbp": "0.69", "mfi": "54.07"}, {"adx": "13.65", "pdi": "594.27", "ndi": "552.72"}, {"rsi": "50.64"}, {"adx": "18.71", "pdi": "447.95", "ndi": "437.19"}, {"rsi": "58.68"}, {"adx": "22.75", "pdi": "346.47", "ndi": "269.12"}, {"rsi": "61.18"}, {"adx": "20.64", "pdi": "1125.73", "ndi": "869.02"}, {"rsi": "57.98"}, {"adx": "15.80", "pdi": "1265.89", "ndi": "832.03"}, {"rsi": "55.94"}, {"adx": "12.27", "pdi": "2053.54", "ndi": "1663.40"}], "indicator": ["rsi", "rsi", "bbp", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx"], "price_value": {"3m": {}, "1m": {"high": 0.10292, "low": 0.10277, "close": 0.10288}, "5m": {}, "15m": {}, "30m": {}, "1h": {}}, "exchange": "binance", "market": "RVN/USDT", "base_currency": "RVN", "quote_currency": "USDT", "prices": "", "decimal_format": "%.5f", "status": "Signal to sell"}]

ppovedam commented 2 years ago

try this config.. i use it to try conditional and its work.. use webhook notifier

settings: log_level: INFO update_interval: 900 start_worker_interval: 15 market_data_chunk_size: 1

exchanges:

binance:
    required:
        enabled: true
    all_pairs:
        - USDT
        #- BTC
    future: true         
    exclude:
        - USDC
        - PAX
        - BUSD
        - TUSD
        - EUR
        - SUSD
        - GBP
        - UTK

indicators:

bbp:
    - enabled: true
      candle_period: 3m
      alert_enabled: true
      alert_frequency: always
      period_count: 20
      hot: 0
      cold: 0
      std_dev: 2
      signal:
        - bbp
        - mfi
      hot_label: 'Lower Band'
      cold_label: 'Upper Band'
      indicator_label: 'Bollinger Crossing'
      mute_cold: false
ma_crossover:
    - enabled: false
stoch_rsi:
    - enabled: false
adx:
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 3m
      period_count: 14
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 1m
      period_count: 14
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 5m
      period_count: 14
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 15m
      period_count: 14
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 30m
      period_count: 14
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - adx
        - pdi
        - ndi
      hot: 25
      cold: 25
      candle_period: 1h
      period_count: 14
rsi:
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 3m
      period_count: 14
      mute_cold: false
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 1m
      period_count: 14
      mute_cold: false
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 5m
      period_count: 14
      mute_cold: false
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 15m
      period_count: 14
      mute_cold: false
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 30m
      period_count: 14
      mute_cold: false
    - enabled: true
      alert_enabled: true
      alert_frequency: always
      signal:
        - rsi
      hot: 50
      cold: 50
      candle_period: 1h
      period_count: 14
      mute_cold: false
stochrsi_cross:
    - enabled: false
momentum:
    - enabled: false
macd:
    - enabled: false
ma_ribbon:
    - enabled: false 
iiv:
    - enabled: false
obv:
    - enabled: false
mfi:
    - enabled: false
ichimoku:
    - enabled: false

informants:

lrsi:
    - enabled: false
sma:
    - enabled: false 
ema:
    - enabled: false

vwap:
    - enabled: false
bollinger_bands:
    - enabled: false
ohlcv:
    - enabled: true
      signal:
        - high
        - low
        - close
      candle_period: 1m
      period_count: 14

conditionals:

-label: "Signal to buy" hot:

  • bbp: 0
  • rsi: 0
  • rsi: 1
  • rsi: 2
  • rsi: 3
  • rsi: 4
  • rsi: 5
  • adx: 0
  • adx: 1
  • adx: 2
  • adx: 3
  • adx: 4
  • adx: 5

-label: "Signal to sell" cold:

  • bbp: 0
  • rsi: 0
  • rsi: 0
  • rsi: 1
  • rsi: 2
  • rsi: 3
  • rsi: 4
  • rsi: 5
  • adx: 0
  • adx: 1
  • adx: 2
  • adx: 3
  • adx: 4
  • adx: 5

notifiers:

webhook:
    required:
        url: https://shiftcrypto.my.id/newtest/newfuture1.php
    optional:
        username: 
        password: 

its take some time and i got this data

[{"values": [{"rsi": "54.91"}, {"rsi": "54.91"}, {"bbp": "0.69", "mfi": "54.07"}, {"adx": "13.65", "pdi": "594.27", "ndi": "552.72"}, {"rsi": "50.64"}, {"adx": "18.71", "pdi": "447.95", "ndi": "437.19"}, {"rsi": "58.68"}, {"adx": "22.75", "pdi": "346.47", "ndi": "269.12"}, {"rsi": "61.18"}, {"adx": "20.64", "pdi": "1125.73", "ndi": "869.02"}, {"rsi": "57.98"}, {"adx": "15.80", "pdi": "1265.89", "ndi": "832.03"}, {"rsi": "55.94"}, {"adx": "12.27", "pdi": "2053.54", "ndi": "1663.40"}], "indicator": ["rsi", "rsi", "bbp", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx"], "price_value": {"3m": {}, "1m": {"high": 0.10292, "low": 0.10277, "close": 0.10288}, "5m": {}, "15m": {}, "30m": {}, "1h": {}}, "exchange": "binance", "market": "RVN/USDT", "base_currency": "RVN", "quote_currency": "USDT", "prices": "", "decimal_format": "%.5f", "status": "Signal to sell"}]

I didn't have time to test this config. I wil try tomorrow. Thank you.

w1ld3r commented 2 years ago

If you have difficuties identifing the error in your config file, don't hesitate to add a log output to your issue

ppovedam commented 2 years ago

try this config.. i use it to try conditional and its work.. use webhook notifier

settings:
    log_level: INFO
    update_interval: 900
    start_worker_interval: 15
    market_data_chunk_size: 1

exchanges:
    binance:
        required:
            enabled: true
        all_pairs:
            - USDT
            #- BTC
        future: true         
        exclude:
            - USDC
            - PAX
            - BUSD
            - TUSD
            - EUR
            - SUSD
            - GBP
            - UTK

indicators:
    bbp:
        - enabled: true
          candle_period: 3m
          alert_enabled: true
          alert_frequency: always
          period_count: 20
          hot: 0
          cold: 0
          std_dev: 2
          signal:
            - bbp
            - mfi
          hot_label: 'Lower Band'
          cold_label: 'Upper Band'
          indicator_label: 'Bollinger Crossing'
          mute_cold: false
    ma_crossover:
        - enabled: false
    stoch_rsi:
        - enabled: false
    adx:
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 3m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 1m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 5m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 15m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 30m
          period_count: 14
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - adx
            - pdi
            - ndi
          hot: 25
          cold: 25
          candle_period: 1h
          period_count: 14
    rsi:
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 3m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 1m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 5m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 15m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 30m
          period_count: 14
          mute_cold: false
        - enabled: true
          alert_enabled: true
          alert_frequency: always
          signal:
            - rsi
          hot: 50
          cold: 50
          candle_period: 1h
          period_count: 14
          mute_cold: false
    stochrsi_cross:
        - enabled: false
    momentum:
        - enabled: false
    macd:
        - enabled: false
    ma_ribbon:
        - enabled: false 
    iiv:
        - enabled: false
    obv:
        - enabled: false
    mfi:
        - enabled: false
    ichimoku:
        - enabled: false

informants:
    lrsi:
        - enabled: false
    sma:
        - enabled: false 
    ema:
        - enabled: false

    vwap:
        - enabled: false
    bollinger_bands:
        - enabled: false
    ohlcv:
        - enabled: true
          signal:
            - high
            - low
            - close
          candle_period: 1m
          period_count: 14

conditionals:
-label: "Signal to buy"
    hot:
      - bbp: 0
      - rsi: 0
      - rsi: 1
      - rsi: 2
      - rsi: 3
      - rsi: 4
      - rsi: 5
      - adx: 0
      - adx: 1
      - adx: 2
      - adx: 3
      - adx: 4
      - adx: 5

-label: "Signal to sell"
    cold:
      - bbp: 0
      - rsi: 0
      - rsi: 0
      - rsi: 1
      - rsi: 2
      - rsi: 3
      - rsi: 4
      - rsi: 5
      - adx: 0
      - adx: 1
      - adx: 2
      - adx: 3
      - adx: 4
      - adx: 5

notifiers:
    webhook:
        required:
            url: https://shiftcrypto.my.id/newtest/newfuture1.php
        optional:
            username: 
            password: 

its take some time and i got this data

[{"values": [{"rsi": "54.91"}, {"rsi": "54.91"}, {"bbp": "0.69", "mfi": "54.07"}, {"adx": "13.65", "pdi": "594.27", "ndi": "552.72"}, {"rsi": "50.64"}, {"adx": "18.71", "pdi": "447.95", "ndi": "437.19"}, {"rsi": "58.68"}, {"adx": "22.75", "pdi": "346.47", "ndi": "269.12"}, {"rsi": "61.18"}, {"adx": "20.64", "pdi": "1125.73", "ndi": "869.02"}, {"rsi": "57.98"}, {"adx": "15.80", "pdi": "1265.89", "ndi": "832.03"}, {"rsi": "55.94"}, {"adx": "12.27", "pdi": "2053.54", "ndi": "1663.40"}], "indicator": ["rsi", "rsi", "bbp", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx", "rsi", "adx"], "price_value": {"3m": {}, "1m": {"high": 0.10292, "low": 0.10277, "close": 0.10288}, "5m": {}, "15m": {}, "30m": {}, "1h": {}}, "exchange": "binance", "market": "RVN/USDT", "base_currency": "RVN", "quote_currency": "USDT", "prices": "", "decimal_format": "%.5f", "status": "Signal to sell"}]

I have tested your config.yml but it still does not work. I have created a webhook but only receives messages if I remove the conditionals

ppovedam commented 2 years ago

If you have difficuties identifing the error in your config file, don't hesitate to add a log output to your issue

Thanks w1ld3r, but I'm not sure how to do that. Terminal log?

w1ld3r commented 2 years ago

How do your run the app ?

ppovedam commented 2 years ago

How do your run the app ?

I'm using docker run --rm -ti -v $PWD/app:/app dev/crypto-signals:latest in a terminal, but I have also tried with docker run --rm -di -v $PWD/app:/app dev/crypto-signals:latest

ppovedam commented 2 years ago

How do your run the app ? w1ld3r, find enclosed both the config (renamed as txt) and a test output.

config.txt output.txt

w1ld3r commented 2 years ago

How do your run the app ?

I'm using docker run --rm -ti -v $PWD/app:/app dev/crypto-signals:latest in a terminal, but I have also tried with docker run --rm -di -v $PWD/app:/app dev/crypto-signals:latest

So when you launch it using docker and -ti paramater, dont you see texte output ?

ppovedam commented 2 years ago

How do your run the app ?

I'm using docker run --rm -ti -v $PWD/app:/app dev/crypto-signals:latest in a terminal, but I have also tried with docker run --rm -di -v $PWD/app:/app dev/crypto-signals:latest

So when you launch it using docker and -ti paramater, dont you see texte output ?

Yes, I see text. I sent you some files in the last comment. I do not see any error.

w1ld3r commented 2 years ago

Your confguration file is good. You are not receiving notification because the condition isn't triggered. To test, you can put stoch_rsi hot value at 100 and cold at 0 you will for sure trigger an alert.

ppovedam commented 2 years ago

Your confguration file is good. You are not receiving notification because the condition isn't triggered. To test, you can put stoch_rsi hot value at 100 and cold at 0 you will for sure trigger an alert.

I think the cause of the failure may be in the notification.py file. In the next section my computer always execute the "except" option (pass):

or msg in messages[candle_period]: for stat in status: if msg['status'] == stat: try: for indicator in condition[stat]: if msg['alert_frequency'] != 'once': should_alert += self.should_i_alert(''.join( [msg['market'], msg['values'][0], candle_period]), msg['alert_frequency']) if msg['indicator'] in indicator.keys(): if indicator[msg['indicator']] == msg['indicator_number']: new_message['values'].append( msg['values']) new_message['indicator'].append( msg['indicator']) c_nb_conditions += 1 if msg['last_status'] == msg['last_status'] and msg['analysis']['config']['alert_frequency'] == 'once' and not self.first_run: c_nb_once_muted += 1 if msg['last_status'] != msg['last_status']: c_nb_new_status += 1 except: pass

The problem is given by the syntax msg['alert_frequency'], which does not work on my computer. Is it probably because I am missing some library? To access 'alert_frequency' I need to put msg['analysis']['config'][alert_frequency']. The same happens with msg['values'][0], it doesn't work to access the value of the indicator. Any idea to solve the problem?

w1ld3r commented 2 years ago

Can you check the new push ? Thanks a lot for your debug.

ppovedam commented 2 years ago

Can you check the new push ? Thanks a lot for your debug.

Thank you very much, w1ld3r, now it's working properly.