Exemple #1
0
def handle(ex: Exception) -> str:
    response: ResponseModel = ResponseModel()
    try:
        LogUtils.error('Handle error', ex)

        msg: str = str(ex)
        response.http_status_code = http.HTTPStatus.INTERNAL_SERVER_ERROR
        response.error_message = msg if msg else 'Error'
        if isinstance(ex, BadRequestException):
            response.http_status_code = http.HTTPStatus.BAD_REQUEST
        if isinstance(ex, NotFoundException):
            response.http_status_code = http.HTTPStatus.NOT_FOUND
        if isinstance(ex, DbConnectionException):
            response.http_status_code = http.HTTPStatus.INTERNAL_SERVER_ERROR
    except Exception as e:
        response.http_status_code = http.HTTPStatus.INTERNAL_SERVER_ERROR
        response.error_message = 'Error'
    return StringUtils.to_json(response)
Exemple #2
0
def close_positions() -> str:
    return StringUtils.to_json(ResponseModel(
        __trade_service.close_positions()))
Exemple #3
0
def sync_orders() -> str:
    return StringUtils.to_json(ResponseModel(__trade_service.sync_orders()))
Exemple #4
0
def get_all_suggestions() -> str:
    return StringUtils.to_json(
        ResponseModel(__trade_service.get_all_suggestions()))
Exemple #5
0
def get_suggestions() -> str:
    req: TradeSuggestionsRequest = ModelUtils.get_obj(
        TradeSuggestionsRequest(), request.get_json())
    return StringUtils.to_json(
        ResponseModel(__trade_service.get_suggestions(req)))
Exemple #6
0
def get_trade_orders() -> str:
    req: GetTradeOrdersRequest = ModelUtils.get_obj(GetTradeOrdersRequest(),
                                                    request.get_json())
    return StringUtils.to_json(
        ResponseModel(__trade_service.get_trade_orders(req)))
Exemple #7
0
def get_key_info(symbol: str) -> str:
    return StringUtils.to_json(
        ResponseModel(__trade_service.get_key_info(symbol)))
Exemple #8
0
def get_account() -> str:
    return StringUtils.to_json(ResponseModel(__trade_service.get_account()))
Exemple #9
0
def get_sample_prices_for_charts() -> str:
    req: CR = ModelUtils.get_obj(CR(), request.get_json())
    return StringUtils.to_json(
        ResponseModel(__stock_service.get_sample_prices_for_charts(req)))
Exemple #10
0
def get_sp500_mismatches(is_missing: str) -> str:
    return StringUtils.to_json(
        ResponseModel(
            __stock_service.get_sp500_mismatches(is_missing == 'True')))
Exemple #11
0
def delete_old_prices() -> str:
    return StringUtils.to_json(
        ResponseModel(__stock_service.delete_old_prices()))
Exemple #12
0
def update_symbol() -> str:
    req: SymbolMaster = ModelUtils.get_obj(SymbolMaster(), request.get_json())
    return StringUtils.to_json(
        ResponseModel(__stock_service.update_symbol(req)))
Exemple #13
0
def get_symbols(instrument: str) -> str:
    return StringUtils.to_json(
        ResponseModel(__stock_service.get_symbols(instrument)))
Exemple #14
0
def run() -> str:
    req: BackTestRunRequest = ModelUtils.get_obj(BackTestRunRequest(),
                                                 request.get_json())
    return StringUtils.to_json(ResponseModel(__back_test_service.run(req)))
Exemple #15
0
def import_prices() -> str:
    return StringUtils.to_json(ResponseModel(__import_service.import_prices()))