OpenTick SDK
Project description
# OpenTick
![OpenTrade Logo](https://github.com/opentradesolutions/opentrade/blob/master/web/img/ot.png)
OpenTick is a fast tick database for financial timeseries data, built on [FoundationDB](https://www.foundationdb.org/) with simplified SQL layer.
# Features:
* Built-in price adjustment support
* Nanosecond support
* Python, C++ and Go SDK
* Both sync and async query
* Implicit SQL statement prepare
# Installation on Ubuntu
You need to use **Go >=1.11** which has module support.
```bash
sudo apt install -y python
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-server_6.0.18-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-clients_6.0.18-1_amd64.deb
sudo dpkg -i foundationdb-clients_6.0.18-1_amd64.deb foundationdb-server_6.0.18-1_amd64.deb
git clone https://github.com/opentradesolutions/opentick
make build
sudo apt install nodejs
sudo npm install -g pm2
pm2 start ./opentick
```
**Note:** FoundationDB runs in memory storage mode and only one process by default. You can change it to disk storage as belows:
```bash
user@host$ fdbcli
fdb> configure ssd
```
Fore more configuration on FoundationDB, please check [FoundationDB Configuration](https://apple.github.io/foundationdb/configuration.html)
# Usage
[Python](https://github.com/opentradesolutions/opentick/blob/master/bindings/python/test.py)
[C++](https://github.com/opentradesolutions/opentick/blob/master/bindings/cpp/test.cc)
[Go](https://github.com/opentradesolutions/opentick/blob/master/bindings/go/test.go)
# Performance
100k ohlcv bar inserted in 1 second.
```bash
user@host:~/opentick/bindings/go$ go run test.go
2018/11/27 21:27:23 4.500470184s 5.500314708s 0 100000 all insert futures get done
2018/11/27 21:27:25 861.306778ms 1.139363333s 0 10 all batch insert futures get done
2018/11/27 21:27:26 805.542584ms 100000 retrieved with ranges
2018/11/27 21:27:27 1.782497936s 100000 retrieved with async
2018/11/27 21:27:29 1.424262818s 100000 retrieved with one sync
```
```bash
user@host:~/opentick/bindings/python$ ./test.py
2018-11-27 21:29:10.168138 0:00:00.200577 0:00:06.724991 0 100000 all insert futures get done
2018-11-27 21:29:12.192570 0:00:00.176540 0:00:00.959563 0 10 all batch insert futures get done
2018-11-27 21:29:13.460025 0:00:01.267462 100000 retrieved with ranges
2018-11-27 21:29:15.077686 0:00:01.617666 100000 retrieved with async
2018-11-27 21:29:16.777043 0:00:01.699361 100000 retrieved with one sync
```
```bash
user@host:~/opentick/bindings/cpp$ make test
21:33:19.231156889: 4.22207s 4.84954s 0 100000 all insert futures get done
21:33:20.172744180: 0.447708s 0.934337s 0 10 all batch insert futures get done
21:33:21.677161076: 1.49497s 100000 retrieved with async
```
# Sample Code (C++)
* **Create database and table**
```C++
auto conn = Connection::Create("127.0.0.1", 1116);
conn->Start();
conn->Execute("create database if not exists test");
conn->Use("test");
conn->Execute(R"(
create table if not exists test(sec int, interval int, tm timestamp,
open double, high double, low double, close double, v double, vwap
double, primary key(sec, interval, tm))
)");
```
* **Execute**
```C++
// opentick prepares the sql statement automatically, no need to prepare explicitly
auto fut = conn->ExecuteAsync(
"select * from test where sec=1 and interval=?", Args{1}));
auto res = fut->Get(); // blocked wait until execution done
// Get last 2 rows ordering by primary key
auto res = conn->Execute(
"select tm from test where sec=1 and interval=? limit -2", Args{1});
```
* **Insert**
```C++
static const std::string kInsert =
"insert into test(sec, interval, tm, open, high, low, close, vol, vwap) "
"values(?, ?, ?, ?, ?, ?, ?, ?, ?)";
std::vector<Future> futs;
for (auto i = 0; i < 1000; ++i) {
futs.push_back(conn->ExecuteAsync(kInsert, Args{1, 1, system_clock::now(), 2.2, 2.4, 2.1, 2.3, 1000000, 2.25}));
}
// wait for all insertion done
for (auto fut : futs) fut->Get();
```
* **Batch Insert**
```C++
Argss argss;
for (auto i = 0; i < 1000; ++i) {
argss.push_back(Args{1, i, system_clock::now(), 2.2, 2.4, 2.1, 2.3, 1000000, 2.25});
}
conn->BatchInsert(kInsert, argss);
```
* **Price Adjustments**
```C++
auto res = conn->Execute(
"select tm, adj(open), adj(high), adj(low), adj(close), adj(vol) from test where sec=1 and interval=? limit -2", Args{1});
```
For more details, please checkout [adj_test.go](https://github.com/opentradesolutions/opentick/blob/master/adj_test.go)
![OpenTrade Logo](https://github.com/opentradesolutions/opentrade/blob/master/web/img/ot.png)
OpenTick is a fast tick database for financial timeseries data, built on [FoundationDB](https://www.foundationdb.org/) with simplified SQL layer.
# Features:
* Built-in price adjustment support
* Nanosecond support
* Python, C++ and Go SDK
* Both sync and async query
* Implicit SQL statement prepare
# Installation on Ubuntu
You need to use **Go >=1.11** which has module support.
```bash
sudo apt install -y python
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-server_6.0.18-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-clients_6.0.18-1_amd64.deb
sudo dpkg -i foundationdb-clients_6.0.18-1_amd64.deb foundationdb-server_6.0.18-1_amd64.deb
git clone https://github.com/opentradesolutions/opentick
make build
sudo apt install nodejs
sudo npm install -g pm2
pm2 start ./opentick
```
**Note:** FoundationDB runs in memory storage mode and only one process by default. You can change it to disk storage as belows:
```bash
user@host$ fdbcli
fdb> configure ssd
```
Fore more configuration on FoundationDB, please check [FoundationDB Configuration](https://apple.github.io/foundationdb/configuration.html)
# Usage
[Python](https://github.com/opentradesolutions/opentick/blob/master/bindings/python/test.py)
[C++](https://github.com/opentradesolutions/opentick/blob/master/bindings/cpp/test.cc)
[Go](https://github.com/opentradesolutions/opentick/blob/master/bindings/go/test.go)
# Performance
100k ohlcv bar inserted in 1 second.
```bash
user@host:~/opentick/bindings/go$ go run test.go
2018/11/27 21:27:23 4.500470184s 5.500314708s 0 100000 all insert futures get done
2018/11/27 21:27:25 861.306778ms 1.139363333s 0 10 all batch insert futures get done
2018/11/27 21:27:26 805.542584ms 100000 retrieved with ranges
2018/11/27 21:27:27 1.782497936s 100000 retrieved with async
2018/11/27 21:27:29 1.424262818s 100000 retrieved with one sync
```
```bash
user@host:~/opentick/bindings/python$ ./test.py
2018-11-27 21:29:10.168138 0:00:00.200577 0:00:06.724991 0 100000 all insert futures get done
2018-11-27 21:29:12.192570 0:00:00.176540 0:00:00.959563 0 10 all batch insert futures get done
2018-11-27 21:29:13.460025 0:00:01.267462 100000 retrieved with ranges
2018-11-27 21:29:15.077686 0:00:01.617666 100000 retrieved with async
2018-11-27 21:29:16.777043 0:00:01.699361 100000 retrieved with one sync
```
```bash
user@host:~/opentick/bindings/cpp$ make test
21:33:19.231156889: 4.22207s 4.84954s 0 100000 all insert futures get done
21:33:20.172744180: 0.447708s 0.934337s 0 10 all batch insert futures get done
21:33:21.677161076: 1.49497s 100000 retrieved with async
```
# Sample Code (C++)
* **Create database and table**
```C++
auto conn = Connection::Create("127.0.0.1", 1116);
conn->Start();
conn->Execute("create database if not exists test");
conn->Use("test");
conn->Execute(R"(
create table if not exists test(sec int, interval int, tm timestamp,
open double, high double, low double, close double, v double, vwap
double, primary key(sec, interval, tm))
)");
```
* **Execute**
```C++
// opentick prepares the sql statement automatically, no need to prepare explicitly
auto fut = conn->ExecuteAsync(
"select * from test where sec=1 and interval=?", Args{1}));
auto res = fut->Get(); // blocked wait until execution done
// Get last 2 rows ordering by primary key
auto res = conn->Execute(
"select tm from test where sec=1 and interval=? limit -2", Args{1});
```
* **Insert**
```C++
static const std::string kInsert =
"insert into test(sec, interval, tm, open, high, low, close, vol, vwap) "
"values(?, ?, ?, ?, ?, ?, ?, ?, ?)";
std::vector<Future> futs;
for (auto i = 0; i < 1000; ++i) {
futs.push_back(conn->ExecuteAsync(kInsert, Args{1, 1, system_clock::now(), 2.2, 2.4, 2.1, 2.3, 1000000, 2.25}));
}
// wait for all insertion done
for (auto fut : futs) fut->Get();
```
* **Batch Insert**
```C++
Argss argss;
for (auto i = 0; i < 1000; ++i) {
argss.push_back(Args{1, i, system_clock::now(), 2.2, 2.4, 2.1, 2.3, 1000000, 2.25});
}
conn->BatchInsert(kInsert, argss);
```
* **Price Adjustments**
```C++
auto res = conn->Execute(
"select tm, adj(open), adj(high), adj(low), adj(close), adj(vol) from test where sec=1 and interval=? limit -2", Args{1});
```
For more details, please checkout [adj_test.go](https://github.com/opentradesolutions/opentick/blob/master/adj_test.go)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
opentick-1.0.1.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file opentick-1.0.1.tar.gz
.
File metadata
- Download URL: opentick-1.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/38.5.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0a6b1f1c9bc74c81b631bdf0de90f2544d503f57411f0f54fdce06d76791d0f |
|
MD5 | f14c8414cd7053720034aa8afebeb2c4 |
|
BLAKE2b-256 | 9ffc3e53955c9b06f44139f88d3fb4e9aab4d05a0dc0f1c162d5f622fdedb514 |
File details
Details for the file opentick-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: opentick-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/38.5.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c107fffabc1aab6f992205594e4cc9d916eeb3e461bc2119a3ab7c2d33fa08c |
|
MD5 | 8eba90fc03ca59e3a209f50f3c817783 |
|
BLAKE2b-256 | 61c719510b147c67e17811a2b84addbec19a77f7ae5b95ad64a6c486792fa923 |