Skip to main content

No project description provided

Project description

GCP time series

codecov

Requirements

  • Python 3.10+

Installation

pip install gcpts

Test

poetry run pytest -s -vv

Usage

import gcpts
import pandas as pd
import numpy as np



gcpts_client = gcpts.GCPTS(
    project_id="example_project", 
    dataset_id="example_dataset"
)

# Prepare example data, your data need to have 3 columns named symbol, dt, partition_dt
df = pd.DataFrame(np.random.randn(5000, 4))

df.columns = ['open', 'high', 'low', 'close']

# symbol represent a group of data for given data columns
df['symbol'] = 'BTCUSDT'

# timestamp should be UTC timezone but without tz info
df['dt'] = pd.date_range('2022-01-01', '2022-05-01', freq='15Min')[:5000]

# partition_dt must be date, data will be updated partition by partition with use of this column.
# Every time, you have to upload all the data for a given partition_dt, otherwise older will be gone.
df['partition_dt'] = df['dt'].dt.date.map(lambda x: x.replace(day=1))

gcpts_client.upload(table_name='example_table', df=df)
# Query for raw data.
raw_clsoe = gcpts_client.query(
    table_name='example_table',
    field='close',
    start_dt='2022-02-01 00:00:00', # yyyy-mm-dd HH:MM:SS, inclusive
    end_dt='2022-02-05 23:59:59', # yyyy-mm-dd HH:MM:SS, inclusive
    symbols=['BTCUSDT'],
)

# Query for raw data with resampling
resampeld_daily_close = gcpts_client.resample_query(
    table_name='example_table',
    field='close',
    start_dt='2022-01-01 00:00:00', # yyyy-mm-dd HH:MM:SS, inclusive
    end_dt='2022-01-31 23:59:59', # yyyy-mm-dd HH:MM:SS, inclusive
    symbols=['BTCUSDT'],
    interval='day', # month | week | day | hour | {1,2,3,4,6,8,12}hour | minute | {5,15,30}minute
    op='last', # last | first | min | max | sum
)

Disclaimer

This allows you to have SQL injection. Please use it for your own purpose only and do not allow putting arbitrary requests to this library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcpts-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

gcpts-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file gcpts-0.1.2.tar.gz.

File metadata

  • Download URL: gcpts-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-1034-azure

File hashes

Hashes for gcpts-0.1.2.tar.gz
Algorithm Hash digest
SHA256 01cc04fad7f3d5184ed7437d20c1b8a3aee34fd7e8a5ad06814f50c0dde97b7a
MD5 fc139be66ebba14ff06b285be2464f88
BLAKE2b-256 46199ae78248b339055b6df19eada3da65a471526034e053dcd5873028d45257

See more details on using hashes here.

File details

Details for the file gcpts-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gcpts-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-1034-azure

File hashes

Hashes for gcpts-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e57eeb7112cd440394896105916580d260a29fcda59d6d49be377f90e192eb3d
MD5 b839251660a995c3704f4694f9eaaf86
BLAKE2b-256 f01558da13577fb999dbaf44ae140eb51dbe13cc98076e3ce2a0a68f4b115dc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page