From 46c0829efbfa02bc43858958fea3b1cc8babdba7 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:09:25 -0700 Subject: [PATCH] Clean up --- .circleci/config.yml | 20 --- examples/crypto-aggregates_bars.py | 30 ---- examples/crypto-conditions.py | 13 -- examples/crypto-daily_open_close.py | 16 --- examples/crypto-exchanges.py | 25 ---- examples/crypto-grouped_daily_bars.py | 20 --- .../crypto-last_trade_for_a_crypto_pair.py | 12 -- examples/crypto-market_holidays.py | 20 --- examples/crypto-market_status.py | 11 -- examples/crypto-previous_close.py | 14 -- examples/crypto-snapshots_all_tickers.py | 41 ------ examples/crypto-snapshots_gainers_losers.py | 37 ----- examples/crypto-snapshots_ticker.py | 11 -- .../crypto-snapshots_ticker_full_book_l2.py | 13 -- examples/crypto-technical_indicators_ema.py | 17 --- examples/crypto-technical_indicators_macd.py | 19 --- examples/crypto-technical_indicators_rsi.py | 17 --- examples/crypto-technical_indicators_sma.py | 17 --- examples/crypto-tickers.py | 13 -- examples/crypto-trades.py | 15 -- examples/financials.py | 11 -- examples/forex-aggregates_bars.py | 30 ---- examples/forex-conditions.py | 13 -- examples/forex-exchanges.py | 25 ---- examples/forex-grouped_daily_bars.py | 22 --- .../forex-last_quote_for_a_currency_pair.py | 15 -- examples/forex-market_holidays.py | 20 --- examples/forex-market_status.py | 11 -- examples/forex-previous_close.py | 14 -- examples/forex-quotes.py | 13 -- .../forex-real-time_currency_conversion.py | 15 -- examples/forex-snapshots_all_tickers.py | 41 ------ examples/forex-snapshots_gainers_losers.py | 37 ----- examples/forex-snapshots_ticker.py | 11 -- examples/forex-technical_indicators_ema.py | 17 --- examples/forex-technical_indicators_macd.py | 19 --- examples/forex-technical_indicators_rsi.py | 17 --- examples/forex-technical_indicators_sma.py | 17 --- examples/forex-tickers.py | 13 -- examples/indices-aggregates_bars.py | 30 ---- examples/indices-daily_open_close.py | 16 --- examples/indices-market_holidays.py | 20 --- examples/indices-market_status.py | 11 -- examples/indices-previous_close.py | 14 -- examples/indices-snapshots.py | 14 -- examples/indices-technical_indicators_ema.py | 17 --- examples/indices-technical_indicators_macd.py | 19 --- examples/indices-technical_indicators_rsi.py | 17 --- examples/indices-technical_indicators_sma.py | 17 --- examples/indices-ticker_types.py | 27 ---- examples/indices-tickers.py | 13 -- examples/options-aggregates_bars.py | 30 ---- examples/options-conditions.py | 13 -- examples/options-contract.py | 13 -- examples/options-contracts.py | 13 -- examples/options-daily_open_close.py | 16 --- examples/options-exchanges.py | 25 ---- examples/options-last_trade.py | 14 -- examples/options-market_holidays.py | 20 --- examples/options-market_status.py | 11 -- examples/options-previous_close.py | 14 -- examples/options-quotes.py | 13 -- examples/options-snapshots_option_contract.py | 13 -- examples/options-snapshots_options_chain.py | 19 --- examples/options-technical_indicators_ema.py | 14 -- examples/options-technical_indicators_macd.py | 19 --- examples/options-technical_indicators_rsi.py | 14 -- examples/options-technical_indicators_sma.py | 14 -- examples/options-ticker_details.py | 11 -- examples/options-ticker_news.py | 24 ---- examples/options-tickers.py | 13 -- examples/options-trades.py | 15 -- examples/stocks-aggregates_bars.py | 30 ---- examples/stocks-aggregates_bars_extra.py | 78 ---------- examples/stocks-aggregates_bars_highcharts.py | 136 ------------------ examples/stocks-conditions.py | 13 -- examples/stocks-daily_open_close.py | 16 --- examples/stocks-dividends.py | 13 -- examples/stocks-exchanges.py | 25 ---- examples/stocks-grouped_daily_bars.py | 20 --- examples/stocks-last_quote.py | 14 -- examples/stocks-last_trade.py | 14 -- examples/stocks-market_holidays.py | 20 --- examples/stocks-market_status.py | 11 -- examples/stocks-previous_close.py | 14 -- examples/stocks-quotes.py | 21 --- examples/stocks-snapshots_all.py | 45 ------ examples/stocks-snapshots_gainers_losers.py | 37 ----- examples/stocks-snapshots_ticker.py | 11 -- examples/stocks-stock_financials.py | 13 -- examples/stocks-stock_splits.py | 13 -- examples/stocks-technical_indicators_ema.py | 17 --- examples/stocks-technical_indicators_macd.py | 19 --- examples/stocks-technical_indicators_rsi.py | 17 --- examples/stocks-technical_indicators_sma.py | 17 --- examples/stocks-ticker_details.py | 11 -- examples/stocks-ticker_events.py | 11 -- examples/stocks-ticker_news.py | 26 ---- examples/stocks-ticker_types.py | 11 -- examples/stocks-tickers.py | 13 -- examples/stocks-trades.py | 21 --- examples/stocks-trades_extra.py | 27 ---- examples/universal-snapshot.py | 47 ------ git_push.sh | 57 -------- 104 files changed, 2133 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 examples/crypto-aggregates_bars.py delete mode 100644 examples/crypto-conditions.py delete mode 100644 examples/crypto-daily_open_close.py delete mode 100644 examples/crypto-exchanges.py delete mode 100644 examples/crypto-grouped_daily_bars.py delete mode 100644 examples/crypto-last_trade_for_a_crypto_pair.py delete mode 100644 examples/crypto-market_holidays.py delete mode 100644 examples/crypto-market_status.py delete mode 100644 examples/crypto-previous_close.py delete mode 100644 examples/crypto-snapshots_all_tickers.py delete mode 100644 examples/crypto-snapshots_gainers_losers.py delete mode 100644 examples/crypto-snapshots_ticker.py delete mode 100644 examples/crypto-snapshots_ticker_full_book_l2.py delete mode 100644 examples/crypto-technical_indicators_ema.py delete mode 100644 examples/crypto-technical_indicators_macd.py delete mode 100644 examples/crypto-technical_indicators_rsi.py delete mode 100644 examples/crypto-technical_indicators_sma.py delete mode 100644 examples/crypto-tickers.py delete mode 100644 examples/crypto-trades.py delete mode 100644 examples/financials.py delete mode 100644 examples/forex-aggregates_bars.py delete mode 100644 examples/forex-conditions.py delete mode 100644 examples/forex-exchanges.py delete mode 100644 examples/forex-grouped_daily_bars.py delete mode 100644 examples/forex-last_quote_for_a_currency_pair.py delete mode 100644 examples/forex-market_holidays.py delete mode 100644 examples/forex-market_status.py delete mode 100644 examples/forex-previous_close.py delete mode 100644 examples/forex-quotes.py delete mode 100644 examples/forex-real-time_currency_conversion.py delete mode 100644 examples/forex-snapshots_all_tickers.py delete mode 100644 examples/forex-snapshots_gainers_losers.py delete mode 100644 examples/forex-snapshots_ticker.py delete mode 100644 examples/forex-technical_indicators_ema.py delete mode 100644 examples/forex-technical_indicators_macd.py delete mode 100644 examples/forex-technical_indicators_rsi.py delete mode 100644 examples/forex-technical_indicators_sma.py delete mode 100644 examples/forex-tickers.py delete mode 100644 examples/indices-aggregates_bars.py delete mode 100644 examples/indices-daily_open_close.py delete mode 100644 examples/indices-market_holidays.py delete mode 100644 examples/indices-market_status.py delete mode 100644 examples/indices-previous_close.py delete mode 100644 examples/indices-snapshots.py delete mode 100644 examples/indices-technical_indicators_ema.py delete mode 100644 examples/indices-technical_indicators_macd.py delete mode 100644 examples/indices-technical_indicators_rsi.py delete mode 100644 examples/indices-technical_indicators_sma.py delete mode 100644 examples/indices-ticker_types.py delete mode 100644 examples/indices-tickers.py delete mode 100644 examples/options-aggregates_bars.py delete mode 100644 examples/options-conditions.py delete mode 100644 examples/options-contract.py delete mode 100644 examples/options-contracts.py delete mode 100644 examples/options-daily_open_close.py delete mode 100644 examples/options-exchanges.py delete mode 100644 examples/options-last_trade.py delete mode 100644 examples/options-market_holidays.py delete mode 100644 examples/options-market_status.py delete mode 100644 examples/options-previous_close.py delete mode 100644 examples/options-quotes.py delete mode 100644 examples/options-snapshots_option_contract.py delete mode 100644 examples/options-snapshots_options_chain.py delete mode 100644 examples/options-technical_indicators_ema.py delete mode 100644 examples/options-technical_indicators_macd.py delete mode 100644 examples/options-technical_indicators_rsi.py delete mode 100644 examples/options-technical_indicators_sma.py delete mode 100644 examples/options-ticker_details.py delete mode 100644 examples/options-ticker_news.py delete mode 100644 examples/options-tickers.py delete mode 100644 examples/options-trades.py delete mode 100644 examples/stocks-aggregates_bars.py delete mode 100644 examples/stocks-aggregates_bars_extra.py delete mode 100644 examples/stocks-aggregates_bars_highcharts.py delete mode 100644 examples/stocks-conditions.py delete mode 100644 examples/stocks-daily_open_close.py delete mode 100644 examples/stocks-dividends.py delete mode 100644 examples/stocks-exchanges.py delete mode 100644 examples/stocks-grouped_daily_bars.py delete mode 100644 examples/stocks-last_quote.py delete mode 100644 examples/stocks-last_trade.py delete mode 100644 examples/stocks-market_holidays.py delete mode 100644 examples/stocks-market_status.py delete mode 100644 examples/stocks-previous_close.py delete mode 100644 examples/stocks-quotes.py delete mode 100644 examples/stocks-snapshots_all.py delete mode 100644 examples/stocks-snapshots_gainers_losers.py delete mode 100644 examples/stocks-snapshots_ticker.py delete mode 100644 examples/stocks-stock_financials.py delete mode 100644 examples/stocks-stock_splits.py delete mode 100644 examples/stocks-technical_indicators_ema.py delete mode 100644 examples/stocks-technical_indicators_macd.py delete mode 100644 examples/stocks-technical_indicators_rsi.py delete mode 100644 examples/stocks-technical_indicators_sma.py delete mode 100644 examples/stocks-ticker_details.py delete mode 100644 examples/stocks-ticker_events.py delete mode 100644 examples/stocks-ticker_news.py delete mode 100644 examples/stocks-ticker_types.py delete mode 100644 examples/stocks-tickers.py delete mode 100644 examples/stocks-trades.py delete mode 100644 examples/stocks-trades_extra.py delete mode 100644 examples/universal-snapshot.py delete mode 100644 git_push.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a0abc47..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: 2 # use CircleCI 2.0 - -jobs: - build: - docker: - - image: circleci/php:7.2-node-browsers - working_directory: ~/client - steps: - - checkout - - run: sudo composer self-update - - restore_cache: - keys: - - composer-v1-{{ checksum "composer.lock" }} - - composer-v1- - - run: composer install -n --prefer-dist - - save_cache: - key: composer-v1-{{ checksum "composer.lock" }} - paths: - - vendor - - run: ./vendor/bin/phpunit diff --git a/examples/crypto-aggregates_bars.py b/examples/crypto-aggregates_bars.py deleted file mode 100644 index a3831ae..0000000 --- a/examples/crypto-aggregates_bars.py +++ /dev/null @@ -1,30 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# API key injected below for easy use. If not provided, the script will attempt -# to use the environment variable "POLYGON_API_KEY". -# -# setx POLYGON_API_KEY "" <- windows -# export POLYGON_API_KEY="" <- mac/linux -# -# Note: To persist the environment variable you need to add the above command -# to the shell startup script (e.g. .bashrc or .bash_profile. -# -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "X:BTCUSD", - 1, - "day", - "2023-01-30", - "2023-02-03", - limit=50000, -): - aggs.append(a) - -print(aggs) diff --git a/examples/crypto-conditions.py b/examples/crypto-conditions.py deleted file mode 100644 index 93e3fed..0000000 --- a/examples/crypto-conditions.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v3_reference_conditions -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-conditions - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -conditions = [] -for c in client.list_conditions("crypto", limit=1000): - conditions.append(c) -print(conditions) diff --git a/examples/crypto-daily_open_close.py b/examples/crypto-daily_open_close.py deleted file mode 100644 index 8ff3ad4..0000000 --- a/examples/crypto-daily_open_close.py +++ /dev/null @@ -1,16 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_open-close_crypto__from___to___date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-daily-open-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# make request -request = client.get_daily_open_close_agg( - "X:BTCUSD", - "2023-01-09", -) - -print(request) diff --git a/examples/crypto-exchanges.py b/examples/crypto-exchanges.py deleted file mode 100644 index cf0a46d..0000000 --- a/examples/crypto-exchanges.py +++ /dev/null @@ -1,25 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - Exchange, -) - -# docs -# https://polygon.io/docs/crypto/get_v3_reference_exchanges -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-exchanges - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -exchanges = client.get_exchanges("crypto") -print(exchanges) - -# loop over exchanges -for exchange in exchanges: - # verify this is an exchange - if isinstance(exchange, Exchange): - # print exchange info - print( - "{:<15}{} ({})".format( - exchange.asset_class, exchange.name, exchange.operating_mic - ) - ) diff --git a/examples/crypto-grouped_daily_bars.py b/examples/crypto-grouped_daily_bars.py deleted file mode 100644 index ec1bdb8..0000000 --- a/examples/crypto-grouped_daily_bars.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -import pprint - -# docs -# https://polygon.io/docs/crypto/get_v2_aggs_grouped_locale_global_market_crypto__date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-grouped-daily-aggs - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -grouped = client.get_grouped_daily_aggs( - "2023-01-09", locale="global", market_type="crypto" -) - -# print(grouped) - -# pprint (short for "pretty-print") is a module that provides a more human- -# readable output format for data structures. -pp = pprint.PrettyPrinter(indent=2) -pp.pprint(grouped) diff --git a/examples/crypto-last_trade_for_a_crypto_pair.py b/examples/crypto-last_trade_for_a_crypto_pair.py deleted file mode 100644 index 850bd98..0000000 --- a/examples/crypto-last_trade_for_a_crypto_pair.py +++ /dev/null @@ -1,12 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_last_crypto__from___to -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#get-last-crypto-trade - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trade = client.get_last_crypto_trade("BTC", "USD") - -print(trade) diff --git a/examples/crypto-market_holidays.py b/examples/crypto-market_holidays.py deleted file mode 100644 index 6d1df16..0000000 --- a/examples/crypto-market_holidays.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - MarketHoliday, -) - -# docs -# https://polygon.io/docs/crypto/get_v1_marketstatus_upcoming -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-holidays - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -holidays = client.get_market_holidays() -# print(holidays) - -# print date, name, and exchange -for holiday in holidays: - # verify this is an exchange - if isinstance(holiday, MarketHoliday): - print("{:<15}{:<15} ({})".format(holiday.date, holiday.name, holiday.exchange)) diff --git a/examples/crypto-market_status.py b/examples/crypto-market_status.py deleted file mode 100644 index 4265997..0000000 --- a/examples/crypto-market_status.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_marketstatus_now -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-status - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -result = client.get_market_status() -print(result) diff --git a/examples/crypto-previous_close.py b/examples/crypto-previous_close.py deleted file mode 100644 index bf309fe..0000000 --- a/examples/crypto-previous_close.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__prev -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-previous-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = client.get_previous_close_agg( - "X:BTCUSD", -) - -print(aggs) diff --git a/examples/crypto-snapshots_all_tickers.py b/examples/crypto-snapshots_all_tickers.py deleted file mode 100644 index 9bb0662..0000000 --- a/examples/crypto-snapshots_all_tickers.py +++ /dev/null @@ -1,41 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, - Agg, -) - -# docs -# https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-all-snapshots - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -snapshot = client.get_snapshot_all("crypto") # all tickers - -# print raw values -print(snapshot) - -# crunch some numbers -for item in snapshot: - # verify this is an TickerSnapshot - if isinstance(item, TickerSnapshot): - # verify this is an Agg - if isinstance(item.prev_day, Agg): - # verify this is a float - if isinstance(item.prev_day.open, float) and isinstance( - item.prev_day.close, float - ): - percent_change = ( - (item.prev_day.close - item.prev_day.open) - / item.prev_day.open - * 100 - ) - print( - "{:<15}{:<15}{:<15}{:.2f} %".format( - item.ticker, - item.prev_day.open, - item.prev_day.close, - percent_change, - ) - ) diff --git a/examples/crypto-snapshots_gainers_losers.py b/examples/crypto-snapshots_gainers_losers.py deleted file mode 100644 index 34db190..0000000 --- a/examples/crypto-snapshots_gainers_losers.py +++ /dev/null @@ -1,37 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, -) - -# docs -# https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto__direction -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-gainers-losers-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# get gainers -gainers = client.get_snapshot_direction("crypto", "gainers") -# print(gainers) - -# print ticker with % change -for gainer in gainers: - # verify this is a TickerSnapshot - if isinstance(gainer, TickerSnapshot): - # verify this is a float - if isinstance(gainer.todays_change_percent, float): - print("{:<15}{:.2f} %".format(gainer.ticker, gainer.todays_change_percent)) - -print() - -# get losers -losers = client.get_snapshot_direction("crypto", "losers") -# print(losers) - -# print ticker with % change -for loser in losers: - # verify this is a TickerSnapshot - if isinstance(loser, TickerSnapshot): - # verify this is a float - if isinstance(loser.todays_change_percent, float): - print("{:<15}{:.2f} %".format(loser.ticker, loser.todays_change_percent)) diff --git a/examples/crypto-snapshots_ticker.py b/examples/crypto-snapshots_ticker.py deleted file mode 100644 index 31a48eb..0000000 --- a/examples/crypto-snapshots_ticker.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-ticker-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ticker = client.get_snapshot_ticker("crypto", "X:BTCUSD") -print(ticker) diff --git a/examples/crypto-snapshots_ticker_full_book_l2.py b/examples/crypto-snapshots_ticker_full_book_l2.py deleted file mode 100644 index 38d239c..0000000 --- a/examples/crypto-snapshots_ticker_full_book_l2.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker__book -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-crypto-l2-book-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -snapshot = client.get_snapshot_crypto_book("X:BTCUSD") - -# print raw values -print(snapshot) diff --git a/examples/crypto-technical_indicators_ema.py b/examples/crypto-technical_indicators_ema.py deleted file mode 100644 index 4995800..0000000 --- a/examples/crypto-technical_indicators_ema.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_indicators_ema__cryptoticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ema = client.get_ema( - ticker="X:BTCUSD", - timespan="day", - window=50, - series_type="close", -) - -print(ema) diff --git a/examples/crypto-technical_indicators_macd.py b/examples/crypto-technical_indicators_macd.py deleted file mode 100644 index ee168d0..0000000 --- a/examples/crypto-technical_indicators_macd.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_indicators_macd__cryptoticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -macd = client.get_macd( - ticker="X:BTCUSD", - timespan="day", - short_window=12, - long_window=26, - signal_window=9, - series_type="close", -) - -print(macd) diff --git a/examples/crypto-technical_indicators_rsi.py b/examples/crypto-technical_indicators_rsi.py deleted file mode 100644 index 1eb3c01..0000000 --- a/examples/crypto-technical_indicators_rsi.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_indicators_rsi__cryptoticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rsi = client.get_rsi( - ticker="X:BTCUSD", - timespan="day", - window=14, - series_type="close", -) - -print(rsi) diff --git a/examples/crypto-technical_indicators_sma.py b/examples/crypto-technical_indicators_sma.py deleted file mode 100644 index e8d503f..0000000 --- a/examples/crypto-technical_indicators_sma.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v1_indicators_sma__cryptoticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -sma = client.get_sma( - ticker="X:BTCUSD", - timespan="day", - window=50, - series_type="close", -) - -print(sma) diff --git a/examples/crypto-tickers.py b/examples/crypto-tickers.py deleted file mode 100644 index 8eb0717..0000000 --- a/examples/crypto-tickers.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v3_reference_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = [] -for t in client.list_tickers(market="crypto", limit=1000): - tickers.append(t) -print(tickers) diff --git a/examples/crypto-trades.py b/examples/crypto-trades.py deleted file mode 100644 index 7cafd98..0000000 --- a/examples/crypto-trades.py +++ /dev/null @@ -1,15 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/crypto/get_v3_trades__cryptoticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#polygon.RESTClient.list_trades - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trades = [] -for t in client.list_trades("X:BTC-USD", "2023-02-01", limit=50000): - trades.append(t) - -# prints each trade that took place -print(trades) diff --git a/examples/financials.py b/examples/financials.py deleted file mode 100644 index f9e6dad..0000000 --- a/examples/financials.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -client = RESTClient() - -financials = client.get_ticker_details("NFLX") -print(financials) - -for i, n in enumerate(client.list_ticker_news("INTC", limit=5)): - print(i, n) - if i == 5: - break diff --git a/examples/forex-aggregates_bars.py b/examples/forex-aggregates_bars.py deleted file mode 100644 index b7ab233..0000000 --- a/examples/forex-aggregates_bars.py +++ /dev/null @@ -1,30 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# API key injected below for easy use. If not provided, the script will attempt -# to use the environment variable "POLYGON_API_KEY". -# -# setx POLYGON_API_KEY "" <- windows -# export POLYGON_API_KEY="" <- mac/linux -# -# Note: To persist the environment variable you need to add the above command -# to the shell startup script (e.g. .bashrc or .bash_profile. -# -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "C:EURUSD", - 1, - "day", - "2023-01-30", - "2023-02-03", - limit=50000, -): - aggs.append(a) - -print(aggs) diff --git a/examples/forex-conditions.py b/examples/forex-conditions.py deleted file mode 100644 index fca1e88..0000000 --- a/examples/forex-conditions.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v3_reference_conditions -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-conditions - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -conditions = [] -for c in client.list_conditions("fx", limit=1000): - conditions.append(c) -print(conditions) diff --git a/examples/forex-exchanges.py b/examples/forex-exchanges.py deleted file mode 100644 index e85b342..0000000 --- a/examples/forex-exchanges.py +++ /dev/null @@ -1,25 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - Exchange, -) - -# docs -# https://polygon.io/docs/options/get_v3_reference_exchanges -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-exchanges - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -exchanges = client.get_exchanges("fx") -print(exchanges) - -# loop over exchanges -for exchange in exchanges: - # verify this is an exchange - if isinstance(exchange, Exchange): - # print exchange info - print( - "{:<15}{} ({})".format( - exchange.asset_class, exchange.name, exchange.operating_mic - ) - ) diff --git a/examples/forex-grouped_daily_bars.py b/examples/forex-grouped_daily_bars.py deleted file mode 100644 index f813087..0000000 --- a/examples/forex-grouped_daily_bars.py +++ /dev/null @@ -1,22 +0,0 @@ -from polygon import RESTClient -import pprint - -# docs -# https://polygon.io/docs/forex/get_v2_aggs_grouped_locale_global_market_fx__date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-grouped-daily-aggs - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -grouped = client.get_grouped_daily_aggs( - "2023-03-27", - locale="global", - market_type="fx", -) - -# print(grouped) - -# pprint (short for "pretty-print") is a module that provides a more human- -# readable output format for data structures. -pp = pprint.PrettyPrinter(indent=2) -pp.pprint(grouped) diff --git a/examples/forex-last_quote_for_a_currency_pair.py b/examples/forex-last_quote_for_a_currency_pair.py deleted file mode 100644 index 8b3c78b..0000000 --- a/examples/forex-last_quote_for_a_currency_pair.py +++ /dev/null @@ -1,15 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_last_quote_currencies__from___to -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#get-last-forex-quote - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -quote = client.get_last_forex_quote( - "AUD", - "USD", -) - -print(quote) diff --git a/examples/forex-market_holidays.py b/examples/forex-market_holidays.py deleted file mode 100644 index 70c03f4..0000000 --- a/examples/forex-market_holidays.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - MarketHoliday, -) - -# docs -# https://polygon.io/docs/forex/get_v1_marketstatus_upcoming -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-holidays - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -holidays = client.get_market_holidays() -# print(holidays) - -# print date, name, and exchange -for holiday in holidays: - # verify this is an exchange - if isinstance(holiday, MarketHoliday): - print("{:<15}{:<15} ({})".format(holiday.date, holiday.name, holiday.exchange)) diff --git a/examples/forex-market_status.py b/examples/forex-market_status.py deleted file mode 100644 index 06f544c..0000000 --- a/examples/forex-market_status.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_marketstatus_now -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-status - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -result = client.get_market_status() -print(result) diff --git a/examples/forex-previous_close.py b/examples/forex-previous_close.py deleted file mode 100644 index 0de1170..0000000 --- a/examples/forex-previous_close.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__prev -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-previous-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = client.get_previous_close_agg( - "C:EURUSD", -) - -print(aggs) diff --git a/examples/forex-quotes.py b/examples/forex-quotes.py deleted file mode 100644 index 880ebca..0000000 --- a/examples/forex-quotes.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v3_quotes__fxticker -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#list-quotes - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -quotes = [] -for t in client.list_quotes("C:EUR-USD", "2023-02-01", limit=50000): - quotes.append(t) -print(quotes) diff --git a/examples/forex-real-time_currency_conversion.py b/examples/forex-real-time_currency_conversion.py deleted file mode 100644 index b50099c..0000000 --- a/examples/forex-real-time_currency_conversion.py +++ /dev/null @@ -1,15 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_conversion__from___to -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#get-real-time-currency-conversion - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rate = client.get_real_time_currency_conversion( - "AUD", - "USD", -) - -print(rate) diff --git a/examples/forex-snapshots_all_tickers.py b/examples/forex-snapshots_all_tickers.py deleted file mode 100644 index 8e0ec6b..0000000 --- a/examples/forex-snapshots_all_tickers.py +++ /dev/null @@ -1,41 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, - Agg, -) - -# docs -# https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-all-snapshots - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -snapshot = client.get_snapshot_all("forex") # all tickers - -# print raw values -print(snapshot) - -# crunch some numbers -for item in snapshot: - # verify this is an TickerSnapshot - if isinstance(item, TickerSnapshot): - # verify this is an Agg - if isinstance(item.prev_day, Agg): - # verify this is a float - if isinstance(item.prev_day.open, float) and isinstance( - item.prev_day.close, float - ): - percent_change = ( - (item.prev_day.close - item.prev_day.open) - / item.prev_day.open - * 100 - ) - print( - "{:<15}{:<15}{:<15}{:.2f} %".format( - item.ticker, - item.prev_day.open, - item.prev_day.close, - percent_change, - ) - ) diff --git a/examples/forex-snapshots_gainers_losers.py b/examples/forex-snapshots_gainers_losers.py deleted file mode 100644 index dd064e6..0000000 --- a/examples/forex-snapshots_gainers_losers.py +++ /dev/null @@ -1,37 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, -) - -# docs -# https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex__direction -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-gainers-losers-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# get gainers -gainers = client.get_snapshot_direction("forex", "gainers") -# print(gainers) - -# print ticker with % change -for gainer in gainers: - # verify this is a TickerSnapshot - if isinstance(gainer, TickerSnapshot): - # verify this is a float - if isinstance(gainer.todays_change_percent, float): - print("{:<15}{:.2f} %".format(gainer.ticker, gainer.todays_change_percent)) - -print() - -# get losers -losers = client.get_snapshot_direction("forex", "losers") -# print(losers) - -# print ticker with % change -for loser in losers: - # verify this is a TickerSnapshot - if isinstance(loser, TickerSnapshot): - # verify this is a float - if isinstance(loser.todays_change_percent, float): - print("{:<15}{:.2f} %".format(loser.ticker, loser.todays_change_percent)) diff --git a/examples/forex-snapshots_ticker.py b/examples/forex-snapshots_ticker.py deleted file mode 100644 index 9dbfc0f..0000000 --- a/examples/forex-snapshots_ticker.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers__ticker -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-ticker-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ticker = client.get_snapshot_ticker("forex", "C:EURUSD") -print(ticker) diff --git a/examples/forex-technical_indicators_ema.py b/examples/forex-technical_indicators_ema.py deleted file mode 100644 index ba67ee8..0000000 --- a/examples/forex-technical_indicators_ema.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_indicators_ema__fxticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ema = client.get_ema( - ticker="C:EURUSD", - timespan="day", - window=50, - series_type="close", -) - -print(ema) diff --git a/examples/forex-technical_indicators_macd.py b/examples/forex-technical_indicators_macd.py deleted file mode 100644 index ee32c4b..0000000 --- a/examples/forex-technical_indicators_macd.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_indicators_macd__fxticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -macd = client.get_macd( - ticker="C:EURUSD", - timespan="day", - short_window=12, - long_window=26, - signal_window=9, - series_type="close", -) - -print(macd) diff --git a/examples/forex-technical_indicators_rsi.py b/examples/forex-technical_indicators_rsi.py deleted file mode 100644 index a63185d..0000000 --- a/examples/forex-technical_indicators_rsi.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_indicators_rsi__fxticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rsi = client.get_rsi( - ticker="C:EURUSD", - timespan="day", - window=14, - series_type="close", -) - -print(rsi) diff --git a/examples/forex-technical_indicators_sma.py b/examples/forex-technical_indicators_sma.py deleted file mode 100644 index cd4aab2..0000000 --- a/examples/forex-technical_indicators_sma.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v1_indicators_sma__fxticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -sma = client.get_sma( - ticker="C:EURUSD", - timespan="day", - window=50, - series_type="close", -) - -print(sma) diff --git a/examples/forex-tickers.py b/examples/forex-tickers.py deleted file mode 100644 index c173672..0000000 --- a/examples/forex-tickers.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/forex/get_v3_reference_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = [] -for t in client.list_tickers(market="fx", limit=1000): - tickers.append(t) -print(tickers) diff --git a/examples/indices-aggregates_bars.py b/examples/indices-aggregates_bars.py deleted file mode 100644 index b2b561a..0000000 --- a/examples/indices-aggregates_bars.py +++ /dev/null @@ -1,30 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# API key injected below for easy use. If not provided, the script will attempt -# to use the environment variable "POLYGON_API_KEY". -# -# setx POLYGON_API_KEY "" <- windows -# export POLYGON_API_KEY="" <- mac/linux -# -# Note: To persist the environment variable you need to add the above command -# to the shell startup script (e.g. .bashrc or .bash_profile. -# -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "I:SPX", - 1, - "day", - "2023-03-10", - "2023-05-12", - limit=50000, -): - aggs.append(a) - -print(aggs) diff --git a/examples/indices-daily_open_close.py b/examples/indices-daily_open_close.py deleted file mode 100644 index f84a51a..0000000 --- a/examples/indices-daily_open_close.py +++ /dev/null @@ -1,16 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_open-close__indicesticker___date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-daily-open-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# make request -request = client.get_daily_open_close_agg( - "I:SPX", - "2023-03-28", -) - -print(request) diff --git a/examples/indices-market_holidays.py b/examples/indices-market_holidays.py deleted file mode 100644 index 0bf112d..0000000 --- a/examples/indices-market_holidays.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - MarketHoliday, -) - -# docs -# https://polygon.io/docs/indices/get_v1_marketstatus_upcoming -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-holidays - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -holidays = client.get_market_holidays() -# print(holidays) - -# print date, name, and exchange -for holiday in holidays: - # verify this is an exchange - if isinstance(holiday, MarketHoliday): - print("{:<15}{:<15} ({})".format(holiday.date, holiday.name, holiday.exchange)) diff --git a/examples/indices-market_status.py b/examples/indices-market_status.py deleted file mode 100644 index 6c74dee..0000000 --- a/examples/indices-market_status.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_marketstatus_now -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-status - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -result = client.get_market_status() -print(result) diff --git a/examples/indices-previous_close.py b/examples/indices-previous_close.py deleted file mode 100644 index 8774bd6..0000000 --- a/examples/indices-previous_close.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__prev -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-previous-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = client.get_previous_close_agg( - "I:SPX", -) - -print(aggs) diff --git a/examples/indices-snapshots.py b/examples/indices-snapshots.py deleted file mode 100644 index 407d2de..0000000 --- a/examples/indices-snapshots.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v3_snapshot_indices -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/snapshot.py# - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = ["I:SPX", "I:DJI", "I:VIX"] -snapshot = client.get_snapshot_indices(tickers) - -# print raw values -print(snapshot) diff --git a/examples/indices-technical_indicators_ema.py b/examples/indices-technical_indicators_ema.py deleted file mode 100644 index bacf9e8..0000000 --- a/examples/indices-technical_indicators_ema.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_indicators_ema__indicesticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ema = client.get_ema( - ticker="I:SPX", - timespan="day", - window=50, - series_type="close", -) - -print(ema) diff --git a/examples/indices-technical_indicators_macd.py b/examples/indices-technical_indicators_macd.py deleted file mode 100644 index bb3950d..0000000 --- a/examples/indices-technical_indicators_macd.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_indicators_macd__indicesticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -macd = client.get_macd( - ticker="I:SPX", - timespan="day", - short_window=12, - long_window=26, - signal_window=9, - series_type="close", -) - -print(macd) diff --git a/examples/indices-technical_indicators_rsi.py b/examples/indices-technical_indicators_rsi.py deleted file mode 100644 index ec5ca4d..0000000 --- a/examples/indices-technical_indicators_rsi.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_indicators_rsi__indicesticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rsi = client.get_rsi( - ticker="I:SPX", - timespan="day", - window=14, - series_type="close", -) - -print(rsi) diff --git a/examples/indices-technical_indicators_sma.py b/examples/indices-technical_indicators_sma.py deleted file mode 100644 index 1dfa7b7..0000000 --- a/examples/indices-technical_indicators_sma.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v1_indicators_sma__indicesticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -sma = client.get_sma( - ticker="I:SPX", - timespan="day", - window=50, - series_type="close", -) - -print(sma) diff --git a/examples/indices-ticker_types.py b/examples/indices-ticker_types.py deleted file mode 100644 index ec3277e..0000000 --- a/examples/indices-ticker_types.py +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Optional, Union, List -from urllib3 import HTTPResponse -from polygon import RESTClient -from polygon.rest.models import ( - TickerTypes, -) - -# docs -# https://polygon.io/docs/indices/get_v3_reference_tickers_types -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-ticker-types - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -types: Optional[Union[List[TickerTypes], HTTPResponse]] = None - -try: - types = client.get_ticker_types("indices") -except TypeError as e: - if "not NoneType" in str(e): - print("None found") - types = None - else: - raise - -if types is not None: - print(types) diff --git a/examples/indices-tickers.py b/examples/indices-tickers.py deleted file mode 100644 index a0786f1..0000000 --- a/examples/indices-tickers.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/indices/get_v3_reference_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = [] -for t in client.list_tickers(market="indices", limit=1000): - tickers.append(t) -print(tickers) diff --git a/examples/options-aggregates_bars.py b/examples/options-aggregates_bars.py deleted file mode 100644 index 62e3297..0000000 --- a/examples/options-aggregates_bars.py +++ /dev/null @@ -1,30 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# API key injected below for easy use. If not provided, the script will attempt -# to use the environment variable "POLYGON_API_KEY". -# -# setx POLYGON_API_KEY "" <- windows -# export POLYGON_API_KEY="" <- mac/linux -# -# Note: To persist the environment variable you need to add the above command -# to the shell startup script (e.g. .bashrc or .bash_profile. -# -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "O:SPY251219C00650000", - 1, - "day", - "2023-01-30", - "2023-02-03", - limit=50000, -): - aggs.append(a) - -print(aggs) diff --git a/examples/options-conditions.py b/examples/options-conditions.py deleted file mode 100644 index 3d72e3e..0000000 --- a/examples/options-conditions.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_reference_conditions -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-conditions - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -conditions = [] -for c in client.list_conditions("options", limit=1000): - conditions.append(c) -print(conditions) diff --git a/examples/options-contract.py b/examples/options-contract.py deleted file mode 100644 index f87c161..0000000 --- a/examples/options-contract.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_reference_options_contracts__options_ticker -# https://polygon-api-client.readthedocs.io/en/latest/Contracts.html - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -contract = client.get_options_contract("O:EVRI240119C00002500") - -# print raw values -print(contract) diff --git a/examples/options-contracts.py b/examples/options-contracts.py deleted file mode 100644 index 34d7327..0000000 --- a/examples/options-contracts.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_reference_options_contracts -# https://polygon-api-client.readthedocs.io/en/latest/Contracts.html#list-options-contracts - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -contracts = [] -for c in client.list_options_contracts("HCP"): - contracts.append(c) -print(contracts) diff --git a/examples/options-daily_open_close.py b/examples/options-daily_open_close.py deleted file mode 100644 index 54a700c..0000000 --- a/examples/options-daily_open_close.py +++ /dev/null @@ -1,16 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_open-close__optionsticker___date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-daily-open-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# make request -request = client.get_daily_open_close_agg( - "O:SPY251219C00650000", - "2023-02-22", -) - -print(request) diff --git a/examples/options-exchanges.py b/examples/options-exchanges.py deleted file mode 100644 index 881eed3..0000000 --- a/examples/options-exchanges.py +++ /dev/null @@ -1,25 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - Exchange, -) - -# docs -# https://polygon.io/docs/options/get_v3_reference_exchanges -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-exchanges - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -exchanges = client.get_exchanges("options") -print(exchanges) - -# loop over exchanges -for exchange in exchanges: - # verify this is an exchange - if isinstance(exchange, Exchange): - # print exchange info - print( - "{:<15}{} ({})".format( - exchange.asset_class, exchange.name, exchange.operating_mic - ) - ) diff --git a/examples/options-last_trade.py b/examples/options-last_trade.py deleted file mode 100644 index bf3e766..0000000 --- a/examples/options-last_trade.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v2_last_trade__optionsticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#get-last-trade - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trade = client.get_last_trade( - "O:TSLA210903C00700000", -) - -print(trade) diff --git a/examples/options-market_holidays.py b/examples/options-market_holidays.py deleted file mode 100644 index d6b03ab..0000000 --- a/examples/options-market_holidays.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - MarketHoliday, -) - -# docs -# https://polygon.io/docs/options/get_v1_marketstatus_upcoming -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-holidays - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -holidays = client.get_market_holidays() -# print(holidays) - -# print date, name, and exchange -for holiday in holidays: - # verify this is an exchange - if isinstance(holiday, MarketHoliday): - print("{:<15}{:<15} ({})".format(holiday.date, holiday.name, holiday.exchange)) diff --git a/examples/options-market_status.py b/examples/options-market_status.py deleted file mode 100644 index fb8e5cc..0000000 --- a/examples/options-market_status.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_marketstatus_now -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-status - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -result = client.get_market_status() -print(result) diff --git a/examples/options-previous_close.py b/examples/options-previous_close.py deleted file mode 100644 index f7b9d06..0000000 --- a/examples/options-previous_close.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__prev -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-previous-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = client.get_previous_close_agg( - "O:SPY251219C00650000", -) - -print(aggs) diff --git a/examples/options-quotes.py b/examples/options-quotes.py deleted file mode 100644 index 71d2577..0000000 --- a/examples/options-quotes.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_quotes__optionsticker -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#list-quotes - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -quotes = [] -for t in client.list_quotes("O:SPY241220P00720000", limit=50000): - quotes.append(t) -print(quotes) diff --git a/examples/options-snapshots_option_contract.py b/examples/options-snapshots_option_contract.py deleted file mode 100644 index 280e331..0000000 --- a/examples/options-snapshots_option_contract.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset___optioncontract -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -snapshot = client.get_snapshot_option("AAPL", "O:AAPL230616C00150000") - -# print raw values -print(snapshot) diff --git a/examples/options-snapshots_options_chain.py b/examples/options-snapshots_options_chain.py deleted file mode 100644 index 9ebdd93..0000000 --- a/examples/options-snapshots_options_chain.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset -# ttps://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-all-snapshots - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -options_chain = [] -for o in client.list_snapshot_options_chain( - "HCP", - params={ - "expiration_date.gte": "2024-03-16", - "strike_price.gte": 20, - }, -): - options_chain.append(o) -print(options_chain) diff --git a/examples/options-technical_indicators_ema.py b/examples/options-technical_indicators_ema.py deleted file mode 100644 index ff04ff7..0000000 --- a/examples/options-technical_indicators_ema.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_indicators_ema__optionsticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ema = client.get_ema( - ticker="O:SPY241220P00720000", timespan="day", window=50, series_type="close" -) - -print(ema) diff --git a/examples/options-technical_indicators_macd.py b/examples/options-technical_indicators_macd.py deleted file mode 100644 index e7961c8..0000000 --- a/examples/options-technical_indicators_macd.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_indicators_macd__optionsticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -macd = client.get_macd( - ticker="O:SPY241220P00720000", - timespan="day", - short_window=12, - long_window=26, - signal_window=9, - series_type="close", -) - -print(macd) diff --git a/examples/options-technical_indicators_rsi.py b/examples/options-technical_indicators_rsi.py deleted file mode 100644 index 4bf9ebd..0000000 --- a/examples/options-technical_indicators_rsi.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_indicators_rsi__optionsticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rsi = client.get_rsi( - ticker="O:SPY241220P00720000", timespan="day", window=14, series_type="close" -) - -print(rsi) diff --git a/examples/options-technical_indicators_sma.py b/examples/options-technical_indicators_sma.py deleted file mode 100644 index ce6f3d0..0000000 --- a/examples/options-technical_indicators_sma.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v1_indicators_sma__optionsticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -sma = client.get_sma( - ticker="O:SPY241220P00720000", timespan="day", window=50, series_type="close" -) - -print(sma) diff --git a/examples/options-ticker_details.py b/examples/options-ticker_details.py deleted file mode 100644 index 43d5915..0000000 --- a/examples/options-ticker_details.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_reference_tickers__ticker -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-ticker-details - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -details = client.get_ticker_details("TSLA") -print(details) diff --git a/examples/options-ticker_news.py b/examples/options-ticker_news.py deleted file mode 100644 index be9497d..0000000 --- a/examples/options-ticker_news.py +++ /dev/null @@ -1,24 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerNews, -) - -# docs -# https://polygon.io/docs/options/get_v2_reference_news -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-ticker-news - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -news = [] -for n in client.list_ticker_news("AAPL", order="desc", limit=1000): - news.append(n) - -# print date + title -for index, item in enumerate(news): - # verify this is an agg - if isinstance(item, TickerNews): - print("{:<25}{:<15}".format(item.published_utc, item.title)) - - if index == 20: - break diff --git a/examples/options-tickers.py b/examples/options-tickers.py deleted file mode 100644 index d77ef64..0000000 --- a/examples/options-tickers.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_reference_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = [] -for t in client.list_tickers(limit=1000): - tickers.append(t) -print(tickers) diff --git a/examples/options-trades.py b/examples/options-trades.py deleted file mode 100644 index 210362d..0000000 --- a/examples/options-trades.py +++ /dev/null @@ -1,15 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/options/get_v3_trades__optionsticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#polygon.RESTClient.list_trades - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trades = [] -for t in client.list_trades("O:TSLA210903C00700000", limit=50000): - trades.append(t) - -# prints each trade that took place -print(trades) diff --git a/examples/stocks-aggregates_bars.py b/examples/stocks-aggregates_bars.py deleted file mode 100644 index c553b00..0000000 --- a/examples/stocks-aggregates_bars.py +++ /dev/null @@ -1,30 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# API key injected below for easy use. If not provided, the script will attempt -# to use the environment variable "POLYGON_API_KEY". -# -# setx POLYGON_API_KEY "" <- windows -# export POLYGON_API_KEY="" <- mac/linux -# -# Note: To persist the environment variable you need to add the above command -# to the shell startup script (e.g. .bashrc or .bash_profile. -# -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "AAPL", - 1, - "minute", - "2022-01-01", - "2023-02-03", - limit=50000, -): - aggs.append(a) - -print(aggs) diff --git a/examples/stocks-aggregates_bars_extra.py b/examples/stocks-aggregates_bars_extra.py deleted file mode 100644 index 4fd76c3..0000000 --- a/examples/stocks-aggregates_bars_extra.py +++ /dev/null @@ -1,78 +0,0 @@ -# This code retrieves stock market data for a specific stock using the -# Polygon REST API and writes it to a CSV file. It uses the "polygon" -# library to communicate with the API and the "csv" library to write -# the data to a CSV file. The script retrieves data for the stock "AAPL" -# for the dates "2023-01-30" to "2023-02-03" in 1 hour intervals. The -# resulting data includes the open, high, low, close, volume, vwap, -# timestamp, transactions, and otc values for each hour. The output is -# then printed to the console. -from polygon import RESTClient -from polygon.rest.models import ( - Agg, -) -import csv -import datetime -import io - -# docs -# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "AAPL", - 1, - "hour", - "2023-01-30", - "2023-02-03", - limit=50000, -): - aggs.append(a) - -print(aggs) - -# headers -headers = [ - "timestamp", - "open", - "high", - "low", - "close", - "volume", - "vwap", - "transactions", - "otc", -] - -# creating the csv string -csv_string = io.StringIO() -writer = csv.DictWriter(csv_string, fieldnames=headers) - -# writing headers -writer.writeheader() - -# writing data -for agg in aggs: - # verify this is an agg - if isinstance(agg, Agg): - # verify this is an int - if isinstance(agg.timestamp, int): - writer.writerow( - { - "timestamp": datetime.datetime.fromtimestamp(agg.timestamp / 1000), - "open": agg.open, - "high": agg.high, - "low": agg.low, - "close": agg.close, - "volume": agg.volume, - "vwap": agg.vwap, - "transactions": agg.transactions, - "otc": agg.otc, - } - ) - -# printing the csv string -print(csv_string.getvalue()) diff --git a/examples/stocks-aggregates_bars_highcharts.py b/examples/stocks-aggregates_bars_highcharts.py deleted file mode 100644 index b252997..0000000 --- a/examples/stocks-aggregates_bars_highcharts.py +++ /dev/null @@ -1,136 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - Agg, -) -import datetime -import http.server -import socketserver -import traceback -import json - -# This program retrieves stock price data for the AAPL stock from the Polygon -# API using a REST client, and formats the data in a format expected by the -# Highcharts JavaScript library. The program creates a web server that serves -# an HTML page that includes a candlestick chart of the AAPL stock prices using -# Highcharts. The chart displays data for the time range from January 1, 2019, -# to February 16, 2023. The chart data is updated by retrieving the latest data -# from the Polygon API every time the HTML page is loaded or refreshed. The -# server listens on port 8888 and exits gracefully when a KeyboardInterrupt is -# received. -# -# Connect to http://localhost:8888 in your browser to view candlestick chart. - -PORT = 8888 - -# https://www.highcharts.com/blog/products/stock/ -# JavaScript StockChart with Date-Time Axis -html = """ - - - - - - - - - - - -
- - - - -""" - -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = [] -for a in client.list_aggs( - "AAPL", - 1, - "day", - "2019-01-01", - "2023-02-16", - limit=50000, -): - aggs.append(a) - -# print(aggs) - -data = [] - -# writing data -for agg in aggs: - # verify this is an agg - if isinstance(agg, Agg): - # verify this is an int - if isinstance(agg.timestamp, int): - new_record = { - "date": agg.timestamp, - "open": agg.open, - "high": agg.high, - "low": agg.low, - "close": agg.close, - "volume": agg.volume, - } - - data.append(new_record) - -values = [[v for k, v in d.items()] for d in data] - -# json_data = json.dumps(data) -# print(json_data) - - -class handler(http.server.SimpleHTTPRequestHandler): - def do_GET(self): - if self.path == "/data": - self.send_response(200) - self.send_header("Content-type", "application/json") - self.end_headers() - json_data = json.dumps(values) - self.wfile.write(json_data.encode()) - else: - self.send_response(200) - self.send_header("Content-type", "text/html") - self.end_headers() - self.wfile.write(html.encode()) - - -# handle ctrl-c KeyboardInterrupt to exit the program gracefully -try: - while True: - # run http server - with socketserver.TCPServer(("", PORT), handler) as httpd: - print("serving at port", PORT) - httpd.serve_forever() - pass -except KeyboardInterrupt: - print("\nExiting gracefully...") - # traceback.print_exc() diff --git a/examples/stocks-conditions.py b/examples/stocks-conditions.py deleted file mode 100644 index 1be9b48..0000000 --- a/examples/stocks-conditions.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_conditions -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-conditions - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -conditions = [] -for c in client.list_conditions(limit=1000): - conditions.append(c) -print(conditions) diff --git a/examples/stocks-daily_open_close.py b/examples/stocks-daily_open_close.py deleted file mode 100644 index 65c9626..0000000 --- a/examples/stocks-daily_open_close.py +++ /dev/null @@ -1,16 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_open-close__stocksticker___date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-daily-open-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# make request -request = client.get_daily_open_close_agg( - "AAPL", - "2023-02-07", -) - -print(request) diff --git a/examples/stocks-dividends.py b/examples/stocks-dividends.py deleted file mode 100644 index 75cd795..0000000 --- a/examples/stocks-dividends.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_dividends -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-dividends - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -dividends = [] -for d in client.list_dividends("MSFT", limit=1000): - dividends.append(d) -print(dividends) diff --git a/examples/stocks-exchanges.py b/examples/stocks-exchanges.py deleted file mode 100644 index 20c9477..0000000 --- a/examples/stocks-exchanges.py +++ /dev/null @@ -1,25 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - Exchange, -) - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_exchanges -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-exchanges - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -exchanges = client.get_exchanges() -print(exchanges) - -# loop over exchanges -for exchange in exchanges: - # verify this is an exchange - if isinstance(exchange, Exchange): - # print exchange info - print( - "{:<15}{} ({})".format( - exchange.asset_class, exchange.name, exchange.operating_mic - ) - ) diff --git a/examples/stocks-grouped_daily_bars.py b/examples/stocks-grouped_daily_bars.py deleted file mode 100644 index ea0ff1c..0000000 --- a/examples/stocks-grouped_daily_bars.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -import pprint - -# docs -# https://polygon.io/docs/stocks/get_v2_aggs_grouped_locale_us_market_stocks__date -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-grouped-daily-aggs - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -grouped = client.get_grouped_daily_aggs( - "2023-02-16", -) - -# print(grouped) - -# pprint (short for "pretty-print") is a module that provides a more human- -# readable output format for data structures. -pp = pprint.PrettyPrinter(indent=2) -pp.pprint(grouped) diff --git a/examples/stocks-last_quote.py b/examples/stocks-last_quote.py deleted file mode 100644 index 15b83e5..0000000 --- a/examples/stocks-last_quote.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v2_last_nbbo__stocksticker -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#get-last-quote - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -quote = client.get_last_quote( - "AAPL", -) - -print(quote) diff --git a/examples/stocks-last_trade.py b/examples/stocks-last_trade.py deleted file mode 100644 index 42278ba..0000000 --- a/examples/stocks-last_trade.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v2_last_trade__stocksticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#get-last-trade - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trade = client.get_last_trade( - "AAPL", -) - -print(trade) diff --git a/examples/stocks-market_holidays.py b/examples/stocks-market_holidays.py deleted file mode 100644 index 054bfa8..0000000 --- a/examples/stocks-market_holidays.py +++ /dev/null @@ -1,20 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - MarketHoliday, -) - -# docs -# https://polygon.io/docs/stocks/get_v1_marketstatus_upcoming -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-holidays - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -holidays = client.get_market_holidays() -# print(holidays) - -# print date, name, and exchange -for holiday in holidays: - # verify this is an exchange - if isinstance(holiday, MarketHoliday): - print("{:<15}{:<15} ({})".format(holiday.date, holiday.name, holiday.exchange)) diff --git a/examples/stocks-market_status.py b/examples/stocks-market_status.py deleted file mode 100644 index bd4362b..0000000 --- a/examples/stocks-market_status.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_marketstatus_now -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-market-status - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -result = client.get_market_status() -print(result) diff --git a/examples/stocks-previous_close.py b/examples/stocks-previous_close.py deleted file mode 100644 index 9785ab2..0000000 --- a/examples/stocks-previous_close.py +++ /dev/null @@ -1,14 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__prev -# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#get-previous-close-agg - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -aggs = client.get_previous_close_agg( - "AAPL", -) - -print(aggs) diff --git a/examples/stocks-quotes.py b/examples/stocks-quotes.py deleted file mode 100644 index 4d615da..0000000 --- a/examples/stocks-quotes.py +++ /dev/null @@ -1,21 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_quotes__stockticker -# https://polygon-api-client.readthedocs.io/en/latest/Quotes.html#list-quotes - -# NBBO (National Best Bid and Offer) is a term used in the financial industry -# to describe the best bid and offer prices for a particular stock or security -# being traded on all the available stock exchanges in the United States. It -# provides information on the highest price a buyer is willing to pay (best -# bid) and the lowest price a seller is willing to accept (best offer) for a -# particular security. This information is used by traders to make informed -# investment decisions and execute trades at the best available price. - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -quotes = [] -for t in client.list_quotes("IBIO", "2023-02-01", limit=50000): - quotes.append(t) -print(quotes) diff --git a/examples/stocks-snapshots_all.py b/examples/stocks-snapshots_all.py deleted file mode 100644 index d168298..0000000 --- a/examples/stocks-snapshots_all.py +++ /dev/null @@ -1,45 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, - Agg, -) - -# docs -# https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-all-snapshots - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# tickers we are interested in -tickers = ["TSLA", "AAPL", "MSFT", "META"] - -# snapshot = client.get_snapshot_all("stocks") # all tickers -snapshot = client.get_snapshot_all("stocks", tickers) - -# print raw values -print(snapshot) - -# crunch some numbers -for item in snapshot: - # verify this is an TickerSnapshot - if isinstance(item, TickerSnapshot): - # verify this is an Agg - if isinstance(item.prev_day, Agg): - # verify this is a float - if isinstance(item.prev_day.open, float) and isinstance( - item.prev_day.close, float - ): - percent_change = ( - (item.prev_day.close - item.prev_day.open) - / item.prev_day.open - * 100 - ) - print( - "{:<15}{:<15}{:<15}{:.2f} %".format( - item.ticker, - item.prev_day.open, - item.prev_day.close, - percent_change, - ) - ) diff --git a/examples/stocks-snapshots_gainers_losers.py b/examples/stocks-snapshots_gainers_losers.py deleted file mode 100644 index d0a0e36..0000000 --- a/examples/stocks-snapshots_gainers_losers.py +++ /dev/null @@ -1,37 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerSnapshot, -) - -# docs -# https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks__direction -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-gainers-losers-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# get gainers -gainers = client.get_snapshot_direction("stocks", "gainers") -# print(gainers) - -# print ticker with % change -for gainer in gainers: - # verify this is a TickerSnapshot - if isinstance(gainer, TickerSnapshot): - # verify this is a float - if isinstance(gainer.todays_change_percent, float): - print("{:<15}{:.2f} %".format(gainer.ticker, gainer.todays_change_percent)) - -print() - -# get losers -losers = client.get_snapshot_direction("stocks", "losers") -# print(losers) - -# print ticker with % change -for loser in losers: - # verify this is a TickerSnapshot - if isinstance(loser, TickerSnapshot): - # verify this is a float - if isinstance(loser.todays_change_percent, float): - print("{:<15}{:.2f} %".format(loser.ticker, loser.todays_change_percent)) diff --git a/examples/stocks-snapshots_ticker.py b/examples/stocks-snapshots_ticker.py deleted file mode 100644 index 2b26433..0000000 --- a/examples/stocks-snapshots_ticker.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers__stocksticker -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html#get-ticker-snapshot - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ticker = client.get_snapshot_ticker("stocks", "AAPL") -print(ticker) diff --git a/examples/stocks-stock_financials.py b/examples/stocks-stock_financials.py deleted file mode 100644 index dc35649..0000000 --- a/examples/stocks-stock_financials.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_vx_reference_financials -# https://polygon-api-client.readthedocs.io/en/latest/vX.html#list-stock-financials - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -financials = [] -for f in client.vx.list_stock_financials("AAPL"): - financials.append(f) -print(financials) diff --git a/examples/stocks-stock_splits.py b/examples/stocks-stock_splits.py deleted file mode 100644 index 5598097..0000000 --- a/examples/stocks-stock_splits.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_splits -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-splits - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -splits = [] -for s in client.list_splits("TSLA", limit=1000): - splits.append(s) -print(splits) diff --git a/examples/stocks-technical_indicators_ema.py b/examples/stocks-technical_indicators_ema.py deleted file mode 100644 index 20092d7..0000000 --- a/examples/stocks-technical_indicators_ema.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_indicators_ema__stockticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -ema = client.get_ema( - ticker="AAPL", - timespan="day", - window=50, - series_type="close", -) - -print(ema) diff --git a/examples/stocks-technical_indicators_macd.py b/examples/stocks-technical_indicators_macd.py deleted file mode 100644 index 187e8ae..0000000 --- a/examples/stocks-technical_indicators_macd.py +++ /dev/null @@ -1,19 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_indicators_macd__stockticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -macd = client.get_macd( - ticker="AAPL", - timespan="day", - short_window=12, - long_window=26, - signal_window=9, - series_type="close", -) - -print(macd) diff --git a/examples/stocks-technical_indicators_rsi.py b/examples/stocks-technical_indicators_rsi.py deleted file mode 100644 index a69d6ae..0000000 --- a/examples/stocks-technical_indicators_rsi.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_indicators_rsi__stockticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -rsi = client.get_rsi( - ticker="AAPL", - timespan="day", - window=14, - series_type="close", -) - -print(rsi) diff --git a/examples/stocks-technical_indicators_sma.py b/examples/stocks-technical_indicators_sma.py deleted file mode 100644 index 41a9c7c..0000000 --- a/examples/stocks-technical_indicators_sma.py +++ /dev/null @@ -1,17 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v1_indicators_sma__stockticker -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/indicators.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -sma = client.get_sma( - ticker="AAPL", - timespan="day", - window=50, - series_type="close", -) - -print(sma) diff --git a/examples/stocks-ticker_details.py b/examples/stocks-ticker_details.py deleted file mode 100644 index 5f81b4b..0000000 --- a/examples/stocks-ticker_details.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_tickers__ticker -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-ticker-details - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -details = client.get_ticker_details("AAPL") -print(details) diff --git a/examples/stocks-ticker_events.py b/examples/stocks-ticker_events.py deleted file mode 100644 index 09b1343..0000000 --- a/examples/stocks-ticker_events.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_vx_reference_tickers__id__events -# https://github.com/polygon-io/client-python/blob/master/polygon/rest/reference.py - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -events = client.get_ticker_events("META") -print(events) diff --git a/examples/stocks-ticker_news.py b/examples/stocks-ticker_news.py deleted file mode 100644 index fa83489..0000000 --- a/examples/stocks-ticker_news.py +++ /dev/null @@ -1,26 +0,0 @@ -from polygon import RESTClient -from polygon.rest.models import ( - TickerNews, -) - -# docs -# https://polygon.io/docs/stocks/get_v2_reference_news -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-ticker-news - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -news = [] -for n in client.list_ticker_news("BBBY", order="desc", limit=1000): - news.append(n) - -# print(news) - -# print date + title -for index, item in enumerate(news): - # verify this is an agg - if isinstance(item, TickerNews): - print("{:<25}{:<15}".format(item.published_utc, item.title)) - - if index == 20: - break diff --git a/examples/stocks-ticker_types.py b/examples/stocks-ticker_types.py deleted file mode 100644 index fa09338..0000000 --- a/examples/stocks-ticker_types.py +++ /dev/null @@ -1,11 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_tickers_types -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#get-ticker-types - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -types = client.get_ticker_types() -print(types) diff --git a/examples/stocks-tickers.py b/examples/stocks-tickers.py deleted file mode 100644 index 7fc0923..0000000 --- a/examples/stocks-tickers.py +++ /dev/null @@ -1,13 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_reference_tickers -# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -tickers = [] -for t in client.list_tickers(market="stocks", type="CS", active=True, limit=1000): - tickers.append(t) -print(tickers) diff --git a/examples/stocks-trades.py b/examples/stocks-trades.py deleted file mode 100644 index 8f2f147..0000000 --- a/examples/stocks-trades.py +++ /dev/null @@ -1,21 +0,0 @@ -from polygon import RESTClient - -# docs -# https://polygon.io/docs/stocks/get_v3_trades__stockticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#polygon.RESTClient.list_trades - -# Trade data refers to the tick records of individual transactions that have -# taken place in a financial market, such as the price, size, and time of -# each trade. It provides a high-frequency, granular view of market activity, -# and is used by traders, investors, and researchers to gain insights into -# market behavior and inform their investment decisions. - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -trades = [] -for t in client.list_trades("IBIO", "2023-02-01", limit=50000): - trades.append(t) - -# prints each trade that took place -print(trades) diff --git a/examples/stocks-trades_extra.py b/examples/stocks-trades_extra.py deleted file mode 100644 index 1fcf566..0000000 --- a/examples/stocks-trades_extra.py +++ /dev/null @@ -1,27 +0,0 @@ -# This code retrieves trade records and counts the amount of money that changes hands. -from polygon import RESTClient -from polygon.rest.models import ( - Trade, -) - -# docs -# https://polygon.io/docs/stocks/get_v3_trades__stockticker -# https://polygon-api-client.readthedocs.io/en/latest/Trades.html#polygon.RESTClient.list_trades - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - -# used to track money across trades -money = float(0) - -# loop through and count price * volume -for t in client.list_trades("DIS", "2023-02-07", limit=50000): - # verify this is an Trade - if isinstance(t, Trade): - # verify these are float - if isinstance(t.price, float) and isinstance(t.size, int): - money += t.price * t.size - -# format the number so it's human readable -formatted_number = "{:,.2f}".format(money) -print("Roughly " + formatted_number + " changed hands for DIS on 2023-02-07.") diff --git a/examples/universal-snapshot.py b/examples/universal-snapshot.py deleted file mode 100644 index 1ab5e80..0000000 --- a/examples/universal-snapshot.py +++ /dev/null @@ -1,47 +0,0 @@ -from typing import cast, Iterator, Union -from urllib3 import HTTPResponse -from polygon import RESTClient -from polygon.rest.models import UniversalSnapshot, SnapshotMarketType - -# docs -# https://polygon.io/docs/stocks/get_v3_snapshot -# https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html - -# client = RESTClient("XXXXXX") # hardcoded api_key is used -client = RESTClient() # POLYGON_API_KEY environment variable is used - - -def print_snapshots(iterator: Union[Iterator[UniversalSnapshot], HTTPResponse]): - snapshots = [s for s in iterator] - - print(f"count: {len(snapshots)}") - - for item in snapshots: - print(item) - - -# it = client.list_universal_snapshots() # all tickers for all assets types in lexicographical order - -it = client.list_universal_snapshots( - ticker_any_of=[ - "AAPL", - "O:AAPL230519C00055000", - "DOES_NOT_EXIST", - "X:1INCHUSD", - "C:AEDAUD", - ] -) -print_snapshots(it) - -it = client.list_universal_snapshots(type="stocks", ticker_gt="A", ticker_lt="AAPL") -print_snapshots(it) - -it = client.list_universal_snapshots(type="stocks", ticker_gte="AAPL", ticker_lte="ABB") -print_snapshots(it) - -it = client.list_universal_snapshots( - type="options", - ticker_gte="O:AAPL230804C00050000", - ticker_lte="O:AAPL230804C00070000", -) -print_snapshots(it) diff --git a/git_push.sh b/git_push.sh deleted file mode 100644 index f53a75d..0000000 --- a/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https'