Tick
A Tick
represent the value of an Epic at a given point in time.
Minimal usage
The following example show the minimal usage of a Tick
.
from datetime import datetime, timezone
from estrade import Tick
def test_tick_nominal():
now = datetime.now(tz=timezone.utc)
tick = Tick(datetime=now, bid=99, ask=101)
assert tick.bid == 99
assert tick.ask == 101
assert tick.datetime == now
Timezone Management
A Tick
instance takes a time-zoned datetime as input.
Note
Internaly, Estrade uses the Arrow module to handle datetime conversions.
import arrow
from estrade import Tick
def test_tick_timezone():
now_tokyo = arrow.now("Asia/Tokyo")
tick = Tick(datetime=now_tokyo, bid=99, ask=101)
assert tick.datetime == now_tokyo
assert tick.datetime_utc == now_tokyo.to("UTC")
Meta data
A Tick
can optionnaly hold meta information.
import arrow
from estrade import Tick
def test_tick_meta():
now = arrow.utcnow()
tick = Tick(datetime=now, bid=99, ask=101, meta={"test": "test"})
assert tick.meta == {"test": "test"}
Value
A Tick
value represents the value between bid and ask.
import arrow
from estrade import Tick
def test_tick_value():
now = arrow.utcnow()
tick = Tick(datetime=now, bid=99, ask=101)
assert tick.value == 100
Spread
A Tick
spread represents the difference between its bid and ask
value.
import arrow
from estrade import Tick
def test_tick_spread():
now = arrow.utcnow()
tick = Tick(datetime=now, bid=99, ask=101)
assert tick.spread == 2