-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
74 lines (64 loc) · 2.56 KB
/
Copy pathapp.py
File metadata and controls
74 lines (64 loc) · 2.56 KB
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
from utils import GroupSignal, Session, Strategy, get_timedelta
from utils import indicators
from utils.signals import *
from utils.indicators import *
from utils.pid_management import *
from utils.strategies import STRATEGIES
from utils.session import Controller, CustomedQueue
from utils.fxcm_connection import FXCMConnection
from utils.charting import GraphCharter
from dotenv import dotenv_values
from datetime import datetime
import logging
import logging.config
from logging import StreamHandler, LogRecord
from utils.telegram_bot import TeleBot
import queue
import sys
import argparse
import configparser
import threading
from threading import Event
# Read config
confparser = configparser.ConfigParser()
confparser.read('configs.conf')
TMZ = int(confparser['DEFAULT']['TMZ'])
RECEIVER_ID = confparser['DEFAULT']['RECEIVER_ID']
PLATFORM = confparser['DEFAULT']['PLATFORM']
# Read .env file
envs = dotenv_values('.env')
TOKEN = envs['TOKEN']
def main():
# Arguments
# parser = argparse.ArgumentParser()
# parser.add_argument('--id', type = str, help = 'Id of the session.')
# parser.add_argument('--instrument', type = str, help = 'The instrument for the strategy to work on.')
# parser.add_argument('--timeframe', type = str, help = 'The timeframe for the strategy to work on.')
# parser.add_argument('--strategy', type = str, help = 'Name of the customed strategy.')
# parser.add_argument('--name', type = str, help = 'Name of the session, must be unique, for user reference.')
# parser.add_argument('--lookback', type = int, help = 'The number of lookback period, could be used for backtesting.')
# Connection
connection = FXCMConnection(token = TOKEN, server = 'real')
if not connection.is_connected():
sys.exit('Cannot connect to FXCM server.')
# Queue
queue_killed = Event()
message_queue = CustomedQueue(kill_event = queue_killed)
# Graph charter
graph_charter = GraphCharter()
# Create logger
# logger = create_file_logger(session._path_logs)
# print(session._path_logs)
logging.basicConfig(
filename='logs.txt',
filemode='w', format='%(name)s - %(levelname)s - %(message)s',
level = logging.INFO)
bot = TeleBot(
token = envs['BOT_TOKEN'], message_queue = message_queue,
receiver_id = RECEIVER_ID, kill_event = queue_killed)
controller = Controller(
platform = PLATFORM, connection = connection, message_queue = message_queue,
graph_charter = graph_charter, bot = bot)
controller.start_listening()
if __name__ == '__main__':
main()