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

fix: update date range specification #698

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading