# Path: datafeed/exchange.py
# class SH(StockExchange):
#     name = 'Shanghai Stock Exchange'
#     currency = ('¥', 'CNY')
#     timezone = 'Asia/Shanghai'
#     _pre_market_session = ((9, 15), (9, 25))
#     _market_session = ((9, 30), (15, 0))
#     _market_break_session = ((11, 30), (13, 0))
# 
#     # Daily minute data count.
#     market_minutes = 242
# 
# Path: datafeed/tests/helper.py
# def sample_key():
# def sample():
# def sample_minutes():


import h5py
import os
import re
import time
import unittest
import numpy as np
    import shutil
from datetime import datetime
from mock import Mock, patch
from datafeed.exchange import SH
from datafeed.datastore import *
from datafeed.tests import helper

        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x)

    def test_update_multi_days(self):
        key = 'SH000001'
        x = np.array([
                (1316501700, 3130.8701171875, 3137.739990234375, 3128.81005859375,
                 3132.580078125, 30530.0, 20179424.0),
                (1316502000, 3132.68994140625, 3142.75, 3129.8798828125,
                 3141.5400390625, 57703.0, 41456768.0),
                (1316588100, 3210.860107421875, 3215.239990234375, 3208.43994140625,
                 3212.919921875, 62756.0, 49122656.0),
                (1316588400, 3213.43994140625, 3214.47998046875, 3206.800048828125,
                 3206.840087890625, 81252.0, 55866096.0)
                ], dtype=FiveMinute.DTYPE)
        self.store.update(key, x)

        date = datetime.fromtimestamp(1316501700).date()
        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x[:2])

        date = datetime.fromtimestamp(1316588400).date()
        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x[2:])

    def test_update_multi_partial_days_data(self):
        market_minutes = 1440 # 5min data
        store = FiveMinute(h5py.File('%s/data.h5' % helper.datadir),
                           market_minutes)

# Path: datafeed/exchange.py
# class SH(StockExchange):
#     name = 'Shanghai Stock Exchange'
#     currency = ('¥', 'CNY')
#     timezone = 'Asia/Shanghai'
#     _pre_market_session = ((9, 15), (9, 25))
#     _market_session = ((9, 30), (15, 0))
#     _market_break_session = ((11, 30), (13, 0))
# 
#     # Daily minute data count.
#     market_minutes = 242
# 
# Path: datafeed/tests/helper.py
# def sample_key():
# def sample():
# def sample_minutes():


# Path: datafeed/tests/test_datastore.py
import h5py
import os
import re
import time
import unittest
import numpy as np
    import shutil
from datetime import datetime
from mock import Mock, patch
from datafeed.exchange import SH
from datafeed.datastore import *
from datafeed.tests import helper


        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x)

    def test_update_multi_days(self):
        key = 'SH000001'
        x = np.array([
                (1316501700, 3130.8701171875, 3137.739990234375, 3128.81005859375,
                 3132.580078125, 30530.0, 20179424.0),
                (1316502000, 3132.68994140625, 3142.75, 3129.8798828125,
                 3141.5400390625, 57703.0, 41456768.0),
                (1316588100, 3210.860107421875, 3215.239990234375, 3208.43994140625,
                 3212.919921875, 62756.0, 49122656.0),
                (1316588400, 3213.43994140625, 3214.47998046875, 3206.800048828125,
                 3206.840087890625, 81252.0, 55866096.0)
                ], dtype=FiveMinute.DTYPE)
        self.store.update(key, x)

        date = datetime.fromtimestamp(1316501700).date()
        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x[:2])

        date = datetime.fromtimestamp(1316588400).date()
        y = self.store.get(key, date)
        np.testing.assert_array_equal(y, x[2:])

    def test_update_multi_partial_days_data(self):
        market_minutes = 1440 # 5min data
        store = FiveMinute(h5py.File('%s/data.h5' % helper.datadir),
                           market_minutes)

        self.assertEqual(store.time_interval, 300)