-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArbitrageur.py
52 lines (33 loc) · 1.37 KB
/
Arbitrageur.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
import numpy as np
class Arbitrageur():
def __init__(self, money, goods, cost, value, low, high):
self.money = money
self.goods = goods
self.cost = cost
self.value = value
self.low = low
self.high = high
return
def set_value(self, value):
self.value = value
return
def set_cost(self, cost):
self.cost = cost
return
def set_seller_orderbook(self, orderbook):
self.seller_orderbook = orderbook
return
def set_buyer_orderbook(self, orderbook):
self.buyer_orderbook = orderbook
return
def make_bid(self):
bid = np.random.uniform(low=self.buyer_orderbook.bid, high=min(self.seller_orderbook.bid, self.high))
# print('ARBBID: low: {:10.4f} high: {:10.4f} bid: {:10.4f}'.\
# format(self.buyer_orderbook.bid, min(self.seller_orderbook.bid, self.high), bid))
return bid
def make_ask(self):
ask = np.random.uniform(low=max(self.buyer_orderbook.ask, self.low), high=self.seller_orderbook.ask)
# print('ARBASK: low: {:10.4f} high: {:10.4f} ask: {:10.4f}'.\
# format(max(self.buyer_orderbook.ask, self.low), self.seller_orderbook.ask, ask))
return ask