Ejemplo n.º 1
0
 def __init__(self):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('traderiddb', host=host, port=port, alias='traderiddb')
     traderidcoll = switch(TraderIdColl, 'traderiddb')
     connect('twseiddb', host=host, port=port, alias='twseiddb')
     twseidcoll = switch(TwseIdColl, 'twseiddb')
     self._stock = StockIdDBHandler(twseidcoll)
     self._trader = TraderIdDBHandler(traderidcoll)
Ejemplo n.º 2
0
 def __init__(self):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('traderiddb', host=host, port=port, alias='traderiddb')
     traderidcoll = switch(TraderIdColl, 'traderiddb')
     connect('twseiddb', host=host, port=port, alias='twseiddb')
     twseidcoll = switch(TwseIdColl, 'twseiddb')
     self._stock = StockIdDBHandler(twseidcoll)
     self._trader = TraderIdDBHandler(traderidcoll)
Ejemplo n.º 3
0
 def __init__(self):
     super(OtcIdDBHandler, self).__init__()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('traderiddb', host=host, port=port, alias='traderiddb')
     traderidcoll = switch(TraderIdColl, 'traderiddb')
     connect('otciddb', host=host, port=port, alias='otciddb')
     otcidcoll = switch(OtcIdColl, 'otciddb')
     self._stock = StockIdDBHandler(otcidcoll)
     self._trader = TraderIdDBHandler(traderidcoll)
Ejemplo n.º 4
0
 def __init__(self):
     super(OtcIdDBHandler, self).__init__()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('traderiddb', host=host, port=port, alias='traderiddb')
     traderidcoll = switch(TraderIdColl, 'traderiddb')
     connect('otciddb', host=host, port=port, alias='otciddb')
     otcidcoll = switch(OtcIdColl, 'otciddb')
     self._stock = StockIdDBHandler(otcidcoll)
     self._trader = TraderIdDBHandler(traderidcoll)
Ejemplo n.º 5
0
 def __init__(self, **kwargs):
     super(OtcHisDBHandler, self).__init__(**copy.deepcopy(kwargs))
     self._debug = kwargs.pop('debug', False)
     db = 'otchisdb' if not self._debug else 'testotchisdb'
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     otchiscoll = switch(OtcHisColl, db)
     kwargs = {
         'stock': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'trader': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'credit': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'future': {
             'coll': otchiscoll,
             'debug': self._debug
         }
     }
     self._stock = OtcStockHisDBHandler(**kwargs['stock'])
     self._trader = OtcTraderHisDBHandler(**kwargs['trader'])
     self._credit = OtcCreditHisDBHandler(**kwargs['credit'])
     self._future = OtcFutureHisDBHandler(**kwargs['future'])
Ejemplo n.º 6
0
 def __init__(self, **kwargs):
     self._debug = kwargs.pop('debug', False)
     db = 'twsehisdb' if not self._debug else 'testtwsehisdb'
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     twsehiscoll = switch(TwseHisColl, db)
     kwargs = {
         'stock': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'trader': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'credit': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'future': {
             'coll': twsehiscoll,
             'debug': self._debug
         }
     }
     self._stock = TwseStockHisDBHandler(**kwargs['stock'])
     self._trader = TwseTraderHisDBHandler(**kwargs['trader'])
     self._credit = TwseCreditHisDBHandler(**kwargs['credit'])
     self._future = TwseFutureHisDBHandler(**kwargs['future'])
Ejemplo n.º 7
0
 def setUp(self):
     super(TestTwseHisColl, self).setUp()
     global TraderData, TraderInfo, StockData, TwseHisColl
     connect('twsehisdb', alias='twsehisdb')
     TwseHisColl = switch(TwseHisColl, 'twsehisdb')
     TwseHisColl.drop_collection()
     TwseHisColl.ensure_index([('date', -1), ('stockid', 1), ('stocknm', 1)])
Ejemplo n.º 8
0
 def setUp(self):
     super(TestTwseIdColl, self).setUp()
     global TwseIdColl
     connect('twseiddb', host=MongoDBDriver._host, port=MongoDBDriver._port, alias='twseiddb')
     TwseIdColl = switch(TwseIdColl, 'twseiddb')
     TwseIdColl.drop_collection()
     TwseIdColl.ensure_index([('stockid', 1), ('stocknm', 1)])
Ejemplo n.º 9
0
 def __init__(self):
     super(OtcHisDBHandler, self).__init__()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     otchiscoll = switch(OtcHisColl, 'otchisdb')
     self._stock = OtcStockHisDBHandler(otchiscoll)
     self._trader = OtcTraderHisDBHandler(otchiscoll)
Ejemplo n.º 10
0
 def __init__(self, **kwargs):
     self._debug = kwargs.pop('debug', False)
     db = 'twsehisdb' if not self._debug else 'testtwsehisdb'
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     twsehiscoll = switch(TwseHisColl, db)
     kwargs = {
         'stock': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'trader': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'credit': {
             'coll': twsehiscoll,
             'debug': self._debug
         },
         'future': {
             'coll': twsehiscoll,
             'debug': self._debug
         }
     }
     self._stock = TwseStockHisDBHandler(**kwargs['stock'])
     self._trader = TwseTraderHisDBHandler(**kwargs['trader'])
     self._credit = TwseCreditHisDBHandler(**kwargs['credit'])
     self._future = TwseFutureHisDBHandler(**kwargs['future'])
Ejemplo n.º 11
0
 def __init__(self, alg, **kwargs):
     self._alg = alg
     self._order = kwargs.pop('order', [])
     self._cfg = kwargs.pop('cfg', {})
     self._reserved = kwargs.pop('reserved', False)
     self._debug = kwargs.pop('debug', False)
     # hisframe collect args
     self._kwargs = {
         'opt': kwargs.pop('opt', None),
         'starttime': kwargs.pop('starttime', datetime.utcnow() - timedelta(days=30)),
         'endtime': kwargs.pop('endtime', datetime.utcnow()),
         'targets': ['stock'],
         'base': kwargs.pop('base', 'stock'),
         'stockids': kwargs.pop('stockids', []),
         'traderids': kwargs.pop('traderids', []),
         'limit': kwargs.pop('limit', 10),
         'debug': self._debug
     }
     db = "twsealgdb"
     db = db if not self._debug else 'test' + db
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     self._algcoll = switch(AlgStrategyColl, db)
     self._id = TwseIdDBHandler(debug=self._debug, opt='twse')
     self._report = Report(alg, sort=[('buys', False), ('sells', False), ('portfolio_value', False)], limit=100)
Ejemplo n.º 12
0
 def __init__(self):
     super(OtcHisDBHandler, self).__init__()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     otchiscoll = switch(OtcHisColl, 'otchisdb')
     self._stock = OtcStockHisDBHandler(otchiscoll)
     self._trader = OtcTraderHisDBHandler(otchiscoll)
Ejemplo n.º 13
0
 def __init__(self, **kwargs):
     super(OtcHisDBHandler, self).__init__(**copy.deepcopy(kwargs))
     self._debug = kwargs.pop('debug', False)
     db = 'otchisdb' if not self._debug else 'testotchisdb'
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     otchiscoll = switch(OtcHisColl, db)
     kwargs = {
         'stock': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'trader': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'credit': {
             'coll': otchiscoll,
             'debug': self._debug
         },
         'future': {
             'coll': otchiscoll,
             'debug': self._debug
         }
     }
     self._stock = OtcStockHisDBHandler(**kwargs['stock'])
     self._trader = OtcTraderHisDBHandler(**kwargs['trader'])
     self._credit = OtcCreditHisDBHandler(**kwargs['credit'])
     self._future = OtcFutureHisDBHandler(**kwargs['future'])
Ejemplo n.º 14
0
 def __init__(self, coll):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('stockhisdb', host=host, port=port, alias='stockhisdb')
     self._iddbhandler = TwseIdDBHandler()
     self._mapcoll = switch(StockMapColl, 'stockhisdb')
     self._mapcoll.drop_collection()
     self._coll = coll
     self._ids = []
Ejemplo n.º 15
0
 def __init__(self, alg, **kwargs):
     super(OtcAlgDBHandler, self).__init__(alg, **kwargs)
     db = "otcalgdb"
     db = db if not self._debug else 'test' + db
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect(db, host=host, port=port, alias=db)
     self._sumycoll = switch(AlgSummaryColl, db)
     self._id = OtcIdDBHandler(debug=self._debug, opt='otc')
Ejemplo n.º 16
0
 def __init__(self, coll):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('stockhisdb', host=host, port=port, alias='stockhisdb')
     self._iddbhandler = TwseIdDBHandler()
     self._mapcoll = switch(StockMapColl, 'stockhisdb')
     self._mapcoll.drop_collection()
     self._coll = coll
     self._ids = []
Ejemplo n.º 17
0
 def setUp(self):
     super(TestOtcHisTrader, self).setUp()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     self._hiscoll = switch(OtcHisColl, 'otchisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl otchistrader -s LOG_FILE=otchistrader.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 18
0
 def setUp(self):
     self._proc = start_service() if not has_service() else None
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     self._hiscoll = switch(OtcHisColl, 'otchisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl otchisstock -s LOG_FILE=otchisstock.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 19
0
 def setUp(self):
     super(TestTwseHisStock, self).setUp()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('twsehisdb', host=host, port=port, alias='twsehisdb')
     self._hiscoll = switch(TwseHisColl, 'twsehisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl twsehisstock -s LOG_FILE=twsehisstock.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 20
0
 def setUp(self):
     self._proc = start_service() if not has_service() else None
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     self._hiscoll = switch(OtcHisColl, 'otchisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl otchisstock -s LOG_FILE=otchisstock.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 21
0
 def setUp(self):
     super(TestOtcHisTrader, self).setUp()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('otchisdb', host=host, port=port, alias='otchisdb')
     self._hiscoll = switch(OtcHisColl, 'otchisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl otchistrader -s LOG_FILE=otchistrader.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 22
0
 def setUp(self):
     super(TestTwseHisStock, self).setUp()
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('twsehisdb', host=host, port=port, alias='twsehisdb')
     self._hiscoll = switch(TwseHisColl, 'twsehisdb')
     self._hiscoll.drop_collection()
     # call scrapy
     cmd = 'scrapy crawl twsehisstock -s LOG_FILE=twsehisstock.log -s GIANT_DEBUG=1 -s GIANT_LIMIT=1'
     subprocess.check_call(cmd, shell=True)
Ejemplo n.º 23
0
 def __init__(self, **kwargs):
     self._debug = kwargs.pop('debug', False)
     host, port = MongoDBDriver._host, MongoDBDriver._port
     db = 'traderiddb' if not self._debug else 'testtraderiddb'
     connect(db, host=host, port=port, alias=db)
     traderidcoll = switch(TraderIdColl, db)
     db = 'twseiddb' if not self._debug else 'testtwseiddb'
     connect(db, host=host, port=port, alias=db)
     twseidcoll = switch(TwseIdColl, db)
     kwargs = {
         'stock': {
             'coll': twseidcoll,
             'debug': self._debug,
             'opt': 'twse'
         },
         'trader': {
             'coll': traderidcoll,
             'debug': self._debug,
             'opt': 'twse'
         }
     }
     self._stock = StockIdDBHandler(**kwargs['stock'])
     self._trader = TraderIdDBHandler(**kwargs['trader'])
Ejemplo n.º 24
0
 def __init__(self):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('twsehisdb', host=host, port=port, alias='twsehisdb')
     twsehiscoll = switch(TwseHisColl, 'twsehisdb')
     self._stock = TwseStockHisDBHandler(twsehiscoll)
     self._trader = TwseTraderHisDBHandler(twsehiscoll)
Ejemplo n.º 25
0
 def __init__(self):
     host, port = MongoDBDriver._host, MongoDBDriver._port
     connect('twsehisdb', host=host, port=port, alias='twsehisdb')
     twsehiscoll = switch(TwseHisColl, 'twsehisdb')
     self._stock = TwseStockHisDBHandler(twsehiscoll)
     self._trader = TwseTraderHisDBHandler(twsehiscoll)