Exemplo n.º 1
0
''' An example on how to set up logging in.
You can store your encryption password in .test.env 
or in a file named .env with the following value

tda_encryption_passcode=keep_this_key_somewhere_safe
'''

import robin_stocks.tda as t
##!!! Optionally load environment variables from .env or .test.env
import os
from dotenv import load_dotenv
load_dotenv()
keep_this_key_somewhere_safe = os.environ["tda_encryption_passcode"]
##!!!

keep_this_key_somewhere_safe = t.generate_encryption_passcode()
print("here is a key you can use for encryption: ", keep_this_key_somewhere_safe)

#!!! Only call login_first_time once! Delete this code after running the first time!
t.login_first_time(
    keep_this_key_somewhere_safe,
    "client_id_goes_here",
    "authorization_token_goes_here",
    "refresh_token_goes_here")
#!!!

# Call login as much as you want.
t.login(os.environ["tda_encryption_passcode"])
Exemplo n.º 2
0
 def test_login(self):
     t.login(os.environ['tda_encryption_passcode'])
     assert t.get_login_state()
Exemplo n.º 3
0
# "G2aUpN+qXx61tNumt4aKThC7W0u8IvWmv1W7rSawftRxkskYUPgpVJSCZ4tmgXHmLlZu8r+uTIT5uBLMqN5peW8n4dAatdvLLLt7TFqcw63m7fCU6qaiWxhzaLF3QfPq7h3DPTCNVr+/SQmKOmqBi+t6KYyXGi94jTiQOB1BjkTmE9qPf35AL9cr5kKYbVXJEOeTNsedcFMXjo8+UCPLrtnW2rCFa1FOjmjMCxZX4M/RuwXVa/5+tTXq3+jOlBmabjz7SiDP42ooPVkhncBeXP4oq8zYnBnhLnLxx0falDcbFY1K8QZ6tftHsSFCjF9QkzigQpbyhAjaqfm7C+46+w/89I15eGJn9HsWyYNd2Y6f8LJg8bMoRtnQoqshwUEtSiJqfd2vq4TaabLn6snBcuBoj2m6qyDSfM6oQA/vM8PIYqzfmsI7gok6jWf100MQuG4LYrgoVi/JHHvl2iAD+MiwRt1Jcok/7oEYYXXBmA1DiKQSi8bRcOG2zSogi5JMtUiqV9YrHrZ0V0U2YwkxRT4JlUJPj/kU+09YUOn5qxnog5CvI4eGyndWLq7PRa3TJ7bEpEuMTW765C91Ei2SKKqBDfzpzjDkX6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FEpCJ%2Fl%2FG4Cb0bnJ0BMarONjR5J%2BPhk6xVzUrCaFI7%2Bho8IL9KGsJxZI7WaE1IHnpeJBaJMxqgSUa%2F6bOQgmuIUuOMdycCNVv59XO1tg7PvKAGJ3eGh3pmojy89Q28bhBpE9aJfAKqlke8HD26akrOgBZVD85ch13yTBCfuHPSkxZ9iy%2BXeYq78EU4WE7qV4ZfUjtzB2ZJOZzR%2FFRe0NpGuiRe0k1MOCnTsh5SgwNs%3D212FD3x19z9sWBHDJACbC00B75E"

# blah = t.generate_encryption_passcode()
# print(blah)
# print(type(blah))
# print(blah)
# print(blah.decode())
# print(type(blah.decode()))
print(t.login("w_Pt4oNsijRB_b5LdvjBZsM3uPE8uB0503lQk8kf7YE="))
# data, _ = t.get_account("233798512","orders", jsonify=False)
# print(type(data) == requests.models.Response)
# print(data)
order = {
    "orderType": "MARKET",
    "session": "NORMAL",
    "duration": "DAY",
    "orderStrategyType": "SINGLE",
    "orderLegCollection": [
        {
            "instruction": "Buy",
            "quantity": 1,
            "instrument": {
                "symbol": "AMC",
                "assetType": "EQUITY"
Exemplo n.º 4
0
 def setup_class(cls):
     t.login(os.environ['tda_encryption_passcode'])