Coder Social home page Coder Social logo

dakimura / jsmarketstore Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 151 KB

Unofficial Node.js driver for marketstore

License: Apache License 2.0

JavaScript 7.77% Shell 4.36% TypeScript 87.87%
alpaca marketstore nodejs node javascript typescript timeseries analysis timeseries-analysis npm

jsmarketstore's Introduction

jsmarketstore

Unofficial client library for marketstore.

Install

npm install jsmarketstore

Usage

Assume that the marketstore server is running on your localhost, and listening 5993 port.

import {Client, Column, DataType, ListSymbolsFormat, Params} from "jsmarketstore";

const cli = new Client('http://localhost:5993/rpc')
const symbol = 'TEST'
const timeframe = '1Sec'
const attributeGroup = 'Tick'
const tbk: string = symbol + '/' + timeframe + '/' + attributeGroup

// write data -> list symbols -> query data -> delete the data
cli
    .write(
        [
            ['Epoch', DataType.INT64],
            ['Bid', DataType.FLOAT32],
            ['Ask', DataType.FLOAT32],
        ],
        [
            [Date.parse('2021-03-08 00:00:00') / 1000, 10.0, 20.0],
            [Date.parse('2021-03-09 00:00:00') / 1000, 30.0, 40.0],
        ],
        tbk,
        true,
    )
    .catch((reason: any) => {
        console.log("failed to write data:" + reason)
    })
    .then(() => {
        console.log('write data to ' + tbk + '.')
        return cli.listSymbols(ListSymbolsFormat.Symbol)
    })
    .catch((reason: any) => {
        console.log("failed to list symbols:" + reason)
    })
    .then((symbols: string[]) => {
        console.log('list symbols:')
        console.log(symbols)
        const params: Params = new Params(symbols[0], timeframe, attributeGroup)
        return cli.query(params)
    })
    .catch((reason: any) => {
        console.log("failed to query data:" + reason)
    })
    .then((response: Map<number, Column>) => {
        console.log('query ' + tbk + ':')
        console.log(response)
        return cli.destroy(tbk)
    })
    .catch((reason: any) => {
        console.log("failed to destroy bucket:" + reason)
    })
    .then(() => {
        console.log('destroyed:' + tbk)
    })

jsmarketstore's People

Contributors

dakimura avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.