-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
78 lines (64 loc) · 2.44 KB
/
main.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import requests
import json
import websockets
from datetime import datetime
import asyncio
# from dydx3.constants import ORDER_TYPE_LIMIT
# from dydx3.constants import MARKET_ETH_USD, MARKET_BTC_USD
from connectors import DeribitConnection
from telegram_bot import TelegramNotifier
# from trading_bot.trading_bot import TradingBot
from trading_bot import (TradingBotOneInstrumentMarketOrders, TradingBotTwoInstrumentsMarketOrders,
TradingBotOneInstrumentLimitOrders, TradingBotTwoInstrumentsLimitOrders)
from utils import load_config
config = load_config('config.yaml')
async def main():
deribit_connection = DeribitConnection(
client_id=config['credentials']['deribit']['client_id'],
client_secret=config['credentials']['deribit']['client_secret']
)
await deribit_connection.connect()
await deribit_connection.authenticate()
telegram_notifier = TelegramNotifier(
bot_token=config['telegram']['bot_token'],
chat_id=config['telegram']['chat_id']
)
instr1 = config['trading_parameters']['instrument_1']
instr2 = config['trading_parameters']['instrument_2']
orders_type = config['trading_parameters']['orders_type']
if instr2 != '-':
if orders_type == 'market':
trading_bot = TradingBotTwoInstrumentsMarketOrders(
conn=deribit_connection,
telegram_bot=telegram_notifier,
)
elif orders_type == 'limit':
trading_bot = TradingBotTwoInstrumentsLimitOrders(
conn=deribit_connection,
telegram_bot=telegram_notifier,
)
else:
if orders_type == 'market':
trading_bot = TradingBotOneInstrumentMarketOrders(
conn=deribit_connection,
telegram_bot=telegram_notifier,
)
elif orders_type == 'limit':
trading_bot = TradingBotOneInstrumentLimitOrders(
conn=deribit_connection,
telegram_bot=telegram_notifier,
)
# try:
await asyncio.gather(
trading_bot.run(),
# trading_bot.send_strategy_info()
)
# except Exception as e:
# print(e)
# await telegram_notifier.send_message(f'Exception: {e}', parse_mode='')
# await asyncio.sleep(1)
# await telegram_notifier.send_message('Bot closed')
# return
print('trading bot closed')
if __name__ == '__main__':
asyncio.run(main())