Skip to content

Commit

Permalink
fix: update date range specification (#698)
Browse files Browse the repository at this point in the history
* fix: update date range specification

* chore: run black linter
  • Loading branch information
cdummett authored Aug 30, 2024
1 parent 7cbe2f4 commit 5b81bfe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion vega_query/scripts/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import vega_protos.protos as protos
from vega_query.service.service import Service
from vega_query.service.networks.constants import Network
from scripts.parser import PARSER
from vega_query.scripts.parser import PARSER

if __name__ == "__main__":
# Enrich parser with script specific options
Expand Down
2 changes: 1 addition & 1 deletion vega_query/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def timestamp_to_datetime(ts: int, nano: bool = True):
if nano:
ts = ts / 1e9
return datetime.datetime.fromtimestamp(ts)
return datetime.datetime.fromtimestamp(ts, tz=datetime.timezone.utc)


def datetime_to_timestamp(dt: datetime.datetime, nano: bool = True) -> int:
Expand Down
14 changes: 7 additions & 7 deletions vega_query/visualisations/plots/amm.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def create(
# Default timestamps for getting data if required
network_timestamp = service.api.data.get_vega_time()
start_timestamp = (
market.market_timestamps.proposed if start_timestamp is None else None
market.market_timestamps.proposed
if start_timestamp is None
else start_timestamp
)
end_timestamp = network_timestamp if end_timestamp is None else None
end_timestamp = network_timestamp if end_timestamp is None else end_timestamp

# Get market specific information
market_data_history = service.api.data.get_market_data_history_by_id(
Expand Down Expand Up @@ -156,7 +158,7 @@ def create(

if __name__ == "__main__":

from scripts.parser import PARSER
from vega_query.scripts.parser import PARSER

args = PARSER.parse_args()

Expand Down Expand Up @@ -188,14 +190,12 @@ def create(
service,
market_code=args.market,
start_timestamp=(
timestamp_to_datetime(args.start_time, nano=True)
int(args.start_time.timestamp() * 1e9)
if args.start_time is not None
else None
),
end_timestamp=(
timestamp_to_datetime(args.end_time, nano=True)
if args.end_time is not None
else None
int(args.end_time.timestamp() * 1e9) if args.end_time is not None else None
),
)
plt.show()
14 changes: 7 additions & 7 deletions vega_query/visualisations/plots/sla.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def create(
# Default timestamps for getting data if required
network_timestamp = service.api.data.get_vega_time()
start_timestamp = (
market.market_timestamps.proposed if start_timestamp is None else None
market.market_timestamps.proposed
if start_timestamp is None
else start_timestamp
)
end_timestamp = network_timestamp if end_timestamp is None else None
end_timestamp = network_timestamp if end_timestamp is None else end_timestamp

# Get market specific information
market_data_history = service.api.data.get_market_data_history_by_id(
Expand Down Expand Up @@ -155,7 +157,7 @@ def create(

if __name__ == "__main__":

from scripts.parser import PARSER
from vega_query.scripts.parser import PARSER

args = PARSER.parse_args()

Expand Down Expand Up @@ -187,14 +189,12 @@ def create(
service,
market_code=args.market,
start_timestamp=(
timestamp_to_datetime(args.start_time, nano=True)
int(args.start_time.timestamp() * 1e9)
if args.start_time is not None
else None
),
end_timestamp=(
timestamp_to_datetime(args.end_time, nano=True)
if args.end_time is not None
else None
int(args.end_time.timestamp() * 1e9) if args.end_time is not None else None
),
)
plt.show()

0 comments on commit 5b81bfe

Please sign in to comment.