Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dakimura/jsmarketstore
Unofficial Node.js driver for marketstore
https://github.com/dakimura/jsmarketstore
alpaca analysis javascript marketstore node nodejs npm timeseries timeseries-analysis typescript
Last synced: about 1 month ago
JSON representation
Unofficial Node.js driver for marketstore
- Host: GitHub
- URL: https://github.com/dakimura/jsmarketstore
- Owner: dakimura
- License: apache-2.0
- Created: 2021-02-13T01:02:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-28T08:31:12.000Z (over 3 years ago)
- Last Synced: 2024-10-06T17:35:29.361Z (about 1 month ago)
- Topics: alpaca, analysis, javascript, marketstore, node, nodejs, npm, timeseries, timeseries-analysis, typescript
- Language: TypeScript
- Homepage:
- Size: 147 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsmarketstore
Unofficial client library for [marketstore](https://github.com/alpacahq/marketstore).## Install
```
npm install jsmarketstore
```## Usage
Assume that the marketstore server is running on your localhost, and listening 5993 port.
```typescript
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) => {
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)
})
```