示例#1
0
    def handleBrokerLogin(args):
        brokerAppConfig = getBrokerAppConfig()

        brokerAppDetails = BrokerAppDetails(brokerAppConfig['broker'])
        brokerAppDetails.setClientID(brokerAppConfig['clientID'])
        brokerAppDetails.setAppKey(brokerAppConfig['appKey'])
        brokerAppDetails.setAppSecret(brokerAppConfig['appSecret'])

        logging.info('handleBrokerLogin appKey %s', brokerAppDetails.appKey)

        if brokerAppDetails.broker == 'zerodha':
            Controller.brokerLogin = ZerodhaLogin(brokerAppDetails)
        # Other brokers - not implemented
        #elif brokerAppDetails.broker == 'fyers':
        #Controller.brokerLogin = FyersLogin(brokerAppDetails)

        redirectUrl = Controller.brokerLogin.login(args)
        return redirectUrl
    def handleBrokerLogin(args):
        brokerAppConfig = getBrokerAppConfig(
            Path(__file__).parent.parent.parent)

        brokerAppDetails = BrokerAppDetails(brokerAppConfig['broker'])
        brokerAppDetails.setClientID(brokerAppConfig['clientID'])
        brokerAppDetails.setAppKey(brokerAppConfig['appKey'])
        brokerAppDetails.setAppSecret(brokerAppConfig['appSecret'])

        logging.info('handleBrokerLogin appKey %s', brokerAppDetails.appKey)
        Controller.brokerName = brokerAppDetails.broker
        if Controller.brokerName == 'zerodha':
            Controller.brokerLogin = ZerodhaLogin(brokerAppDetails)
        # Other brokers - not implemented
        elif Controller.brokerName == 'angel':
            Controller.brokerLogin = AngelLogin(brokerAppDetails)

        redirectUrl = Controller.brokerLogin.login(args)
        return redirectUrl
示例#3
0
app.add_url_rule("/holdings", view_func=HoldingsAPI.as_view("holdings_api"))

def initLoggingConfg(filepath):
  format = "%(asctime)s: %(message)s"
  logging.basicConfig(filename=filepath, format=format, level=logging.INFO, datefmt="%Y-%m-%d %H:%M:%S")

# Execution starts here
serverConfig = getServerConfig()
logFileDir = serverConfig['logFileDir']
if os.path.exists(logFileDir) == False:
  print("LogFile Directory " + logFileDir + " does not exist. Exiting the app.")
  exit(-1)

tradesDir = serverConfig['tradesDir']
if os.path.exists(tradesDir) == False:
  print("Trades Directory " + tradesDir + " does not exist. Exiting the app.")
  exit(-1)

print("LogFile Directory = " + logFileDir)
print("Trades  Directory = " + tradesDir)
initLoggingConfg(logFileDir + "/app.log")


logging.info('serverConfig => %s', serverConfig)

brokerAppConfig = getBrokerAppConfig()
logging.info('brokerAppConfig => %s', brokerAppConfig)

port = serverConfig['port']

app.run('localhost', port)
app.add_url_rule("/holdings", view_func=HoldingsAPI.as_view("holdings_api"))

def initLoggingConfg(filepath):
  format = "%(asctime)s: %(message)s"
  logging.basicConfig(filename=filepath, format=format, level=logging.INFO, datefmt="%Y-%m-%d %H:%M:%S")

# Execution starts here
serverConfig = getServerConfig(Path(__file__).parent.parent)

deployDir = serverConfig['deployDir']
if os.path.exists(deployDir) == False:
  print("Deploy Directory " + deployDir + " does not exist. Exiting the app.")
  exit(-1)

logFileDir = serverConfig['logFileDir']
if os.path.exists(logFileDir) == False:
  print("LogFile Directory " + logFileDir + " does not exist. Exiting the app.")
  exit(-1)

print("Deploy  Directory = " + deployDir)
print("LogFile Directory = " + logFileDir)
initLoggingConfg(logFileDir + "/app.log")

logging.info('serverConfig => %s', serverConfig)

brokerAppConfig = getBrokerAppConfig(Path(__file__).parent.parent)
logging.info('brokerAppConfig => %s', brokerAppConfig)

port = serverConfig['port']

app.run('localhost', port)