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

Price graph #1

Open
miohtama opened this issue Oct 15, 2016 · 0 comments
Open

Price graph #1

miohtama opened this issue Oct 15, 2016 · 0 comments

Comments

@miohtama
Copy link

Plotted out HackerGold price graph.

Looks ok

screen shot 2016-10-15 at 13 25 14

Code - Notebook:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import datetime

start_date = datetime.datetime.now()
end_date = datetime.datetime.now() + datetime.timedelta(days=90)

class milestones:
    p1 = 1476972000  # P1: GMT: 20-Oct-2016 14:00  => The Sale Starts
    p2 = 1478181600  # P2: GMT: 03-Nov-2016 14:00  => 1st Price Ladder 
    p3 = 1479391200  # P3: GMT: 17-Nov-2016 14:00  => Price Stable, 
                      #                                Hackathon Starts
    p4 = 1480600800  # P4: GMT: 01-Dec-2016 14:00  => 2nd Price Ladder
    p5 = 1481810400  # P5: GMT: 15-Dec-2016 14:00  => Price Stable
    p6 = 1482415200   # P6: GMT: 22-Dec-2016 14:00  => Sale Ends, Hackathon Ends

BASE_PRICE = 200


def price(now):

    if now < milestones.p1:
        return 0;

    if now >= milestones.p1 and now < milestones.p2:    
        return BASE_PRICE;

    if now >= milestones.p2 and now < milestones.p3:
        days_in = 1 + (now - milestones.p2) // (60 * 60 *24); 
        return BASE_PRICE - days_in * 25 // 7

    if  now >= milestones.p3 and now < milestones.p4:
        return BASE_PRICE // 4 * 3;

    if now >= milestones.p4 and now < milestones.p5:        
        days_in = 1 + (now - milestones.p4) // (60 * 60 *24); 
        return (BASE_PRICE // 4 * 3) - days_in * 25 // 7;  # daily decrease 3.5

    if now >= milestones.p5 and now < milestones.p6:    
        return BASE_PRICE // 2;

    if now >= milestones.p6:
        return 0;



print("Start date {}, end date {}".format(start_date, end_date))
# Step one day at a time
y = []
x_range = []
current = start_date
while current < end_date:
    x_range.append(current)
    now = current.timestamp()
    p = int(price(now))
    assert type(p) == int
    y.append(p)
    current += datetime.timedelta(days=1)

line, = plt.plot(x_range, y, "--", linewidth=2)

plt.ylim(0, 200)
plt.show()
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