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, )
# 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, ) to_date = CashAccountReport.Request.Date( year=today.year, month=today.month, day=today.day,
def login(self, credentials: Credentials): self.__trading_api = TradingAPI(credentials=credentials) self.__trading_api.connect() self.__setup_extra_credentials()
def trading_api(credentials) -> TradingAPI: trading_api = TradingAPI(credentials=credentials) trading_api.connect() return trading_api