Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream processing classes #65

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ install:
- pip install nose nose-parameterized
- pip install wheel
- pip install twine
- pip install -r requirements.txt
script:
- coverage run --source=oandapyV20 setup.py test
after_success:
Expand Down
4 changes: 4 additions & 0 deletions data/test_candles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"start": "2017-02-23 20:57:00", "end": "2017-02-23 20:58:00", "instrument": "EUR_USD", "completed": true, "granularity": "M1", "data": {"high": 1.058025, "last": 1.05797, "open": 1.058, "low": 1.05795, "volume": 7}}
{"start": "2017-02-23 20:58:00", "end": "2017-02-23 20:59:00", "instrument": "EUR_USD", "completed": true, "granularity": "M1", "data": {"high": 1.0581, "last": 1.0581, "open": 1.05795, "low": 1.057945, "volume": 10}}
{"start": "2017-02-23 20:59:00", "end": "2017-02-23 21:00:00", "instrument": "EUR_USD", "completed": true, "granularity": "M1", "data": {"high": 1.058135, "last": 1.05809, "open": 1.05808, "low": 1.05808, "volume": 9}}
{"start": "2017-02-23 20:55:00", "end": "2017-02-23 21:00:00", "instrument": "EUR_USD", "completed": true, "granularity": "M5", "data": {"high": 1.058135, "last": 1.05809, "open": 1.058, "low": 1.057945, "volume": 26}}
49 changes: 49 additions & 0 deletions data/test_ticks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{"closeoutAsk": "1.05810", "tradeable": true, "time": "2017-02-23T20:57:21.215739156Z", "bids": [{"price": "1.05794", "liquidity": 10000000.0}, {"price": "1.05792", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05806", "liquidity": 10000000.0}, {"price": "1.05808", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05790"}
{"closeoutAsk": "1.05813", "tradeable": true, "time": "2017-02-23T20:57:24.457385032Z", "bids": [{"price": "1.05796", "liquidity": 10000000.0}, {"price": "1.05794", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05809", "liquidity": 10000000.0}, {"price": "1.05811", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05792"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:26.808326703Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:31.810600498Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:36.811805018Z"}
{"closeoutAsk": "1.05808", "tradeable": true, "time": "2017-02-23T20:57:39.977974604Z", "bids": [{"price": "1.05791", "liquidity": 10000000.0}, {"price": "1.05789", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05806", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05787"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:41.813826769Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:46.815729295Z"}
{"closeoutAsk": "1.05807", "tradeable": true, "time": "2017-02-23T20:57:49.458001652Z", "bids": [{"price": "1.05787", "liquidity": 10000000.0}, {"price": "1.05785", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05805", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05783"}
{"closeoutAsk": "1.05808", "tradeable": true, "time": "2017-02-23T20:57:49.915015680Z", "bids": [{"price": "1.05790", "liquidity": 10000000.0}, {"price": "1.05788", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05806", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05786"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:51.816284840Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:57:56.816956614Z"}
{"closeoutAsk": "1.05806", "tradeable": true, "time": "2017-02-23T20:57:58.427895819Z", "bids": [{"price": "1.05788", "liquidity": 10000000.0}, {"price": "1.05786", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05802", "liquidity": 10000000.0}, {"price": "1.05804", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05784"}
{"closeoutAsk": "1.05808", "tradeable": true, "time": "2017-02-23T20:57:59.518152944Z", "bids": [{"price": "1.05790", "liquidity": 10000000.0}, {"price": "1.05788", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05806", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05786"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:01.818672862Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:06.820374141Z"}
{"closeoutAsk": "1.05806", "tradeable": true, "time": "2017-02-23T20:58:10.355035547Z", "bids": [{"price": "1.05788", "liquidity": 10000000.0}, {"price": "1.05786", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05802", "liquidity": 10000000.0}, {"price": "1.05804", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05784"}
{"closeoutAsk": "1.05807", "tradeable": true, "time": "2017-02-23T20:58:10.570844273Z", "bids": [{"price": "1.05791", "liquidity": 10000000.0}, {"price": "1.05789", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05805", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05787"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:11.820728640Z"}
{"closeoutAsk": "1.05805", "tradeable": true, "time": "2017-02-23T20:58:15.214841058Z", "bids": [{"price": "1.05788", "liquidity": 10000000.0}, {"price": "1.05786", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05801", "liquidity": 10000000.0}, {"price": "1.05803", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05784"}
{"closeoutAsk": "1.05807", "tradeable": true, "time": "2017-02-23T20:58:16.495705506Z", "bids": [{"price": "1.05790", "liquidity": 10000000.0}, {"price": "1.05788", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05805", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05786"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:16.821594110Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:21.822895185Z"}
{"closeoutAsk": "1.05809", "tradeable": true, "time": "2017-02-23T20:58:23.661598690Z", "bids": [{"price": "1.05793", "liquidity": 10000000.0}, {"price": "1.05791", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05805", "liquidity": 10000000.0}, {"price": "1.05807", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05789"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:26.823965875Z"}
{"closeoutAsk": "1.05812", "tradeable": true, "time": "2017-02-23T20:58:29.762885717Z", "bids": [{"price": "1.05795", "liquidity": 10000000.0}, {"price": "1.05793", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05808", "liquidity": 10000000.0}, {"price": "1.05810", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05791"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:31.825841986Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:36.827523278Z"}
{"closeoutAsk": "1.05814", "tradeable": true, "time": "2017-02-23T20:58:37.431571020Z", "bids": [{"price": "1.05798", "liquidity": 10000000.0}, {"price": "1.05796", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05810", "liquidity": 10000000.0}, {"price": "1.05812", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05794"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:41.828878492Z"}
{"closeoutAsk": "1.05815", "tradeable": true, "time": "2017-02-23T20:58:45.569019853Z", "bids": [{"price": "1.05798", "liquidity": 10000000.0}, {"price": "1.05796", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05811", "liquidity": 10000000.0}, {"price": "1.05813", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05794"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:46.830751934Z"}
{"closeoutAsk": "1.05818", "tradeable": true, "time": "2017-02-23T20:58:51.167909875Z", "bids": [{"price": "1.05800", "liquidity": 10000000.0}, {"price": "1.05798", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05814", "liquidity": 10000000.0}, {"price": "1.05816", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05796"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:51.831859153Z"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:58:56.832638290Z"}
{"closeoutAsk": "1.05821", "tradeable": true, "time": "2017-02-23T20:58:59.711800988Z", "bids": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05801", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05817", "liquidity": 10000000.0}, {"price": "1.05819", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05799"}
{"closeoutAsk": "1.05819", "tradeable": true, "time": "2017-02-23T20:59:00.017229666Z", "bids": [{"price": "1.05801", "liquidity": 10000000.0}, {"price": "1.05799", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05815", "liquidity": 10000000.0}, {"price": "1.05817", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05797"}
{"closeoutAsk": "1.05821", "tradeable": true, "time": "2017-02-23T20:59:00.103236576Z", "bids": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05802", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05817", "liquidity": 10000000.0}, {"price": "1.05819", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05800"}
{"closeoutAsk": "1.05819", "tradeable": true, "time": "2017-02-23T20:59:00.579467914Z", "bids": [{"price": "1.05801", "liquidity": 10000000.0}, {"price": "1.05799", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05815", "liquidity": 10000000.0}, {"price": "1.05817", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05797"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:59:01.834708747Z"}
{"closeoutAsk": "1.05821", "tradeable": true, "time": "2017-02-23T20:59:02.237279830Z", "bids": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05802", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05817", "liquidity": 10000000.0}, {"price": "1.05819", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05800"}
{"closeoutAsk": "1.05819", "tradeable": true, "time": "2017-02-23T20:59:03.480120327Z", "bids": [{"price": "1.05802", "liquidity": 10000000.0}, {"price": "1.05800", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05815", "liquidity": 10000000.0}, {"price": "1.05817", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05798"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:59:06.835872651Z"}
{"closeoutAsk": "1.05821", "tradeable": true, "time": "2017-02-23T20:59:10.735088955Z", "bids": [{"price": "1.05804", "liquidity": 10000000.0}, {"price": "1.05802", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05817", "liquidity": 10000000.0}, {"price": "1.05819", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05800"}
{"type": "HEARTBEAT", "time": "2017-02-23T20:59:11.836927792Z"}
{"closeoutAsk": "1.05824", "tradeable": true, "time": "2017-02-23T20:59:13.591157263Z", "bids": [{"price": "1.05807", "liquidity": 10000000.0}, {"price": "1.05805", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05820", "liquidity": 10000000.0}, {"price": "1.05822", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05803"}
{"closeoutAsk": "1.05822", "tradeable": true, "time": "2017-02-23T20:59:14.122295678Z", "bids": [{"price": "1.05805", "liquidity": 10000000.0}, {"price": "1.05803", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05818", "liquidity": 10000000.0}, {"price": "1.05820", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05801"}
{"closeoutAsk": "1.05819", "tradeable": true, "time": "2017-02-23T20:59:14.533954931Z", "bids": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05801", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05815", "liquidity": 10000000.0}, {"price": "1.05817", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05799"}
{"closeoutAsk": "1.05819", "tradeable": true, "time": "2017-02-23T21:00:14.533954931Z", "bids": [{"price": "1.05803", "liquidity": 10000000.0}, {"price": "1.05801", "liquidity": 10000000.0}], "instrument": "EUR_USD", "asks": [{"price": "1.05815", "liquidity": 10000000.0}, {"price": "1.05817", "liquidity": 10000000.0}], "status": "tradeable", "type": "PRICE", "closeoutBid": "1.05799"}
6 changes: 6 additions & 0 deletions oandapyV20/contrib/stream/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from oandapyV20.contrib.stream.candlefactory import (
CandleFactory,
granularity_to_time
)
from oandapyV20.contrib.stream.streamrecord import *
Loading