-
Notifications
You must be signed in to change notification settings - Fork 2
/
broker_test.py
39 lines (32 loc) · 1.04 KB
/
broker_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
import redis, json
import asyncio, datetime
import sys
import nest_asyncio
import configparser
import traceback
from textmagic.rest import TextmagicRestClient
nest_asyncio.apply()
from broker_root import broker_root
from broker_ibkr import broker_ibkr
from broker_alpaca import broker_alpaca
for account in ["U8438939", "PA3I5VZDCGPF"]:
print(f"Account: {account}")
bot = "live"
config = configparser.ConfigParser()
print("HEALTH CHECK")
config.read('config.ini')
aconfig = config[account]
if aconfig['driver'] == 'ibkr':
driver = broker_ibkr(bot, account)
elif aconfig['driver'] == 'alpaca':
driver = broker_alpaca(bot, account)
else:
raise Exception("Unknown driver: " + aconfig['driver'])
driver.health_check()
print("GET POSITION SIZE")
position_size = driver.get_position_size('ES1!')
print(f"Position size: {position_size}")
print("GET STOCK, CHECK FUTURES")
stock = driver.get_stock("ES1!")
print(f"Stock: {stock}, is_futures={stock.is_futures}")
print("")