-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.py
60 lines (48 loc) · 1.86 KB
/
test.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
import sys
print(sys.path)
sys.path.append('/home/ivan/Documents/github/crobat/crobat')
import crobat
import crobat.recorder
import asyncio, time
#from test import test_connection
#test_connection.main()
#from datetime import datetime
import copra.rest
from copra.websocket import Channel, Client
#import pandas as pd
# # how do i want this shit to work
# # 1. you import the program
# # 2. you intialize the args, with the option to start recording
# # 3a. if you choose to start recording
# # i. you can call the class.get_item to see what the last order was
# # ii. you can call a function to get the current picture of the orderbook
# # iii. you can call a function to get the running order book images as dirty or pandas'd
# # iv. you can call a function to get the last_orders disrt or as pandas
# # 3b. if not you have the option of calling the class indiviudually within your own asyncio loop
# # 4. error handling ?
class input_args(object):
def __init__(self, currency_pair='ETH-USD',
position_range=4,
recording_duration=5,
sides=['bid','ask'],
filetype=['xlsx']):
self.currency_pair = currency_pair
self.position_range = position_range
self.recording_duration = recording_duration
self.sides = sides
self.filetype = filetype
# def check_input(input_str, reference_var):
def main():
settings = input_args()
loop = asyncio.get_event_loop()
channel = Channel('level2', settings.currency_pair)
channel2 =Channel('ticker', settings.currency_pair)
ws = crobat.recorder.L2_Update(loop, channel, settings)
ws.subscribe(channel2)
try:
loop.run_forever()
except KeyboardInterrupt:
loop.run_until_complete(ws.close())
loop.close()
if __name__ == '__main__':
main()