Exemplo n.º 1
0
def stock_positions(account, options={}):
    '''
    options:
    '''
    client = _init_client(account["username"], account["password"])
    x = StockPosition.all(client)
    return x
Exemplo n.º 2
0
    def test_fetch_fields(self):
        client = gen_client()
        with gen_vcr().use_cassette('position_all.yaml'):
            stock_positions = StockPosition.all(client)
            stock_position = stock_positions[0]

            expected_fields = [
                'shares_held_for_stock_grants', 'account',
                'pending_average_buy_price', 'shares_held_for_options_events',
                'intraday_average_buy_price', 'url',
                'shares_held_for_options_collateral', 'created_at',
                'updated_at', 'shares_held_for_buys', 'average_buy_price',
                'instrument', 'intraday_quantity', 'shares_held_for_sells',
                'shares_pending_from_options_events', 'quantity'
            ]

            actual_fields = list(stock_position.keys())

            assert (set(expected_fields) == set(actual_fields))
Exemplo n.º 3
0
import configparser
from fast_arrow import (Client, StockPosition)

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 stock positions
#
all_stock_positions = StockPosition.all(client)

#
# filter to get open positions
#
open_positions = list(
    filter(lambda x: float(x["quantity"]) > 0.0, all_stock_positions))
Exemplo n.º 4
0
def positions(account, options={}):
    token = _get_token(account["username"], account["password"])
    ps = StockPosition.all(token)
    if ("only_open" in options) and options["only_open"]:
        ps = list(filter(lambda x: float(x["quantity"]) > 0.0, ps))
    return ps
Exemplo n.º 5
0
def stock_positions(client, options={}):
    return StockPosition.all(client)