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

Commit 9fa6bf5

Browse files
Merge pull request #75 from westonplatter/17-stock-fetch-by-id
feature #17. stocks. symbol(s) and instrument_id(s)
2 parents a2bb72c + 3b33d24 commit 9fa6bf5

34 files changed

+234
-104
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ coveralls:
1313
.PHONY: lint
1414
lint:
1515
pipenv run tox -e lint
16+
17+
18+
.PHONY: examples
19+
examples:
20+
pipenv run run_all_examples

Pipfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ yarl = "*"
1111
pandas = ">=0.23.2"
1212
numpy = "*"
1313
datetime = "*"
14+
deprecation = "*"
1415

1516
[dev-packages]
1617
vcrpy = "*"
@@ -23,3 +24,6 @@ ipdb = "*"
2324

2425
[requires]
2526
python_version = "3.6"
27+
28+
[scripts]
29+
run_all_examples = "sh ./run_all_examples.sh"

Pipfile.lock

Lines changed: 26 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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
#

examples/auth_mfa.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from fast_arrow import Client
33
from fast_arrow.resources.user import User
44

5-
#
6-
# get the authentication configs
7-
#
5+
print("----- running {}".format(__file__))
6+
7+
8+
get the authentication configs
9+
810
config_file = "config.debug.ini"
911
config = configparser.ConfigParser()
1012
config.read(config_file)

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))

0 commit comments

Comments
 (0)