Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Timeseries #10

Open
cvauclair opened this issue Jan 23, 2022 · 0 comments
Open

Timeseries #10

cvauclair opened this issue Jan 23, 2022 · 0 comments
Labels
enhancement New feature or request in progress

Comments

@cvauclair
Copy link
Contributor

Description

Given a subgrounds fieldpath(s) representing a list of entities, then it should be possible to wrap those fieldpaths in a timeseries which would normalize the data according to time key, interval, aggregation method and interpolation method.

Supported intervals (to start):

  • hourly
  • daily
  • weekly
  • monthly

Supported aggregation methods:

  • mean
  • sum
  • first
  • last
  • median
  • min
  • max
  • count

Supported interpolation methods:

  • backward fill (use next value to fill in missing value)
  • forward fill (use previous value to fill in missing value)

Example

sg = Subgrounds()
uniswapV2 = sg.load_subgraph("https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2")

Swap.price0 = abs(Swap.amount1In - Swap.amount1Out) / abs(Swap.amount0In - Swap.amount0Out)
Swap.price1 = abs(Swap.amount0In - Swap.amount0Out) / abs(Swap.amount1In - Swap.amount1Out)

swaps = uniswapV2.Query.swaps(
  orderBy=Swap.timestamp,
  orderDirection='desc',
  first=500,
)

price0_hourly_close = Timeseries(
  x=swaps.timestamp,
  y=swaps.price0,
  interval='hour',
  aggregation='last',
  interpolation='ffill'
)
@cvauclair cvauclair added the enhancement New feature or request label Jan 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request in progress
Projects
None yet
Development

No branches or pull requests

1 participant