Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Commit ca4f631

Browse files
committed
add print line to examples.
1 parent 2a08fab commit ca4f631

27 files changed

+144
-96
lines changed

examples/auth.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22
from fast_arrow import Client
33
from fast_arrow.resources.user import User
44

5+
print("----- running {}".format(__file__))
6+
7+
# #
8+
# # get the authentication configs
9+
# #
10+
# config_file = "config.debug.ini"
11+
# config = configparser.ConfigParser()
12+
# config.read(config_file)
13+
# username = config['account']['username']
14+
# password = config['account']['password']
515
#
6-
# get the authentication configs
16+
# client = Client(username=username, password=password)
17+
# result = client.authenticate()
718
#
8-
config_file = "config.debug.ini"
9-
config = configparser.ConfigParser()
10-
config.read(config_file)
11-
username = config['account']['username']
12-
password = config['account']['password']
13-
14-
client = Client(username=username, password=password)
15-
result = client.authenticate()
16-
17-
print("Authenticated successfully = {}".format(result))
18-
19-
print("Account Url = {}".format(client.account_url))
20-
print("Account Id = {}".format(client.account_id))
21-
22-
user = User.fetch(client)
23-
print("Username = {}".format(user["username"]))
24-
25-
result = client.relogin_oauth2()
26-
print("Re-Authenticated with refresh_token successfully = {}".format(result))
27-
28-
result = client.logout_oauth2()
29-
print("Logged out successfully = {}".format(result))
19+
# print("Authenticated successfully = {}".format(result))
20+
#
21+
# print("Account Url = {}".format(client.account_url))
22+
# print("Account Id = {}".format(client.account_id))
23+
#
24+
# user = User.fetch(client)
25+
# print("Username = {}".format(user["username"]))
26+
#
27+
# result = client.relogin_oauth2()
28+
# print("Re-Authenticated with refresh_token successfully = {}".format(result))
29+
#
30+
# result = client.logout_oauth2()
31+
# print("Logged out successfully = {}".format(result))

examples/auth_mfa.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,32 @@
22
from fast_arrow import Client
33
from fast_arrow.resources.user import User
44

5+
print("----- running {}".format(__file__))
6+
57
#
68
# get the authentication configs
79
#
8-
config_file = "config.debug.ini"
9-
config = configparser.ConfigParser()
10-
config.read(config_file)
11-
username = config['account']['username']
12-
password = config['account']['password']
13-
14-
mfa_code = "code goes here as a string"
15-
16-
client = Client(username=username, password=password, mfa_code=mfa_code)
17-
result = client.authenticate()
18-
19-
print("Authenticated successfully = {}".format(result))
20-
21-
print("Account Url = {}".format(client.account_url))
22-
print("Account Id = {}".format(client.account_id))
23-
24-
user = User.fetch(client)
25-
print("Username = {}".format(user["username"]))
26-
27-
result = client.relogin_oauth2()
28-
print("Re-Authenticated with refresh_token successfully = {}".format(result))
29-
30-
result = client.logout_oauth2()
31-
print("Logged out successfully = {}".format(result))
10+
# config_file = "config.debug.ini"
11+
# config = configparser.ConfigParser()
12+
# config.read(config_file)
13+
# username = config['account']['username']
14+
# password = config['account']['password']
15+
#
16+
# mfa_code = "code goes here as a string"
17+
#
18+
# client = Client(username=username, password=password, mfa_code=mfa_code)
19+
# result = client.authenticate()
20+
#
21+
# print("Authenticated successfully = {}".format(result))
22+
#
23+
# print("Account Url = {}".format(client.account_url))
24+
# print("Account Id = {}".format(client.account_id))
25+
#
26+
# user = User.fetch(client)
27+
# print("Username = {}".format(user["username"]))
28+
#
29+
# result = client.relogin_oauth2()
30+
# print("Re-Authenticated with refresh_token successfully = {}".format(result))
31+
#
32+
# result = client.logout_oauth2()
33+
# print("Logged out successfully = {}".format(result))

examples/historical_option_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
OptionChain,
77
OptionMarketdata
88
)
9+
import math
10+
11+
print("----- running {}".format(__file__))
912

1013
#
1114
# get the authentication configs
@@ -38,7 +41,6 @@
3841
# get TLT in the middle of the current TLT trading range
3942
#
4043
urls = [op["url"] for op in ops]
41-
import math
4244
middle = math.floor(len(urls)/2)
4345
diff = math.floor(len(urls) * 0.7)
4446
lower_end = middle - diff

examples/option_chain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Option,
77
)
88

9+
print("----- running {}".format(__file__))
910

1011
#
1112
# get the authentication configs

examples/option_events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
OptionEvent
55
)
66

7+
print("----- running {}".format(__file__))
78

89
#
910
# get the authentication configs

examples/option_order_get.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
import math
1111

12+
print("----- running {}".format(__file__))
1213

1314
#
1415
# get the authentication configs

examples/option_order_place_iron_condor.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
Stock
1414
)
1515

16+
print("----- running {}".format(__file__))
17+
1618
#
1719
# get the authentication configs
1820
#
@@ -35,7 +37,6 @@
3537
#
3638
symbol = "SPY"
3739
stock = Stock.fetch(client, symbol)
38-
stock = Stock.mergein_marketdata_list(client, [stock])[0]
3940

4041
oc = OptionChain.fetch(client, stock["id"], symbol)
4142
ed = oc['expiration_dates'][10]
@@ -53,39 +54,38 @@
5354
width = 1
5455
put_inner_lte_delta = -0.2
5556
call_inner_lte_delta = 0.1
56-
ic = IronCondor.generate_by_deltas(ops,
57-
width, put_inner_lte_delta, call_inner_lte_delta)
58-
59-
direction = "credit"
60-
legs = ic["legs"]
61-
# @TODO create helper methods to handle floating arith and rounding issues
62-
# for now, it works good enough
63-
price_notional = ic["price"] * 100
64-
price_notional_fourth = price_notional / 4
65-
price_order = price_notional_fourth / 100
66-
price = str(price_order)
67-
68-
quantity = 1
69-
time_in_force = "gfd"
70-
trigger = "immediate"
71-
order_type = "limit"
72-
73-
# @TODO create human description of IC
74-
# print("Selling a {} {}/{} Put Spread for {} (notional value = ${})".format(
75-
# symbol,
76-
# vertical["strike_price"].values[0],
77-
# vertical["strike_price_shifted"].values[0],
78-
# price,
79-
# my_bid_price_rounded)
80-
# )
81-
82-
oo = OptionOrder.submit(client, direction, legs, price, quantity, time_in_force, trigger, order_type)
83-
84-
print("Order submitted ... ref_id = {}".format(oo["ref_id"]))
85-
57+
# ic = IronCondor.generate_by_deltas(ops,width, put_inner_lte_delta, call_inner_lte_delta)
58+
#
59+
# direction = "credit"
60+
# legs = ic["legs"]
61+
# # @TODO create helper methods to handle floating arith and rounding issues
62+
# # for now, it works good enough
63+
# price_notional = ic["price"] * 100
64+
# price_notional_fourth = price_notional / 4
65+
# price_order = price_notional_fourth / 100
66+
# price = str(price_order)
67+
#
68+
# quantity = 1
69+
# time_in_force = "gfd"
70+
# trigger = "immediate"
71+
# order_type = "limit"
72+
#
73+
# # @TODO create human description of IC
74+
# # print("Selling a {} {}/{} Put Spread for {} (notional value = ${})".format(
75+
# # symbol,
76+
# # vertical["strike_price"].values[0],
77+
# # vertical["strike_price_shifted"].values[0],
78+
# # price,
79+
# # my_bid_price_rounded)
80+
# # )
81+
#
82+
# oo = OptionOrder.submit(client, direction, legs, price, quantity, time_in_force, trigger, order_type)
8683
#
87-
# cancel the order
84+
# print("Order submitted ... ref_id = {}".format(oo["ref_id"]))
8885
#
89-
print("Canceling order = {}".format(oo["ref_id"]))
90-
result = OptionOrder.cancel(client, oo['cancel_url'])
91-
print("Order canceled result = {}".format(result))
86+
# #
87+
# # cancel the order
88+
# #
89+
# print("Canceling order = {}".format(oo["ref_id"]))
90+
# result = OptionOrder.cancel(client, oo['cancel_url'])
91+
# print("Order canceled result = {}".format(result))

examples/option_order_place_single.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
)
99
import math
1010

11+
print("----- running {}".format(__file__))
1112

1213
#
1314
# get the authentication configs

examples/option_order_place_vertical.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
import math
1111

12+
print("----- running {}".format(__file__))
1213

1314
#
1415
# get the authentication configs

examples/option_order_replace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
)
1010
import math
1111

12+
print("----- running {}".format(__file__))
1213

1314
#
1415
# get the authentication configs

examples/option_orders_max_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from datetime import datetime, timedelta
44

55

6+
print("----- running {}".format(__file__))
7+
8+
69
config = configparser.ConfigParser()
710
config.read('config.debug.ini')
811

examples/option_orders_unroll.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from fast_arrow import Client, OptionOrder
33

44

5+
print("----- running {}".format(__file__))
6+
7+
58
config = configparser.ConfigParser()
69
config.read('config.debug.ini')
710

@@ -34,8 +37,7 @@
3437
#
3538
option_orders_unrolled = OptionOrder.unroll_option_legs(client, option_orders)
3639

37-
3840
#
3941
# let's print out the results
4042
#
41-
print(option_orders_unrolled[1:10])
43+
print(option_orders_unrolled[0].keys())

examples/option_positions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
OptionPosition
77
)
88

9+
print("----- running {}".format(__file__))
10+
911
#
1012
# get the authentication configs
1113
#

examples/option_positions_humanized.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
OptionMarketdata,
1010
)
1111

12+
print("----- running {}".format(__file__))
13+
1214
#
1315
# get the authentication configs
1416
#
@@ -73,5 +75,5 @@
7375
# create Pandas DF of option positions
7476
#
7577
df = pd.DataFrame.from_dict(ops)
76-
#
78+
#
7779
print(df)

examples/option_positions_max_date.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
OptionPosition
88
)
99

10+
print("----- running {}".format(__file__))
11+
1012
#
1113
# get the authentication configs
1214
#

examples/portfolio_historicals.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import configparser
22
from fast_arrow import Client
33
from fast_arrow import Portfolio
4+
from fast_arrow import Account
5+
6+
7+
print("----- running {}".format(__file__))
8+
49

510
#
611
# get the authentication configs
@@ -10,19 +15,25 @@
1015
config.read(config_file)
1116
username = config['account']['username']
1217
password = config['account']['password']
13-
account = config['account']['account']
18+
1419

1520
client = Client(username=username, password=password)
1621
result = client.authenticate()
1722

23+
24+
account = Account.all(client)[0]
25+
account_number = account['account_number']
26+
27+
1828
span="year"
1929
bounds="regular"
20-
portfolio_historicals = Portfolio.historical(client, account, span, bounds)
30+
portfolio_historicals = Portfolio.historical(client, account_number, span, bounds)
31+
2132

2233
ehs = portfolio_historicals["equity_historicals"]
2334
begins_at = ehs[-1]["begins_at"]
2435
ends_at = ehs[0]["begins_at"]
2536

26-
print(ehs[0].keys())
2737

38+
print(ehs[0].keys())
2839
print("Fetched portfolio data between {} and {}".format(begins_at, ends_at))

examples/stock_historical_export.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
StockMarketdata
66
)
77

8+
9+
print("----- running {}".format(__file__))
10+
11+
812
#
913
# get the authentication configs
1014
#

examples/stock_positions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
StockPosition
55
)
66

7+
8+
print("----- running {}".format(__file__))
9+
10+
711
#
812
# get the authentication configs
913
#

0 commit comments

Comments
 (0)