Giter Club home page Giter Club logo

python-trading-robot's Introduction

Python Trading Robot

Table of Contents

Overview

Current Version: 0.1.1

A trading robot written in Python that can run automated strategies using a technical analysis. The robot is designed to mimic a few common scenarios:

  1. Maintaining a portfolio of multiple instruments. The Portfolio object will be able to calculate common risk metrics related to a portfolio and give real-time feedback as you trade.

  2. Define an order that can be used to trade a financial instrument. With the Trade object, you can define simple or even complex orders using Python. These orders will also help similify common scenarios like defining both a take profit and stop loss at the same time.

  3. A real-time data table that includes both historical and real-time prices as they change. The StockFrame will make the process of storing your data easy and quick. Additionally, it will be setup so that way you can easily select your financial data as it comes in and do further analysis if needed.

  4. Define and calculate indicators using both historical and real-time prices. The Indicator object will help you easily define the input of your indicators, calculate them, and then update their values as new prices come.

Setup

Setup - Local Install:

If you are planning to make modifications to this project or you would like to access it before it has been indexed on PyPi. I would recommend you either install this project in editable mode or do a local install. For those of you, who want to make modifications to this project. I would recommend you install the library in editable mode.

If you want to install the library in editable mode, make sure to run the setup.py file, so you can install any dependencies you may need. To run the setup.py file, run the following command in your terminal.

pip install -e .

If you don't plan to make any modifications to the project but still want to use it across your different projects, then do a local install.

pip install .

This will install all the dependencies listed in the setup.py file. Once done you can use the library wherever you want.

Setup - PyPi Install:

The project can be found at PyPI, if you'd like to view the project please use this link. To install the library, run the following command from the terminal.

pip install python-trading-robot

Setup - PyPi Upgrade:

To upgrade the library, run the following command from the terminal.

pip install --upgrade python-trading-robot

Usage

To run the robot, you will need to provide a few pieces of information from your TD Ameritrade Developer account. The following items are need for authentication:

  • Client ID: Also, called your consumer key, this was provided when you registered an app with the TD Ameritrade Developer platform. An example of a client ID could look like the following MMMMYYYYYA6444VXXXXBBJC3DOOOO.

  • Redirect URI: Also called the callbakc URL or redirect URL, this was specified by you when you regiestered your app with the TD Ameritrade Developer platform. Here is an example of a redirect URI https://localhost/mycallback

  • Credentials Path: This is a file path that will point to a JSON file where your state info will be saved. Keep in mind that it is okay if it points to a non-existing file as once you run the script the file will be auto generated. For example, if I want my state info to be saved to my desktop, then it would look like the following: C:\Users\Desktop\ts_state.json

Once you've identfied those pieces of info, you can run the robot. Here is a simple example that will create a new instance of it:

from pyrobot.robot import PyRobot

# Initialize the robot
trading_robot = PyRobot(
    client_id='XXXXXX111111YYYY22',
    redirect_uri='https://localhost/mycallback',
    credentials_path='path/to/td_state.json'
)

For more detailed examples, go to the trading_robot.py file to see an example of how to use the library along with all the different objects inside.

Support these Projects

Patreon: Help support this project and future projects by donating to my Patreon Page. I'm always looking to add more content for individuals like yourself, unfortuantely some of the APIs I would require me to pay monthly fees.

YouTube: If you'd like to watch more of my content, feel free to visit my YouTube channel Sigma Coding.

python-trading-robot's People

Contributors

areed1192 avatar charleswwilson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-trading-robot's Issues

RSI Calculation

I'm a newer graduate (so I am not 100% confident in this), but I am pretty sure that the method used in this calculation is a standard weighted average instead of "Wilder's" weighted average. In order to get Wilder's we need to recursively calculate the average based on the previous averages. This can be fixed by changing the ewm method for up and down days to :

    # Calculate the EWMA for the Up days.
    self._frame['ewma_up'] = self._price_groups['up_day'].transform(
        lambda x: x.ewm(alpha=1.0 / period,adjust=False).mean()
    )

Also, when putting the Relative Strength index into the dataframe, the given method only returned values over 95. So I modified it to directly put the Relative strength index variable into the dataframe. Although, when I look at the given method, I am not sure why it doesn't work. Essentially no RSI values should ever be 0 or 100, so wouldn't the np.where statement parameters 0, 100 be essentially ignored?

    # Calculate the Relative Strength Index
    self._frame['rsi'] = 100.0 - (100.0 / (1.0 + relative_strength))

`bollinger_band` calculation method

Thanks for this project Alex! Awesome stuff.

Working on building a robot for tracking trades vs indicator readings and I noticed something looked funny with the bollinger_band indicator. Don't have much of a background in finance so it could be I'm misunderstanding something. You calculate the upper band as

self._frame['band_upper'] = 4 * (self._frame['moving_std'] / self._frame['moving_avg'])

which makes sense to me as 4 times the normalized standard dev, but then the lower band is calculated as

self._frame['band_lower'] = (
             (self._frame['close'] - self._frame['moving_avg']) +
              (2 * self._frame['moving_std']) /
              (4 * self._frame['moving_std'])
          )

Where that third term I believe just simplies to 1/2. I would've guessed based on how upper band is given that lower band would just be its negated version? Again, I'm a novice in finance so my thinking may just be incorrect here.

Unable to post to live account

I must not read instructions well. How does this post to my real account.

I got robot get_account to work. Still not sure how to place trades for real.

Not able to install python trading bot

Hi Alex,

treid installing editable mode with "pip install - e ." am getting the below responce.. Please let me know what component am missing.

PS C:\Users\mypc\Desktop\Trading\pyrobot\python-trading-robot> pip install -e .
Obtaining file:///C:/Users/mypc/Desktop/Trading/pyrobot/python-trading-robot
Requirement already satisfied: td-ameritrade-python-api>=0.3.0 in c:\users\mypc\desktop\trading\tda_pypi\td-ameritrade-python-api (from python-trading-robot==0.1.1)
(0.3.5)
Collecting pandas==1.0.5
Downloading pandas-1.0.5.tar.gz (5.0 MB)
|████████████████████████████████| 5.0 MB 3.3 MB/s
Installing build dependencies ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\mypc\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' 'C:\Users\mypc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.13' 'numpy==1.13.3; python_version=='"'"'3.6'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.6'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"''
cwd: None
Complete output (300 lines):
Ignoring numpy: markers 'python_version == "3.6" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system != "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.6" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version == "3.7" and platform_system == "AIX"' don't match your environment
Ignoring numpy: markers 'python_version >= "3.8" and platform_system == "AIX"' don't match your environment
Collecting setuptools
Downloading setuptools-56.0.0-py3-none-any.whl (784 kB)
Collecting wheel
Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Collecting Cython>=0.29.13
Downloading Cython-0.29.23-cp39-cp39-win_amd64.whl (1.7 MB)
Collecting numpy==1.17.3
Downloading numpy-1.17.3.zip (6.4 MB)
Using legacy 'setup.py install' for numpy, since package 'wheel' is not installed.
Installing collected packages: wheel, setuptools, numpy, Cython
Running setup.py install for numpy: started
Running setup.py install for numpy: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Users\mypc\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\setup.py'"'"'; file='"'"'C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\mypc\AppData\Local\Temp\pip-record-z8i0erw7\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay' --compile --install-headers
'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay\Include\numpy'
cwd: C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c
Complete output (277 lines):
Running from numpy source directory.

  Note: if you need reliable uninstall behavior, then install
  with pip instead of using `setup.py install`:

    - `pip install .`       (from a git repo or downloaded source
                             release)
    - `pip install numpy`   (last NumPy release on PyPi)


  blas_opt_info:
  blas_mkl_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries mkl_rt not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  blis_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries blis not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  openblas_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries openblas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
  get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
  customize GnuFCompiler
  Could not locate executable g77
  Could not locate executable f77
  customize IntelVisualFCompiler
  Could not locate executable ifort
  Could not locate executable ifl
  customize AbsoftFCompiler
  Could not locate executable f90
  customize CompaqVisualFCompiler
  Could not locate executable DF
  customize IntelItaniumVisualFCompiler
  Could not locate executable efl
  customize Gnu95FCompiler
  Could not locate executable gfortran
  Could not locate executable f95
  customize G95FCompiler
  Could not locate executable g95
  customize IntelEM64VisualFCompiler
  customize IntelEM64TFCompiler
  Could not locate executable efort
  Could not locate executable efc
  customize PGroupFlangCompiler
  Could not locate executable flang
  don't know how to compile Fortran code on platform 'nt'
    NOT AVAILABLE

  atlas_3_10_blas_threads_info:
  Setting PTATLAS=ATLAS
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries tatlas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  atlas_3_10_blas_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries satlas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  atlas_blas_threads_info:
  Setting PTATLAS=ATLAS
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries ptf77blas,ptcblas,atlas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  atlas_blas_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries f77blas,cblas,atlas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  accelerate_info:
    NOT AVAILABLE

  C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\numpy\distutils\system_info.py:690: UserWarning:
      Optimized (vendor) Blas libraries are not found.
      Falls back to netlib Blas library which has worse performance.
      A better performance should be easily gained by switching
      Blas library.
    self.calc_info()
  blas_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries blas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\numpy\distutils\system_info.py:690: UserWarning:
      Blas (http://www.netlib.org/blas/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [blas]) or by setting
      the BLAS environment variable.
    self.calc_info()
  blas_src_info:
    NOT AVAILABLE

  C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\numpy\distutils\system_info.py:690: UserWarning:
      Blas (http://www.netlib.org/blas/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [blas_src]) or by setting
      the BLAS_SRC environment variable.
    self.calc_info()
    NOT AVAILABLE

  'svnversion' is not recognized as an internal or external command,
  operable program or batch file.
  non-existing path in 'numpy\\distutils': 'site.cfg'
  lapack_opt_info:
  lapack_mkl_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries mkl_rt not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  openblas_lapack_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries openblas not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  openblas_clapack_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries openblas,lapack not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  flame_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries flame not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program 

Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs']
NOT AVAILABLE

  atlas_3_10_threads_info:
  Setting PTATLAS=ATLAS
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries tatlas,tatlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries tatlas,tatlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries tatlas,tatlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
    NOT AVAILABLE

  atlas_3_10_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries satlas,satlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries satlas,satlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries satlas,satlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  <class 'numpy.distutils.system_info.atlas_3_10_info'>
    NOT AVAILABLE

  atlas_threads_info:
  Setting PTATLAS=ATLAS
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries ptf77blas,ptcblas,atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries ptf77blas,ptcblas,atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries ptf77blas,ptcblas,atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  <class 'numpy.distutils.system_info.atlas_threads_info'>
    NOT AVAILABLE

  atlas_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries f77blas,cblas,atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries f77blas,cblas,atlas not found in C:\
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack_atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries f77blas,cblas,atlas not found in C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\libs
  <class 'numpy.distutils.system_info.atlas_info'>
    NOT AVAILABLE

  lapack_info:
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  customize MSVCCompiler
    libraries lapack not found in ['C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\lib', 'C:\\', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\\libs']
    NOT AVAILABLE

  C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\numpy\distutils\system_info.py:1712: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    if getattr(self, '_calc_info_{}'.format(lapack))():
  lapack_src_info:
    NOT AVAILABLE

  C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\numpy\distutils\system_info.py:1712: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    if getattr(self, '_calc_info_{}'.format(lapack))():
    NOT AVAILABLE

  C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
    warnings.warn(msg)
  running install
  running build
  running config_cc
  unifing config_cc, config, build_clib, build_ext, build commands --compiler options
  running config_fc
  unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
  running build_src
  build_src
  building py_modules sources
  creating build
  creating build\src.win-amd64-3.9
  creating build\src.win-amd64-3.9\numpy
  creating build\src.win-amd64-3.9\numpy\distutils
  building library "npymath" sources
  No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
  error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
  ----------------------------------------

ERROR: Command errored out with exit status 1: 'C:\Users\mypc\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u
-c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\setup.py'"'"'; file='"'"'C:\Users\mypc\AppData\Local\Temp\pip-install-h4qfh7xe\numpy_59a884ee915e42e8a5646e10396d1e6c\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\mypc\AppData\Local\Temp\pip-record-z8i0erw7\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay' --compile --install-headers 'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay\Include\numpy' Check the logs for full command output.

WARNING: Discarding https://files.pythonhosted.org/packages/31/29/ede692aa6547dfc1f07a4d69e8411b35225218bcfbe9787e78b67a35d103/pandas-1.0.5.tar.gz#sha256=69c5d920a0b2a9838e677f78f4dde506b95ea8e4d30da25859db6469ded84fa8 (from https://pypi.org/simple/pandas/) (requires-python:>=3.6.1). Command errored out with exit status 1: 'C:\Users\mypc\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' 'C:\Users\mypc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\mypc\AppData\Local\Temp\pip-build-env-ujic4jvw\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.13' 'numpy==1.13.3; python_version=='"'"'3.6'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system!='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.6'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.16.0; python_version=='"'"'3.7'"'"' and platform_system=='"'"'AIX'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"' and platform_system=='"'"'AIX'"'"'' Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pandas==1.0.5 (from python-trading-robot)
ERROR: No matching distribution found for pandas==1.0.5
PS C:\Users\mypc\Desktop\Trading\pyrobot\python-trading-robot>

Place_order issues

It looks like everything is okay except that I get this particular error and I have tried several time to fix it. Could you please me identify and solve this issue?

in execute_orders
order_dict = self.session.place_order(
"C:\site-packages\td\client.py", line 1925, in place_order
return self._make_request(method='post', endpoint=endpoint, mode='json', json=order, order_details=True)
"C:\lib\site-packages\td\client.py", line 617, in _make_request
raise NotNulError(message=response.text)
td.exceptions.NotNulError: {"error" : "A validation error occurred while processing the request."}

Thank you!

Trouble running setup py

Had a few Warning issues when running the setup.py that I need help with. It may be an simple issue but I am a new user to Py and a novice at coding. I could not locate "PATH" or I just dont understand what it is referencing.

Where exactly should I install these files listed in the Warnings. Thanks for all your help!

Harry

Microsoft Windows [Version 10.0.18363.959]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\htrop\OneDrive\Documents\GitHub\python-trading-robot>pip install -e .
Obtaining file:///C:/Users/htrop/OneDrive/Documents/GitHub/python-trading-robot
Collecting td-ameritrade-python-api
Downloading td_ameritrade_python_api-0.2.8-py3-none-any.whl (52 kB)
|████████████████████████████████| 52 kB 204 kB/s
Collecting pandas
Downloading pandas-1.1.0-cp38-cp38-win_amd64.whl (9.6 MB)
|████████████████████████████████| 9.6 MB 1.1 MB/s
Collecting numpy
Downloading numpy-1.19.1-cp38-cp38-win_amd64.whl (13.0 MB)
|████████████████████████████████| 13.0 MB 127 kB/s
Collecting requests-oauthlib
Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting websockets
Downloading websockets-8.1-cp38-cp38-win_amd64.whl (66 kB)
|████████████████████████████████| 66 kB 96 kB/s
Collecting requests
Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 54 kB/s
Collecting pyopenssl
Downloading pyOpenSSL-19.1.0-py2.py3-none-any.whl (53 kB)
|████████████████████████████████| 53 kB 265 kB/s
Collecting flask
Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
|████████████████████████████████| 94 kB 398 kB/s
Collecting python-dateutil>=2.7.3
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
|████████████████████████████████| 227 kB 1.1 MB/s
Collecting pytz>=2017.2
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 595 kB/s
Collecting oauthlib>=3.0.0
Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
|████████████████████████████████| 147 kB 726 kB/s
Collecting chardet<4,>=3.0.2
Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
|████████████████████████████████| 133 kB 1.1 MB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
|████████████████████████████████| 127 kB 656 kB/s
Collecting certifi>=2017.4.17
Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
|████████████████████████████████| 156 kB 652 kB/s
Collecting idna<3,>=2.5
Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
|████████████████████████████████| 58 kB 562 kB/s
Collecting cryptography>=2.8
Downloading cryptography-3.0-cp38-cp38-win_amd64.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 312 kB/s
Collecting six>=1.5.2
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting Werkzeug>=0.15
Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
|████████████████████████████████| 298 kB 504 kB/s
Collecting click>=5.1
Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 144 kB/s
Collecting itsdangerous>=0.24
Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting Jinja2>=2.10.1
Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 726 kB/s
Collecting cffi!=1.11.3,>=1.8
Downloading cffi-1.14.1-cp38-cp38-win_amd64.whl (178 kB)
|████████████████████████████████| 178 kB 595 kB/s
Collecting MarkupSafe>=0.23
Downloading MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl (16 kB)
Collecting pycparser
Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
|████████████████████████████████| 112 kB 726 kB/s
Installing collected packages: oauthlib, chardet, urllib3, certifi, idna, requests, requests-oauthlib, websockets, pycparser, cffi, six, cryptography, pyopenssl, Werkze
ug, click, itsdangerous, MarkupSafe, Jinja2, flask, td-ameritrade-python-api, python-dateutil, pytz, numpy, pandas, pyrobot
WARNING: The script chardetect.exe is installed in 'C:\Users\htrop\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages
Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script flask.exe is installed in 'C:\Users\htrop\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Pytho
n38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script f2py.exe is installed in 'C:\Users\htrop\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python
38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Running setup.py develop for pyrobot
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 certifi-2020.6.20 cffi-1.14.1 chardet-3.0.4 click-7.1.2 cryptography-3.0 flask-1.1.2 idna-2.10 itsd
angerous-1.1.0 numpy-1.19.1 oauthlib-3.1.0 pandas-1.1.0 pycparser-2.20 pyopenssl-19.1.0 pyrobot python-dateutil-2.8.1 pytz-2020.1 requests-2.24.0 requests-oauthlib-1.

Issue with pulling new Candlesticks

This seems to be a great resource but I can't get over a hurdle I'm encountering.

I'm getting data using TDA's REST API through trading_robot.grab_historical_prices()

This pulls out the latest candle and adds it into the trading loop. Then it runs the indicators on the new data and processes the buy and sell signals. You show this pretty well in your Youtube tutorials.

Unfortunately TDA is pushing out INCOMPLETE candles. So if you do a request on for 15 minute candles at 9:01. The final candle, which we're basing our indicators and triggers on, is only 1 minute of data. This can bee seen in your video: https://www.youtube.com/watch?v=xF5h41CZlls @ 12:18.

Please let me know if you need anymore clarification info.

EDIT:

I think I may have fixed this by taking the following steps.

  1. In the PyRobot.grab_historical_prices() function, I've added the line:
    new_prices = new_prices[:-1]
    this strips the final (incomplete) candle from the initial function to grab the historical candles.

  2. in the Pyrobot.get_latest_bars() function, under the "#parse the candles" section, I've edited the initial for-loop from
    for candle in historical_prices_response['candles'][-1:]:
    To this:
    for candle in historical_prices_response['candles'][-2:-1]:
    The goal here is to ignore the latest incomplete candle. so the 'get_latest_bars' function will never pull an incomplete candle.

Unfortunately this breaks the PyRobot.wait_till_next_bar() function. This can be fixed in two additional steps.

  1. pass 'bar_size' as an argument into the function. The amount of seconds to wait must be dependent on size of the aggregates of the bars.
    def wait_till_next_bar(self, last_bar_timestamp: pd.DatetimeIndex, bar_size) -> None:

  2. We'll use the bar_size argument in assigning the next_bar_time variable:
    next_bar_time = last_bar_time + timedelta(seconds=60*bar_size*2)
    60*bar_size represents the time until the next complete candle. ex, for 1 minute candles, wait 60 seconds (60x1) for 15 minute candles wait 60x15 seconds. we multiply this by two because of how TDA API delivers their candlesticks:
    for 15 minute candles, the 9:30-9:45 candle is called 9:30, we want to receive this candle at 9:45 when it is complete. We want to receive the 9:45 candle at 10:00. That's a 30 minute difference (or 60x15x2 seconds). This calculation remains as a function of the bar_size so that it works with any candle length.

I hope this make sense.

I will test it when the market opens tomorrow.

EDIT2:
This works alright. It breaks down on market open when extended hours data isn't turned on, as expected. I will work on a work-around soon.

response.status_code 400: Validation error

I can't seem to post a trade to my real account. Most of the code below is from the trading_robot.py sample. Is this not the way to execute an order? I get NotNulError: A validation error occurred while processing the request. (this is under the _make_request function) in client.py.
`

Import libraries

from configparser import ConfigParser
from datetime import datetime
from pyrobot.robot import PyRobot

Grab configuration values.

config = ConfigParser()
config_fpath = r'C:\Users\timcr\Desktop\Documents\stocks\td_ameritrade_api\configs\config.ini'
config.read(config_fpath)
CLIENT_ID = config.get('main', 'CLIENT_ID')
REDIRECT_URI = config.get('main', 'REDIRECT_URI')
CREDENTIALS_PATH = config.get('main', 'JSON_PATH')
ACCOUNT_NUMBER = config.get('main', 'ACCOUNT_NUMBER')

Initalize the robot.

trading_robot = PyRobot(
client_id=CLIENT_ID,
redirect_uri=REDIRECT_URI,
credentials_path=CREDENTIALS_PATH,
trading_account=ACCOUNT_NUMBER,
paper_trading=False
)

Create a new Trade Object.

new_trade = trading_robot.create_trade(
trade_id='long_msft',
enter_or_exit='enter',
long_or_short='short',
order_type='lmt',
price=150.00
)

Make it Good Till Cancel.

new_trade.good_till_cancel(cancel_time=datetime.now())

Change the session

new_trade.modify_session(session='am')

Add an Order Leg.

new_trade.instrument(
symbol='MSFT',
quantity=2,
asset_type='EQUITY'
)

Add a Stop Loss Order with the Main Order.

new_trade.add_stop_loss(
stop_size=.10,
percentage=False
)

Execute order

trading_robot.execute_orders(new_trade)`

new

My name is Luis, I'm a big-data machine-learning developer, I'm a fan of your work, and I usually check your updates.

I was afraid that my savings would be eaten by inflation. I have created a powerful tool that based on past technical patterns (volatility, moving averages, statistics, trends, candlesticks, support and resistance, stock index indicators).
All the ones you know (RSI, MACD, STOCH, Bolinger Bands, SMA, DEMARK, Japanese candlesticks, ichimoku, fibonacci, williansR, balance of power, murrey math, etc) and more than 200 others.

The tool creates prediction models of correct trading points (buy signal and sell signal, every stock is good traded in time and direction).
For this I have used big data tools like pandas python, stock market libraries like: tablib, TAcharts ,pandas_ta... For data collection and calculation.
And powerful machine-learning libraries such as: Sklearn.RandomForest , Sklearn.GradientBoosting, XGBoost, Google TensorFlow and Google TensorFlow LSTM.

With the models trained with the selection of the best technical indicators, the tool is able to predict trading points (where to buy, where to sell) and send real-time alerts to Telegram or Mail. The points are calculated based on the learning of the correct trading points of the last 2 years (including the change to bear market after the rate hike).

I think it could be useful to you, to improve, I would like to share it with you, and if you are interested in improving and collaborating I am also willing, and if not file it in the box.

If tou want, Please read the readme , and in case of any problem you can contact me ,
If you are convinced try to install it with the documentation.
https://github.com/Leci37/stocks-Machine-learning-RealTime-telegram/tree/develop I appreciate the feedback

`grab_historical_prices` method a little misleading in description

bar_type {str} -- Defines the bar type, can be one of the following:

        bar_type {str} -- Defines the bar type, can be one of the following:
            `['minute', 'week', 'month', 'year']` (default: {'minute'})

This is a little misleading, if I follow through to your TDClient code all the way to the TD Ameritrade documentation, there are two discrepencies:

  1. aside from "minute" the rest should be in the form of "weekly" "monthly" and "yearly"

  2. "daily" is also a valid option for bar width

This method is mostly utilized in your examples for streaming data by the minute so not a huge deal for that use, but I've repurposed some of this for myself for plotting candles out into the months and years hence taking a closer look into this

Data delayed by 15 minutes even after authenticating

Alex, thank you so much for an awesome repo. I have been following along and getting everything to work just fine until now. However, on video 14, I used the trading_robot.wait_till_next_bar(last_bar_timestamp=last_bar_timestamp) line, and when I print out print("Time to wait {time_to_wait}".format(time_to_wait=time_to_wait_now)) before resetting it to 0 if negative, I get a value between -960 and -900. This indicates to me that the data is 15 minutes delayed, even though I've freshly authenticated. Also note that the time to sleep is set to 0, so it refreshes every second.

What can I do to fix this?

Python 3.7.7 support?

is the minimum requirement truly 3.8? I switched it to 3.7.7 and it seems to function.

Using MT4 instead of TD

For some reason I thought this was a program designed for the platform MetaTrader4. (I specifically looked up, "MT4 python trading bot." and this video popped up.) Now as I am reviewing it, I realize its not for MT4 its for TD ameritrade. Is there any way we can switch the platform?

key error

Traceback (most recent call last):
File "e:\python-trading-robot\samples\trading_robot.py", line 222, in
trading_robot.execute_signals(
File "e:\python-trading-robot\pyrobot\robot.py", line 721, in execute_signals
trade_obj: Trade = trades_to_execute[symbol]['buy']['trade_func']
KeyError: 'buy'

get_positions returns same equity for each

Bot connected etc first print gives me specified account information. Second print gives me 20 entries for the same equity instead of the 20 different equity positions in the account.

Code:

trading_robot_accounts = trading_robot.get_accounts(account_number=ACCOUNT)

pprint.pprint(trading_robot_accounts)

trading_robot_positions = trading_robot.get_positions(account_number=ACCOUNT)

pprint.pprint(trading_robot_positions)

OUTPUT:
[{'account_number': '123',
'account_type': 'MARGIN',
'available_funds': 11.31,
'buying_power': 122.62,
'cash_available_for_trading': 0.0,
'cash_available_for_withdrawl': 0.0,
'cash_balance': 0.0,
'day_trading_buying_power': 0.0,
'long_market_value': 113.05,
'maintenance_call': 0.0,
'maintenance_requirement': 365.92,
'short_balance': 0.0,
'short_margin_value': 0.0,
'short_market_value': 0.0}]
[{'account_number': '123',
'asset_type': 'EQUITY',
'average_price': 125.51974,
'current_day_profit_loss': 54.723030000001,
'current_day_profit_loss_percentage': 0.57,
'cusip': '123',
'description': '',
'long_quantity': 43.089,
'market_value': 91.16,
'settled_long_quantity': 43.089,
'settled_short_quantity': 0.0,
'short_quantity': 0.0,
'sub_asset_type': '',
'symbol': 'VUG',
'type': ''},
{'account_number': '123',

It continues but I cut it there.

post_market_open - adjustment to post_market_end_time

First off - this work is a HUGE help!!! I have been learning out to trade and code at the same time. Your work and videos are very helpful.

This should be a simple one...

I noticed that the post_market_open was acting strange. Upon investigation I realized that the post_market_end_time was set to "hour = 00". That would adjust now() to today at 00:00:00. By shifting the post_market_end_time to "hour=23, minute=59, second=59", the post_market_open works as intended. I would suspect that most people would accept the 1 second error at the very end of the session.

Not installing dependencies using "pip install -e."

I cloned the python trading robot from areed1192 github page last month and tried to install using pip install -e. Snap shot of the error message below. Please advise how I can resolve it. thanks in advance.

image

Problem with single quotes in order dictionary.

It appears through testing that there is some sort of problem when submitting the orders created with the create trade module that have single quotes (') in the dictionary. I kept having a problem getting the orders to submit to my production TD account. Then when I changed the single quotes(') to double quotes(") (as is depicted in the example they provide in the API guide) the order went through just fine. Are you aware of this?

Seems somewhat peculiar that the API would be written this way, but that is what my testing has borne out. Would appreciate any comments from anyone else who is using this to chime in.

If I am correct, it would be worthy of making the changes in the trades Class to remedy this. Please advise.

Not generating credentials file

I cloned the repository and created my own config file to use when initializing the bot, but I get the following error.
image

It looks like the json file isn't being created, would appreciate some help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.