Exemple #1
0
def credentials(config, request) -> Credentials:
    """ Get `--user-token` argument from `CONFIG_FILE` or CLI.

    Args:
        config: `config` fixture.
        request: Pytest `request` fixture.

    Returns:
        Credentials: Trading API's credentials.
    """

    if config is not None:
        int_account = config.get("int_account")
        username = config.get("username")
        password = config.get("password")
        totp_secret_key = config.get("totp_secret_key")
        one_time_password = config.get("one_time_password")
    else:
        int_account = request.config.getoption("--int-account")
        username = request.config.getoption("--username")
        password = request.config.getoption("--password")
        totp_secret_key = request.config.getoption("--totp-secret-key")
        one_time_password = request.config.getoption("--one-time-password")

    credentials = Credentials(
        int_account=int_account,
        username=username,
        password=password,
        totp_secret_key=totp_secret_key,
        one_time_password=one_time_password,
    )

    return credentials
 def __init__(self):
     self.__default_credentials = Credentials(
         int_account=None,
         username=config.DG_USERNAME,
         password=config.DG_PASSWORD,
         one_time_password=None,
         totp_secret_key=config.DG_TOTP_SECRET,
     )
     self.__trading_api = TradingAPI(
         credentials=self.__default_credentials, )
Exemple #3
0
    def login(self, ns_parser: Namespace):
        # GET ATTRIBUTES
        degiro_model = self.__degiro_model
        default_credentials = degiro_model.login_default_credentials()

        credentials = Credentials()
        credentials.CopyFrom(default_credentials)
        credentials.username = ns_parser.username
        credentials.password = ns_parser.password

        if ns_parser.otp is not None:
            credentials.one_time_password = ns_parser.otp
        if ns_parser.topt_secret is not None:
            credentials.totp_secret_key = ns_parser.topt_secret

        degiro_model.login(credentials=credentials)

        DegiroView.__login_display_success()
Exemple #4
0
)

# 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
int_account = config_dict['int_account']
username = config_dict['username']
password = config_dict['password']
credentials = Credentials(
    int_account=int_account,
    username=username,
    password=password,
)

# SETUP TRADING API
trading_api = TradingAPI(credentials=credentials)

# CONNECT
trading_api.connect()

# SETUP REQUEST
today = datetime.date.today()
from_date = CashAccountReport.Request.Date(
    year=2020,
    month=1,
    day=1,
Exemple #5
0
# 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)
Exemple #6
0
# 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']
totp_secret_key = config_dict['totp_secret_key']

credentials = Credentials(
    int_account=None,
    username=username,
    password=password,
    totp_secret_key=totp_secret_key,
)

# 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)