Beispiel #1
0
def option_orders(client, options={}):
    '''
    options:
        - only_filled. Default = True
    '''
    x = OptionOrder.all(client)
    only_filled = util.get_key(options, "only_filled", True)
    if only_filled:
        x = list(filter(lambda j: j["state"] == "filled", x))
    x = OptionOrder.humanize_numbers(x)
    return x
Beispiel #2
0
def option_orders(account, options={}):
    '''
    options:
        - only_filled:
    '''
    client = _init_client(account["username"], account["password"])
    x = OptionOrder.all(client)
    only_filled = util.get_key(options, "only_filled", True)
    if only_filled:
        x = list(filter(lambda j: j["state"] == "filled", x))
    x = OptionOrder.humanize_numbers(x)
    return x
import configparser
from fast_arrow import Client, OptionOrder
from datetime import datetime, timedelta


print("----- running {}".format(__file__))


#
# get auth_data (see https://github.com/westonplatter/fast_arrow_auth)
#
with open("fast_arrow_auth.json") as f:
    auth_data = json.loads(f.read())


#
# initialize client with auth_data
#
client = Client(auth_data)


#
# fetch option orders for last 14 days
#
recent_orders = OptionOrder.all(client, max_fetches=3)

print(len(recent_orders))
Beispiel #4
0
config = configparser.ConfigParser()
config.read('config.debug.ini')

#
# initialize fast_arrow client and authenticate
#
client = Client(username=config['account']['username'],
                password=config['account']['password'])

client.authenticate()

#
# fetch option orders
#
option_orders_all = OptionOrder.all(client)

#
# in case you have lots, only use first 25
# (unroll process fetches contract data for each leg)
#
option_orders = option_orders_all[0:25]

#
# unroll option orders ... ie, break each option leg into its own row
# this is helpful when doing detailed P/L reporting
#
option_orders_unrolled = OptionOrder.unroll_option_legs(client, option_orders)

#
# let's print out the results
Beispiel #5
0
def option_orders(account, options={}):
    token = _get_token(account["username"], account["password"])
    orders = OptionOrder.all(token)
    if ("only_filled" in options) and options["only_filled"]:
        orders = list(filter(lambda x: x["state"] == "filled", orders))
    return orders