-
Notifications
You must be signed in to change notification settings - Fork 0
/
trading_bot.py
63 lines (51 loc) · 2.59 KB
/
trading_bot.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import strategy_config
from gatecoin import gatecoin
from bittrex import bittrex
from liqui import liqui
import datetime
import logging
from pprint import pprint
logger = logging.getLogger("TradingBot")
logger.setLevel(logging.DEBUG)
# Create a file handler
handler = logging.FileHandler('./log_' + datetime.datetime.now().strftime("%Y-%m-%d") + '.log')
handler.setLevel(logging.INFO)
# Create a logging format
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
# Add the handlers to the logger
logger.addHandler(handler)
if __name__ == "__main__":
logger.info("------------------------------------------------------------------------------")
logger.info("------------------------------- CONFIGURATION --------------------------------")
logger.info("------------------------------------------------------------------------------")
exchange = {}
orderbook = {}
orderbook_raw = {}
exchange['Gatecoin'] = gatecoin.Gatecoin(
"https://api.gatecoin.com",
strategy_config.gatecoin['public'],
strategy_config.gatecoin['private'])
orderbook['Gatecoin'] = {}
exchange['Bittrex'] = bittrex.Bittrex(
strategy_config.bittrex['public'],
strategy_config.bittrex['private'])
orderbook['Bittrex'] = {}
exchange['Liqui'] = liqui.Liqui(
strategy_config.liqui['public'],
strategy_config.liqui['private'])
orderbook['Liqui'] = {}
currency_pairs = strategy_config.currency_pairs
one_bp_in_pourcent = strategy_config.one_bp_in_pourcent
logger.info("------------------------------------------------------------------------------")
logger.info("-------------------------------- PROCESSING ----------------------------------")
logger.info("------------------------------------------------------------------------------")
for currency_pair in currency_pairs:
# Simple example on getting the order book for the currency from 2 exchanges: Gatecoin and Bittrex
logger.info("Getting the Primary exchange clean orderbook")
orderbook[currency_pair['Primary_exchange']] = exchange[currency_pair['Primary_exchange']].clean_orderbook(currency_pair['Primary_exchange_currencypair'])
pprint(orderbook[currency_pair['Primary_exchange']])
logger.info("Getting the Secondary exchange clean orderbook")
orderbook[currency_pair['Secondary_exchange']] = exchange[currency_pair['Secondary_exchange']].clean_orderbook(currency_pair['Secondary_exchange_currencypair'])
pprint(orderbook[currency_pair['Secondary_exchange']])
quit()