-
Notifications
You must be signed in to change notification settings - Fork 4
/
server_api.py
77 lines (50 loc) · 1.66 KB
/
server_api.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Port for communication: 19290
Interface:
{
import json
data sent as string can be converted using:
data_unzipped = json.loads(string data)
The type of the data will be according to return types listed below for each command
}
10 stocks:
0..9
Stock: symbol, volume, bid-ask price
Public functions: (available to client)
getSymbols() : list of symbols
getPrice(string symbol): return the bid ask price (double)
getVolume(string symbol): return the volume (int)
buy(string symbol, int quantity): returns 1/0 (for accept/decline)
sell(string symbol, int quantity): returns 1/0 (for accept/decline)
createAccount(): return unique id (int) for newly created account
getFunds(): return available funds of current client
getPortfolio(): return dictionary (symbol: volume)
Preface all commands with unique id (received from createAccount())
Commands
for all commands:
returns -1 if invalid syntax
getid
returns int id
id,buy,ticker,shares
returns int 1 if accepted, 0 if declined
id,sell,ticker,shares
returns int 1 if accepted, 0 if declined
id,bid,ticker,price,quantity
returns int 1 if accepted, 0 pending, -1 if declined
id,ask,ticker,price,quantity
returns int 1 if accepted, 0 pending, -1 if declined
id,price,ticker
returns int price
id,volume,ticker
returns int volume
id,portfolio
returns dict portfolio {symbol : volumeOwned}
id,orders
returns orders for account
id,funds
returns double availableFunds
id,symbols
returns list of symbols
id,trueValue,ticker
returns trueValue of stock
"""