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

Microservice - Add MS to show max move by stock #6

Open
jfmatth opened this issue Dec 4, 2020 · 0 comments
Open

Microservice - Add MS to show max move by stock #6

jfmatth opened this issue Dec 4, 2020 · 0 comments

Comments

@jfmatth
Copy link
Owner

jfmatth commented Dec 4, 2020

given a stock, show it's biggest downside move from day-to-day. see code below

def maximum_price_diff(pl):
    # given a pricelist PL, determine the maximum one-day drop
    # PL = [n]['date','close']
    # assume the list is in date assending order

    max_diff = {'date': None,
                'max': 0}

    for x in range(1, len(pl)):
        today = pl[x]['close']
        yesterday = pl[x-1]['close']
        diff = today - yesterday

        if diff < max_diff['max']:
            max_diff['max'] = diff
            max_diff['date'] = pl[x]['date']
            # print(pl[x]['date'], yesterday, today, max_diff)

    return(max_diff)

and then to call it...

pl = Price.objects.filter(symbol__name="SPXL").values('date','close').order_by('date')
maximum_price_diff(pl)
@jfmatth jfmatth changed the title Service to determine max and avg daily move by stock Microservice - Add MS to show max move by stock Dec 7, 2020
@jfmatth jfmatth transferred this issue from another repository Dec 30, 2020
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