Beispiel #1
0
def create_app(config_name='default'):
    config_name = os.environ.get('TERMINAL_ENV') or config_name
    # TODO: 去掉函数
    session_factory = init_db(config_name)()
    dispatch_params = init_dispatch(config_name)
    logging_params = init_logging(config_name)
    redis_params = init_redis(config_name)
    server_params = init_server(config_name)
    port = init_tornado(config_name)
    # 初始化dispatch参数
    JsonRpcHandler.set_dispatcher(dispatch_params)
    # 初始化Logging参数
    Logging.set_logging_params(logging_params)
    RedisUtils.set_redis_params(redis_params)
    ServerUtils.set_server_params(server_params)
    # 初始化Handler
    handlers = [(r"/api/rpc", QuoteCloseHandler),
                (r"/api/rpc", HistoricalVolHandler),
                (r"/api/rpc", OptionStructureHandler),
                (r"/api/rpc", OTCPositionSnapshotHandler),
                (r"/api/rpc", RealTimeMarketHandler),
                (r"/api/rpc", FittingModelHandler),
                (r"/api/rpc", CommodityFutureContractHandler),
                (r"/api/rpc", OtcAtmQuoteHandler),
                (r"/api/rpc", OTCReportHandler),
                (r"/api/rpc", InstrumentHandler)]
    # 初始化Server
    app = web.Application(handlers=handlers, session_factory=session_factory)
    app.listen(port)
    return app
Beispiel #2
0
from dags.dbo.db_model import create_db_session
import pandas as pd
from terminal.dbo import OtcAtmQuote
from terminal.dto import OptionProductType
import uuid
import os
from terminal.utils import DateTimeUtils, Logging
from datetime import datetime

logging = Logging.getLogger(__name__)


class OtcAtmQuoteService:
    @staticmethod
    def import_atm_vol_from_csv_file(file_path, run_id):
        fname, ext = os.path.splitext(file_path)
        valuation_date = DateTimeUtils.str2date(fname.split('_')[1],
                                                pattern='%Y%m%d')
        df = pd.read_csv(file_path)
        atm_quote_list = []
        current_time = datetime.now()
        for index, row in df.iterrows():
            atm_quote = OtcAtmQuote()
            atm_quote.uuid = uuid.uuid4()
            atm_quote.varietyType = row['udly'].strip()
            atm_quote.underlyer = row['code'].strip()
            atm_quote.legalEntityName = row['ctpt'].strip()
            atm_quote.expireDate = DateTimeUtils.str2date(row['exe_date'])
            if row['type'] == 'am':
                atm_quote.productType = OptionProductType.VANILLA_AMERICAN.name
            if row['type'] == 'eu':