forked from hari-allamraju/pycon-2014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueues.py
28 lines (22 loc) · 768 Bytes
/
queues.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import simplejson as json
from celery import Celery
from celery.utils.log import get_task_logger
import redis
celery=Celery('positions',broker='redis://',backend='redis://')
logger = get_task_logger(__name__)
@celery.task(queue='priority_queue')
def get_initial_position_value(name):
db=redis.Redis()
pos=json.loads(db.get(name))
return pos['size']*pos['price']
@celery.task(queue='priority_queue')
def get_value_at_close(name,close):
db=redis.Redis()
pos=json.loads(db.get(name))
return pos['size']*close
@celery.task(queue='priority_queue')
def get_value_at_close_1(name,close):
db=redis.Redis()
pos=json.loads(db.get(name))
logger.info('Calculating value with close price %s'%(close,))
return pos['size']*close