You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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)`
The text was updated successfully, but these errors were encountered: