Example #1
0
def test_write(MsgpackRpcClient):
    c = pymkts.Client()
    data = np.array([(1, 0)], dtype=[('Epoch', 'i8'), ('Ask', 'f4')])
    tbk = 'TEST/1Min/TICK'
    c.write(data, tbk)
    assert MsgpackRpcClient().call.called == 1
Example #2
0
def test_list_symbols(MsgpackRpcClient):
    c = pymkts.Client()
    c.list_symbols()
    assert MsgpackRpcClient().call.called == 1
Example #3
0
def test_client_init():
    c = pymkts.Client("http://127.0.0.1:5994/rpc")
    assert c.endpoint == "http://127.0.0.1:5994/rpc"
    assert isinstance(c.rpc, pymkts.client.MsgpackRpcClient)
Example #4
0
def test_query(MsgpackRpcClient):
    c = pymkts.Client()
    p = pymkts.Params('BTC', '1Min', 'OHLCV')
    c.query(p)
    assert MsgpackRpcClient().call.called == 1
Example #5
0
"""
STATUS:OK
NOTE:returns empty dataframe in periods when there is no data. 
TODO: improve exception when the symbol does not exist
MIGRATION_STATUS:OK
"""
import pytest

import numpy as np
import pandas as pd
import os
import pymarketstore as pymkts
from . import utils

client = pymkts.Client(
    f"http://127.0.0.1:{os.getenv('MARKETSTORE_PORT',5993)}/rpc",
    grpc=(os.getenv("USE_GRPC", "false") == "true"))


@pytest.mark.parametrize(
    "symbol, timeframe, data, index, nanoseconds, start, end",
    [
        ################################################################################
        # 1Min timeframe
        ################################################################################
        (
            # query before 1st timeframe and different year
            "VA_TEST_1",
            "1Min",
            dict(Bid=np.arange(2), Ask=np.arange(2)),
            ["2016-01-01 10:01:00", "2016-01-01 10:02:00"],
Example #6
0
def test_destroy(MsgpackRpcClient):
    c = pymkts.Client()
    tbk = 'TEST/1Min/TICK'
    c.destroy(tbk)
    assert MsgpackRpcClient().call.called == 1
Example #7
0
 def __init__(self, config):
     host = config.MARKETSTORE_RPC_HOST
     port = config.MARKETSTORE_RPC_PORT
     path = config.MARKETSTORE_RPC_PATH
     self.client = pymkts.Client(endpoint=f'http://{host}:{port}{path}')
"""
import pytest
import random
import numpy as np
import pandas as pd
from subprocess import run, PIPE
import time
import os
import pymarketstore as pymkts
import pathlib
from . import utils
from shutil import which


use_grpc = os.getenv("USE_GRPC", "false") == "true"
client = pymkts.Client(f"http://127.0.0.1:{os.getenv('MARKETSTORE_PORT',5993)}/rpc",
                       grpc=(use_grpc))

pathlib.Path("/tmp/test_intermediate_data").mkdir(exist_ok=True)


@pytest.mark.parametrize(
    "symbol,timeframe,size,start,window",
    [
        ("PYW_TEST_01VA", "1Min", 400, "2016-01-01 10:00:00", "5s"),
        ("PYW_TEST_02VA", "1Min", 800, "2016-01-01 10:00:00", "5s"),
        ("PYW_TEST_03VA", "1Sec", 400, "2016-01-01 10:00:00", "5s"),
        ("PYW_TEST_04VA", "1Sec", 800, "2016-01-01 10:00:00", "5s"),
        # ("PYW_TEST_05VB", "1Min", 50000, "2016-01-01 10:00:00", "4H"),
        # ("PYW_TEST_06VB", "1Min", 100_000, "2016-01-01 10:00:00", "4H"),
        # ("PYW_TEST_07VB", "1Min", 500_000, "2016-01-01 10:00:00", "4H"),
        # ("PYW_TEST_08VB", "1Min", 1_000_000, "2016-01-01 10:00:00", "4H"),
import pytest

import numpy as np
import pandas as pd

import pymarketstore as pymkts

# Constants
DATA_TYPE_TICK = [('Epoch', 'i8'), ('Bid', 'f4'), ('Ask', 'f4'),
                  ('Nanoseconds', 'i4')]
DATA_TYPE_CANDLE = [('Epoch', 'i8'), ('Open', 'f8'), ('High', 'f8'),
                    ('Low', 'f8'), ('Close', 'f8'), ('Volume', 'f8')]
MARKETSTORE_HOST = "localhost"
MARKETSTORE_PORT = 5993

client = pymkts.Client('http://localhost:5993/rpc')


def timestamp(datestr):
    return int(pd.Timestamp(datestr).value / 10**9)


@pytest.mark.parametrize(
    'symbol, data',
    [
        (
            'TEST_SIMPLE_TICK',
            [
                (timestamp('2019-01-01 00:00:00'), 1, 2,
                 3),  # epoch, ask, bid, nanosecond
                (timestamp('2019-01-01 00:00:01'), 4, 5, 6),
Example #10
0
def test_create(MsgpackRpcClient):
    c = pymkts.Client()
    dtype = [('Epoch', 'i8'), ('Bid', 'f4'), ('Ask', 'f4')]
    tbk = 'TEST/1Min/TICK'
    c.create(tbk=tbk, dtype=dtype, isvariablelength=False)
    assert MsgpackRpcClient().call.called == 1
Example #11
0
def test_sql(MsgpackRpcClient):
    c = pymkts.Client()
    s = "SELECT * FROM `BTC/1Min/OHLCV`"
    c.sql(s)
    assert MsgpackRpcClient().call.called == 1
Example #12
0
 def __init__(self, url: str):
     self._client = pymkts.Client(url)
Example #13
0
import pymarketstore as pymkts

client = pymkts.Client(endpoint='http://localhost:5993/rpc')


def test_not_empty_database():
    """Test if the database is empty
    """
    symbols = client.list_symbols()
    assert symbols is not None