-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
36 lines (31 loc) · 1.17 KB
/
run.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
28
29
30
31
32
33
34
35
36
""" run.py
Main file which implements `StocasticMACD` strategy,
sets up logging, and runs scheduler.
"""
from core.markets.GeminiMarket import GeminiMarket
from StochasticMACD import StochasticMACD
from investr import Investr
from apscheduler.schedulers.blocking import BlockingScheduler
import logging
api_key = "account-n60VfGdUsMQmM3KUIPK2"
api_secret = "459WjMdQT6mWGYB1rxQejwi74wJs"
mark = GeminiMarket(api_key, api_secret)
amount = 0.000500 # $5 worth at time of writing
fiat = 50.0
minimum = 0.01
strat = StochasticMACD(amount, fiat, 0.10, minimum, mark)
inv = Investr(mark, strat)
logging.basicConfig(filename='investr.log', level=logging.INFO,
format='%(asctime)s|%(levelname)s|%(message)s', datefmt='%m/%d/%Y %H:%M:%S')
logging.getLogger('apscheduler').setLevel(logging.ERROR)
if __name__ == '__main__':
scheduler = BlockingScheduler()
try:
logging.info("Starting...")
scheduler.add_job(inv.run, 'interval', seconds=30)
scheduler.add_job(inv.save, 'interval', minutes=1)
scheduler.start()
except KeyboardInterrupt:
logging.info("Shutting Down")
print("Shutting Down...")
scheduler.shutdown()