|
@@ -480,7 +480,7 @@ def ownable_name_exists(name):
|
|
|
return False
|
|
|
|
|
|
|
|
|
-def new_stock(timeout=60, name=None):
|
|
|
+def new_stock(expiry, name=None):
|
|
|
connect()
|
|
|
|
|
|
while name is None:
|
|
@@ -507,14 +507,10 @@ def new_stock(timeout=60, name=None):
|
|
|
ownable_id,
|
|
|
price,
|
|
|
amount,
|
|
|
- timeout)
|
|
|
+ expiry)
|
|
|
return name
|
|
|
|
|
|
|
|
|
-def new_stocks(timeout=60, count=1):
|
|
|
- return [new_stock(timeout=timeout) for _ in range(count)]
|
|
|
-
|
|
|
-
|
|
|
def ownable_id_by_name(ownable_name):
|
|
|
connect()
|
|
|
|
|
@@ -796,7 +792,7 @@ def ownable_name_by_id(ownable_id):
|
|
|
return cursor.fetchone()[0]
|
|
|
|
|
|
|
|
|
-def bank_order(buy, ownable_id, limit, amount, time_until_expiration):
|
|
|
+def bank_order(buy, ownable_id, limit, amount, expiry):
|
|
|
if not limit:
|
|
|
raise AssertionError('The bank does not give away anything.')
|
|
|
place_order(buy,
|
|
@@ -804,7 +800,7 @@ def bank_order(buy, ownable_id, limit, amount, time_until_expiration):
|
|
|
limit,
|
|
|
False,
|
|
|
amount,
|
|
|
- time_until_expiration)
|
|
|
+ expiry)
|
|
|
ownable_name = ownable_name_by_id(ownable_id)
|
|
|
new_news('External investors are selling ' + ownable_name + ' atm')
|
|
|
|
|
@@ -819,10 +815,8 @@ def current_db_time(): # might differ from datetime.datetime.now() for time zon
|
|
|
return cursor.fetchone()[0]
|
|
|
|
|
|
|
|
|
-def place_order(buy, ownership_id, limit, stop_loss, amount, time_until_expiration):
|
|
|
+def place_order(buy, ownership_id, limit, stop_loss, amount, expiry):
|
|
|
connect()
|
|
|
- expiry = datetime.strptime(current_db_time(), '%Y-%m-%d %H:%M:%S') + timedelta(minutes=time_until_expiration)
|
|
|
-
|
|
|
cursor.execute('''
|
|
|
INSERT INTO orders
|
|
|
(buy, ownership_id, "limit", stop_loss, ordered_amount, expiry_dt)
|