Skip to main content

Trading Bot Club alpaca api

Project description

tbc-ken-lib

This lib is made for to be used by members of the TBC club made in 2022.

Install

$ pip install tbc-ken-lib

Supported Features

tbc-ken-lib has and will only have functions that will be used for the project. Other functions that other Alpaca API clients may include that will not be used by the club will not be included in this lib.

Examples

Setup

Follow this link and generate an API key: https://app.alpaca.markets/paper/dashboard/overview Don't worry if you lose the key or forgot where you saved it. You can always regenerate them.

#example.py
import ken_api
api = ken_api.api(
    'XXXXXXXXXXXXXXXXXXXX',  # alpaca api key (20 characters in length)
    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"  # alpaca api secret (40 characters in length)
)  
# The alpaca api key and secret almost feels like user and password sometimes.
# If you don't have your own keys, you can use mine up there, though it is limitted to 200 api requests per minute.
# It's recommended to use your own keys. 

Get Assets

"""
This one returns you candle bars of the graph. 
You can specify the start, end, and even limit.

Get info of any stocks by putting in symbols. 
Put in simple=True to make the result come in a simple format. 
You can put in one symbol or many symbols. 
Without having the simple=True, it will return you much more data.
""" 
print(api.get_assets('SXNTF', "SWSSF", "MANR", simple=True))
print(api.get_assets('PCSGF', simple=True))
print(api.get_assets('PCSGF'))
print(api.get_bars("TSLA", start="2022-10-05", end="2022-10-15",limit=10))

Download Assets

"""
The function downloads a list of all stocks and assets Alpaca has, 
both active and inactive. It also takes no parameters
"""
api.download_symbols()
# This function doesn't return anything. The result will be downloaded as symbols_list in your current working directory without a file extension.

Patches

v0.3

To use this lib, it is recommended to put your own api **key** and **secret** in your api object parameters. If not, you will automatically use mine, which has it's limits.

v0.2 and bellow

To use the lib, touch alpaca_credentials.json and place in it your credentials.

//alpaca_credentials.json
{
	"APCA-API-KEY-ID": "PKNOZUSMT0A6E89QURCG",
	"APCA-API-SECRET-KEY": "SXFTc5gC4cAWmUpuGEiEurBGfN4bAqhA6Mxu28Ez"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbc_ken_api-0.3.2.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file tbc_ken_api-0.3.2.tar.gz.

File metadata

  • Download URL: tbc_ken_api-0.3.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for tbc_ken_api-0.3.2.tar.gz
Algorithm Hash digest
SHA256 191e9e71789dd9c4979222142477e096410fe0d80634181346e765cf26bbd3f9
MD5 68861a84115b11c8f7d3779aaab2d6a5
BLAKE2b-256 0e37a031dba78d2089cfb39adf725bdef95a65da8bae6a25b646971fc0e3e342

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page