Funtime - Funguana's Time-series database library for your trading bot
Funtime is a mongodb based time series library. It was created because we ran into the problem of inputting data that may have its schema change and querying it quickly.
We found arctic to be a good library, yet it lacked straightforward pythonic querying methods. We added a layer on top for our own purposes.
Both funtime and arctic use mongodb as the main database
What makes Funtime better?
The single thing that makes funtime better for timeseries information is that it has more clear querying methods. It should be noted that it still has arctic as the foundation. Meaning the speed of it is extremely fast. This works a lot like tickstore, yet it's easier to get your hands on and use than tickstore
It is a layer on time of arctic. We added the following:
- An easy way to add and filter data with a given timestamp/datetime
- Easy conversions to both a
pandasanddaskdataframe - A choice to get information by a filtration type. This allows the user to be highly flexible with how they want to get information
Window- A window query is a query that gets information two dates. They must be valid.Before- Gets every record before a certain timeAfter- Gets every record after a certain time
How does it work?
All forms of time data is stored as a epoch timestamp. This is to make querying easier and faster than if we were to use a full datetime object. We do conversions within the library from datetime objects into epoch timestamps.
This increases the insert time, yet reduces the querying time. Numbers are easier to filter than date objects. The biggetst tradeoff is in ease of use.
Example:
from funtime import Store, Converter
import mimesis # this is used to seed data for our test
import time
# Create a library and access the store you want
store = Store('localhost').create_lib("hello.World").get_store()
# store the data with a timestamp
store['hello.World'].store({
"type": "price",
"currency": "ETH_USD",
"timestamp": time.time(),
"candlestick": {
"open": 1234,
"close": 1234.41,
"other": "etc"
}
})
# Query general information. It returns a generator
runs = store['hello.World'].query({
"type": "price"
})
# Check for results
for r in runs:
print(r)
# Even get information with complex time queries
runs2 = store['hello.World'].query_time(time_type="before", start=time.time(), query_type="price")
# Check for results
for r in runs:
print(r)
To change default store and host
from funtime import set_library_type, set_mongo_host
# Run before you run everything else
set_library_type()
# Run before you run everything else
set_mongo_host()
Using the Pandas/Dask converter
As a data scientist, you may want to handle your data in dataframe format. With funtime, you can get your timestamp information in both pandas.DataFrame and dask.DataFrame format. You would use the Converter import.
from funtime import Store, Converter
runs = store['hello.World'].query({
"type": "price"
})
# if you want a pandas object
df = Converter.to_dataframe(runs)
# If you want to do parallel processing within dask
ddf = Converter.to_dataframe(runs, "dask")
How to install
Make sure to install mongodb at the very beginning. The instructions are different for different operating systems. Then run:
pip install funtime
Or you can use pipenv for it:
pipenv install funtime
Release files for funtime 0.4.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| funtime-0.4.7.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| funtime-0.4.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.9 kB
Release files / funtime-0.4.7.tar.gz
| Download URL | funtime-0.4.7.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53448df93ff0fc5aa60cd82593e5c28eca51d4b7fde7a067174579830af663bf
|
|
BLAKE2b-256 checksum How to use checksums |
4e656ab1df90a2b9c83b3edcc843a0066bd5dd8126c2a145301de7255c49f640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.7
|
Release files / funtime-0.4.7-py3-none-any.whl
| Download URL | funtime-0.4.7-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c95737735367fee68fb26d65a4ed0d4e6f4053f2c4eba566a0353ab56173ac54
|
|
BLAKE2b-256 checksum How to use checksums |
8a5d3adc20abf3197b07345d696cc2db19870ea9503daf97a49aee7f094336a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.7
|