-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.py
More file actions
36 lines (29 loc) · 1001 Bytes
/
point.py
File metadata and controls
36 lines (29 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
point is a container for the Point class.
Author: Justin Cohler
Created: 11/17/2017
"""
from datetime import datetime
class Point:
"""Point contains point-in-time data for a given base and currency.
e.g. base: BTC, currency: USD
"""
def __init__(self, buy, sell):
"""Construct using a buy and sell object from coinbase API."""
self.buy_price=float(buy["amount"])
self.sell_price=float(sell["amount"])
self.base=buy["base"]
self.currency=buy["currency"]
self.dt = datetime.now()
def __repr__(self):
"""Represent as a list of object attributes."""
return repr([self.buy_price, self.sell_price, self.base, self.currency, self.dt])
def to_dict(self):
"""Transform object to simple dict."""
return {
'buy_price': self.buy_price,
'sell_price': self.sell_price,
'base': self.base,
'currency': self.currency,
'dt': self.dt,
}