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

Definition of '1 day' #24

Open
BrandonL20 opened this issue Feb 3, 2023 · 0 comments
Open

Definition of '1 day' #24

BrandonL20 opened this issue Feb 3, 2023 · 0 comments

Comments

@BrandonL20
Copy link
Collaborator

Currently, code computes '1 day' as longer than a day, and also assumes an open price equal to the last close price (which is technically fine, but I think it makes more sense to have open price be the start of the next day).

For example, the code starts out as follows:
Day 1 open: 2021-05-05 08:35:47+0000
Day 1 close: 2021-05-06 09:00:52+0000
Day 2 open: 2021-05-06 09:00:52+0000
Day 2 close: 2021-05-07 09:12:53+0000
...
Day 623 open: 2023-01-25 12:08:35+0000

Recommended changes:


startDay = t.replace(hour=0, minute=0, second=0)

" if (t-startDay).total_seconds()>=nSecs:\n",

if i+1 == len(timestamp30) or (timestamp30[i+1]-startDay).total_seconds()>=nSecs:

" startDay = t\n",
" startTick = ticks30[i]\n",
" startSqrtPrice = sqrtPrice30[i]\n",
" startPrice = sqrtPrice30[i]**2\n",
" startLiq = positionSize / (np.sqrt(startPrice) - np.sqrt(startPrice/r))\n",
" startX = X(startPrice, startPrice, r, startLiq)\n",
" startY = Y(startPrice, startPrice, r, startLiq)\n",
" positionRange = range(startTick - w, startTick + w) \n",

if i+1 < len(timestamp30):
    startDay = timestamp30[i+1].replace(hour=0, minute=0, second=0)
    startTick = ticks30[i+1]
    startSqrtPrice = sqrtPrice30[i+1]
    startPrice = sqrtPrice30[i+1]**2
    # print("time: ", t)
    startLiq = positionSize / (np.sqrt(startPrice) - np.sqrt(startPrice/r))
    startX = X(startPrice, startPrice, r, startLiq)
    startY = Y(startPrice, startPrice, r, startLiq)
    positionRange = range(startTick - w, startTick + w)

However, please note that changing this will result in nSecs=24*3600 only working for discrete intervals of exactly 1 day (24*3600) due to .replace(hour=0, minute=0, second=0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant