forked from Chavithra/degiro-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_otp.py
36 lines (27 loc) · 836 Bytes
/
connection_otp.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
# IMPORTATIONS
import json
import logging
from trading.api import API as TradingAPI
from trading.pb.trading_pb2 import Credentials
# SETUP LOGGING LEVEL
logging.basicConfig(level=logging.DEBUG)
# SETUP CONFIG DICT
with open('config/config.json') as config_file:
config_dict = json.load(config_file)
# SETUP CREDENTIALS
username = config_dict['username']
password = config_dict['password']
one_time_password = config_dict['one_time_password']
credentials = Credentials(
int_account=None,
username=username,
password=password,
one_time_password=one_time_password,
)
# SETUP TRADING API
trading_api = TradingAPI(credentials=credentials)
# CONNECT
trading_api.connect()
# ACCESS SESSION_ID
session_id = trading_api.connection_storage.session_id
print('You are now connected, with the session id :', session_id)