import json
import requests

from bitcoinmonitor.celeryconfig import app
from channels import Group


app.conf.beat_schedule = {
    'add-every-30-seconds': {
        'task': 'dashboard.tasks.get_bitcoin_price',
        'schedule': 6.0,
        'args': ("dale",)
    },
}


@app.task
def get_bitcoin_price(arg):
    last_price = requests.get("https://bittrex.com/api/v1.1/public/getticker?market=USDT-BTC").json().get("result").get("Last")
    Group('btc-price').send({'text': json.dumps({
        'last_price': last_price
    })})

import json

from bitcoinmonitor.celeryconfig import app
from channels import Group
from .helpers import get_coin_price


app.conf.beat_schedule = {
    'get-bitcoin-price-every-five-seconds': {
        'task': 'dashboard.tasks.get_bitcoin_price',
        'schedule': 5.0,
    },
    'get-litecoin-price-every-five-seconds': {
        'task': 'dashboard.tasks.get_litcoin_price',
        'schedule': 5.0,
    },
}


@app.task
def get_bitcoin_price():
    data = get_coin_price('BTC')

    Group('btc-price').send({'text': data})


@app.task
def get_litcoin_price():
    data = get_coin_price('LTC')

    Group('ltc-price').send({'text': data})

Create another task to get the litecoin price
Create another task to get the litecoin price

  import json
- import requests
  
  from bitcoinmonitor.celeryconfig import app
  from channels import Group
+ from .helpers import get_coin_price
  
  
  app.conf.beat_schedule = {
-     'add-every-30-seconds': {
+     'get-bitcoin-price-every-five-seconds': {
          'task': 'dashboard.tasks.get_bitcoin_price',
-         'schedule': 6.0,
+         'schedule': 5.0,
-         'args': ("dale",)
+     },
+     'get-litecoin-price-every-five-seconds': {
+         'task': 'dashboard.tasks.get_litcoin_price',
+         'schedule': 5.0,
      },
  }
  
  
  @app.task
- def get_bitcoin_price(arg):
+ def get_bitcoin_price():
+     data = get_coin_price('BTC')
-     last_price = requests.get("https://bittrex.com/api/v1.1/public/getticker?market=USDT-BTC").json().get("result").get("Last")
-     Group('btc-price').send({'text': json.dumps({
-         'last_price': last_price
-     })})
  
+     Group('btc-price').send({'text': data})
+ 
+ 
+ @app.task
+ def get_litcoin_price():
+     data = get_coin_price('LTC')
+ 
+     Group('ltc-price').send({'text': data})
+ 
Create another task to get the litecoin price
## Code Before:
import json
import requests

from bitcoinmonitor.celeryconfig import app
from channels import Group


app.conf.beat_schedule = {
    'add-every-30-seconds': {
        'task': 'dashboard.tasks.get_bitcoin_price',
        'schedule': 6.0,
        'args': ("dale",)
    },
}


@app.task
def get_bitcoin_price(arg):
    last_price = requests.get("https://bittrex.com/api/v1.1/public/getticker?market=USDT-BTC").json().get("result").get("Last")
    Group('btc-price').send({'text': json.dumps({
        'last_price': last_price
    })})

## Instruction:
Create another task to get the litecoin price
## Code After:
import json

from bitcoinmonitor.celeryconfig import app
from channels import Group
from .helpers import get_coin_price


app.conf.beat_schedule = {
    'get-bitcoin-price-every-five-seconds': {
        'task': 'dashboard.tasks.get_bitcoin_price',
        'schedule': 5.0,
    },
    'get-litecoin-price-every-five-seconds': {
        'task': 'dashboard.tasks.get_litcoin_price',
        'schedule': 5.0,
    },
}


@app.task
def get_bitcoin_price():
    data = get_coin_price('BTC')

    Group('btc-price').send({'text': data})


@app.task
def get_litcoin_price():
    data = get_coin_price('LTC')

    Group('ltc-price').send({'text': data})
