This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from westonplatter/historicals
Historical Data - options
- Loading branch information
Showing
5 changed files
with
98 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import configparser | ||
from fast_arrow import ( | ||
Client, | ||
Stock, | ||
Option, | ||
OptionChain, | ||
OptionMarketdata | ||
) | ||
|
||
# | ||
# get the authentication configs | ||
# | ||
config_file = "config.debug.ini" | ||
config = configparser.ConfigParser() | ||
config.read(config_file) | ||
username = config['account']['username'] | ||
password = config['account']['password'] | ||
|
||
# | ||
# instantiate and authetnicate client | ||
# | ||
client = Client(username=username, password=password) | ||
client.authenticate() | ||
|
||
# | ||
# get TLT options | ||
# | ||
symbol = "TLT" | ||
stock = Stock.fetch(client, symbol) | ||
|
||
stock_id = stock["id"] | ||
oc = OptionChain.fetch(client, stock_id, symbol) | ||
oc_id = oc["id"] | ||
next_2_eds = oc['expiration_dates'][0:1] | ||
ops = Option.in_chain(client, oc_id, expiration_dates=next_2_eds) | ||
|
||
# | ||
# get TLT in the middle of the current TLT trading range | ||
# | ||
urls = [op["url"] for op in ops] | ||
import math | ||
middle = math.floor(len(urls)/2) | ||
diff = math.floor(len(urls) * 0.7) | ||
lower_end = middle - diff | ||
higher_end = middle + diff | ||
urls_subset = urls[lower_end:higher_end] | ||
|
||
# | ||
# get historical data for TLT options | ||
# | ||
hd = OptionMarketdata.historical_quotes_by_urls(client, urls_subset, span="year") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters