forked from westonplatter/fast_arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption_positions.py
49 lines (37 loc) · 1.01 KB
/
option_positions.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
import configparser
from fast_arrow import (
Client,
OptionChain,
Option,
OptionPosition
)
print("----- running {}".format(__file__))
#
# get the authentication configs
#
config_file = "config.debug.ini"
config = configparser.ConfigParser()
config.read(config_file)
username = config['account']['username']
password = config['account']['password']
#
# initialize and authenticate Client
#
client = Client(username=username, password=password)
client.authenticate()
#
# fetch option_positions
#
all_option_positions = OptionPosition.all(client)
#
# filter to get open option_positions
#
open_option_positions = list(filter(lambda p: float(p["quantity"]) > 0.0, all_option_positions))
#
# append marketdata to each position
#
option_position_with_marketdata = OptionPosition.mergein_marketdata_list(client, open_option_positions)
#
# append instrument data to each position
#
ption_position_with_marketdata_and_instrument_data = OptionPosition.mergein_instrumentdata_list(client, option_position_with_marketdata)