Building a Trading Robot in Python | Pt. 1
Summary
TLDRIn this video, the creator introduces a series on building a trading robot using Python, specifically with the TD Ameritrade API. Aimed at viewers with a TD Ameritrade account and a solid understanding of Python, the series will guide through the process from start to finish. The script emphasizes the importance of understanding the underlying mechanics of the robot, including handling price data, managing account activity, and calculating technical indicators. The presenter outlines the need for objects like the robot, stock frame, portfolio, trade, and indicator objects, and mentions that the library is available on GitHub for cloning, with future episodes promising a detailed, hands-on coding approach.
Takeaways
- 😀 The video introduces a series on building a trading robot using Python, specifically with the TD Ameritrade API.
- 🔑 It's assumed that viewers have a TD Ameritrade account, but the presenter may cover other APIs in the future.
- 🛠️ The tutorial is aimed at individuals with a solid understanding of Python and familiarity with libraries like pandas and numpy.
- 🚫 The presenter advises beginners or those not comfortable with programming to hold off on this series due to the complexity.
- 💡 The series emphasizes the importance of understanding the underlying mechanisms of the trading robot for effective use.
- 📈 The robot will need to fetch price quotes, manage account data, enter and exit positions, and calculate technical indicators.
- 🧩 The script outlines the creation of several objects: Robot, StockFrame, Portfolio, Trade, and Indicators, each with specific roles in the trading process.
- 💼 The 'Robot' object acts as the primary interface with the TD Ameritrade API, handling tasks like getting quotes and placing orders.
- 📊 The 'StockFrame' object is designed to organize and manipulate price data, making it easier to work with financial data in pandas.
- 💰 The 'Portfolio' object mimics account activity to aid in decision-making, such as avoiding duplicate positions.
- 📉 The 'Indicators' object is intended to simplify the calculation of technical indicators, ensuring consistency and flexibility.
Q & A
What is the main focus of the video series being introduced?
-The main focus of the video series is to guide viewers through the process of building a trading robot from start to finish using Python, specifically with the TD Ameritrade API.
What is a prerequisite for viewers before starting the series?
-Viewers should have a TD Ameritrade account, and it is assumed that they have a relatively decent understanding of Python and familiarity with libraries like pandas or numpy.
Why is it important for viewers to understand what's happening behind the scenes when building a trading robot?
-Understanding what's happening behind the scenes helps viewers grasp how the robot is structured, how different objects interact, and why it was built in a certain way, which is crucial for effectively using and potentially modifying the robot.
What are some of the complexities involved in trading that the video series aims to address?
-The series addresses complexities such as understanding order types, technical indicators, and account activity, all of which are essential for effective trading and are incorporated into the programming of the trading robot.
How does the presenter plan to make the process of building a trading robot more approachable?
-The presenter plans to make the process more approachable by starting at a high level, defining objectives, and then gradually diving into the programming aspects, ensuring that viewers understand the purpose and functionality of each component.
What is the significance of the 'robot' object in the context of the trading robot being built?
-The 'robot' object is significant as it mimics the user's interaction with the TD Ameritrade account, handling all communications with the TD Ameritrade API, including getting quotes, placing orders, and retrieving account activity.
Why is the 'stock frame' object necessary in the trading robot?
-The 'stock frame' object is necessary for organizing price data in a consistent and finance-oriented manner, making it easier to add, delete, select, and manipulate data for trading decisions.
What role does the 'portfolio' object play in the trading robot?
-The 'portfolio' object mimics the user's account activity, helping to manage and organize information about current positions and active orders, which is crucial for making informed trading decisions.
How does the 'trade' object simplify the process of managing orders in the trading robot?
-The 'trade' object simplifies order management by providing methods to easily modify orders, add components like stop losses, and check the status of orders, making the process less complex and more streamlined.
What is the purpose of the 'indicator' object in the trading robot?
-The 'indicator' object is designed to calculate and define technical indicators in a consistent and easy-to-use manner, ensuring that the robot can use these indicators effectively for trading decisions.
Where can viewers find the current state of the trading robot library discussed in the video?
-Viewers can find the trading robot library on the presenter's GitHub account under the repository named 'Python trading robot', where they can clone the repository and explore the code.
Outlines
🤖 Introduction to Building a Trading Robot with Python
The speaker introduces a new series focused on building a trading robot using Python, specifically with the TD Ameritrade API. It's mentioned that the series has been highly requested and will be structured to go from start to finish in creating the robot. The speaker emphasizes the importance of understanding the underlying processes of the robot, not just using the library. It's assumed that the viewer has a TD Ameritrade account and a decent understanding of Python and libraries like pandas or numpy. The speaker also advises those new to programming to familiarize themselves with basic programming concepts before proceeding with the series.
📈 The Importance of Defining Trading Objectives and Details
The speaker discusses the importance of being explicit about trading objectives and the details of trading strategies when building a trading robot. It's highlighted that many people struggle with defining their trading methods precisely, which becomes necessary when programming a robot. The speaker suggests that traders should write out their trading strategies to understand the finer details, such as order types and quantities. The paragraph also touches on the need to understand the big questions and objectives of the trading robot, such as obtaining price information, entering and exiting positions, and managing account data.
💼 Necessity of Account Activity and Technical Indicators in Trading
The speaker continues by emphasizing the need for a mechanism to obtain account activity and the importance of calculating technical indicators for trading decisions. It's explained that account activity can influence trading logic, such as not entering a new position if one already exists for the same ticker symbol. The speaker also discusses the challenges of calculating technical indicators and the intention to create a consistent and flexible way to calculate them through the use of an indicator object. The paragraph outlines the high-level objectives for the trading robot, focusing on the need for price information, position management, account data handling, and indicator calculations.
🛠️ Designing the Robot's Objects for Effective Trading
The speaker delves into the object-oriented programming approach for the trading robot, starting with the robot object that mimics the user's interaction with the TD Ameritrade API. The robot object is essential as it handles all interactions with the API, including getting quotes, placing orders, and retrieving account activity. The paragraph also introduces the concept of a stock frame object to organize price data and a portfolio object to mimic account activity. The speaker discusses the benefits of having these objects, such as ease of data manipulation and decision-making based on account data.
📊 Streamlining the Trading Process with Trade and Indicator Objects
The speaker further elaborates on the design of the trading robot by introducing the trade object, which encapsulates the complexity of orders, and the indicator object, which simplifies the calculation of technical indicators. The trade object is designed to handle modifications and additions to orders easily, while the indicator object ensures consistent and flexible calculation of indicators. The speaker also discusses the importance of having the stock frame and indicator objects communicate effectively, with the indicators recalculating as new data is added to the stock frame.
🔗 Accessing the Trading Robot Library and Preparing for the Next Steps
The speaker wraps up the presentation by directing viewers to the GitHub repository where the trading robot library is available for cloning. It's mentioned that the library is a work in progress and will undergo significant changes. The speaker provides instructions on how to clone the repository and gives a brief overview of its contents, including the main robot file, configuration requirements, and examples of how to use the library. The speaker encourages viewers to contribute to the project and hints at the next video, where the creation of the robot will begin from scratch.
Mindmap
Keywords
💡Trading Robot
💡Python
💡TD Ameritrade API
💡Pandas
💡Technical Indicators
💡Object-Oriented Programming (OOP)
💡Order Types
💡Account Activity
💡GitHub
💡Unit Testing
Highlights
Introduction to a series on building a trading robot using Python and the TD Ameritrade API.
Assumption that viewers have a TD Ameritrade account and a basic understanding of Python and libraries like pandas or numpy.
Emphasis on the importance of understanding the underlying processes of the trading robot for effective usage.
Advice for beginners to gain more programming knowledge before engaging with the series.
Explanation of the complexity involved in trading and the additional layer of complexity introduced by programming.
The necessity to define clear objectives for the trading robot at a high level.
The importance of being explicit about trading strategies and order types when programming a trading robot.
The need for a mechanism within the robot to obtain price information from the market.
Discussion on the functionality required for the robot to enter and exit trading positions based on signals.
The role of the robot in managing account data and its influence on trading decisions.
The significance of calculating technical indicators and their impact on trading decisions.
Introduction to the 'robot' object, which mimics user interaction with the TD Ameritrade account.
Explanation of the 'stock frame' object for organizing and managing price data.
Description of the 'portfolio' object that reflects account activity and assists in decision-making.
The 'trade' object facilitates complex order management and real-time trading activities.
The 'indicator' object standardizes the calculation of technical indicators for consistency.
Availability of the library on GitHub for cloning and potential contributions.
Instructions on how to clone the repository and the current state of the library with its dependencies.
Overview of the main robot file, configuration requirements, and examples of how to use the library.
The intention to rewrite the library from scratch in the next video, showcasing the setup and core functionalities.
Transcripts
well welcome back so I know a lot of
people will be excited about this series
we are kicking it off yes we are gonna
cover a series that has been highly
requested by so many people we are gonna
be showing you how to from start to
finish
build a trading robot using Python and
more specifically we're gonna be showing
it using the TD Ameritrade API so yes
this again just putting that out there
right now this will be assuming that you
have a TD Ameritrade account that is not
to say down the road I will not do
Interactive Brokers or the other ones
but right now this one week covering
purely TD Ameritrade so this wonderful
series it's been a few months in the
making so there's a lot of stuff that
kind of comes along but this I will say
that additionally I do want to spend a
few minutes just going over it right so
I don't want to jump right into the
coding I really want to take some time
let's talk about what are we trying to
do and how are we trying to do it for
those of you who I know there's a lot of
people out there they kind of just want
to use the library they don't want to
necessarily kind of care about what's
going on behind the scenes that is okay
to a certain extent but I will say this
you really should know kind of what's
going on behind the scenes the only
reason I say that is you know there's a
lot of things that are being calculated
and it's a little bit easier to
understand how to use it if you kind of
understand how it was built so even
though things will probably change a
little bit from what you're gonna be
seeing now it's gonna change a lot but I
think having that idea of like hey how
did we structure the code how do we
think about the different objects and
how do they kind of all interact
together yeah you might not necessarily
go out there and rewrite the library but
it's a good idea to kind of just
understand why was it built this way and
kind of how's everything talking to each
other additionally I will say this is
well it is assumed that if you're
watching this series
that you're coming in with you know a
relatively decent understanding of
Python and some level of familiarity
with certain popular libraries like
pandas or numpy you know something like
that if you're very new to programming
I'm actually gonna say hold off on this
series for a little bit you know you
might want to go get familiar with
certain concepts like you should be
comfortable with you know class objects
you should be very comfortable with if
statements for loops anything like that
I know sometimes we kind of just want to
jump into it but the thing is this can
actually make real trades for you and if
you don't understand how it's working
and if you don't know how to structure
the code you're gonna be making real
trades with real money so with that
being said you know I am saying if
you're not comfortable with programming
in that regard you need to get familiar
with it and then kind of come back to
this series I do have some videos that
cover different topics but there are
also plenty of other channels out there
who have a ton of content that will more
than likely get you right up to speed so
with that being said let's get started
all right first things first this is
actually a really complex topic trading
is already hard enough right like a lot
of people who day trade who just even
you don't even really day trade I mean
just trade in general you know you learn
right away that it's not easy right I
mean there's a lot of things you have to
understand there's all these fancy terms
there's all these technical indicators
out there and there's all this kind of
background knowledge that you have to
understand in order to trade effectively
so you've got to understand order types
you've got to understand indicators if
we got to understand you know different
things related to account activity so
we've already taken a pretty complex
topic and now we've made it even more
complex by adding this whole wonderful
world of programming into it so that
just makes a little bit more challenging
doesn't make an impossible and doesn't
even make it where it can't be done it
just means we need to be very focused
let me go about this whole process and
part of being focused means we really
need to start at a high level by
defining our objectives
what I have found is what I found is a
lot of times people will reach out and
say hey I'm trying to build a training
robot and I've kind of picked their
brain a little bit and I say okay well
what are you trying to do like how are
you trying to do it and something that
kind of became very apparent to me
relatively quickly was people were
trading but they also weren't
understanding how they were trading in
very explicit terms because behind the
scenes they were making all these
assumptions right and certain things
like you know when they would make an
order you know for a lot of people maybe
for example a big assumption was it's
just a market order well now all this
sudden I'm gonna have to you're gonna
have to ask I'm gonna have to ask you
that right I'm gonna have to you're
gonna have to tell me what type of order
you want to place so all the sudden I'm
gonna start requiring to be very
explicit with how you trade because you
don't get that luxury anymore
you have to be able to tell that robot
hey you need to trade like this and if
you want it to truly mimic your trading
you have to give it all that information
and you have to tell it upfront so hey
you know it got to be this order you've
got to be using this price you've got to
be you know buying this amount of
quantity so all of the sudden this is
where people tend to struggle a little
bit because now I'm forcing them to
really be extremely explicit about how
they're trading so a lot of times what I
have found is having people take a step
back and really sit down right I mean
write it out I mean there's nothing
wrong with writing out but write out how
do you trade you know it's not just
sitting there well I just placed an
order it's more than that and you know
that it's you know there's a type of
order there's a quantity you know there
there's all these little finer details
that are going into it and you now need
to start identifying those finer details
so that's usually where again for at
least from my experience this is where
people kind of struggle a little bit
because hey I'm forcing them be very
explicit and it's very easy to get
overwhelmed so naturally what I do is I
kind of take a step back and say okay
well you don't have to answer every
question but ideally you want to have a
general idea about kind of the kind of
the big the big questions right
the same kind of relates here when we're
talking about the objective right we're
not gonna have to necessarily define
every little fine detail yet but we
should generally have a decent
understanding about what are the big
things that this trading robot needs to
do now this is not an exhaustive list
this doesn't contain every possible
thing it needs to do but when I was kind
of approaching this I kind of asked
myself what is really the things that
this thing needs to do right so what are
the objectives of this training robot
and what does it have to do in order to
function the way I think it should
function well the probably the biggest
thing is it needs to string quotes right
so it needs to be able to get price
information from somewhere because that
price information is used in so many
different parts it's used when we're
calculating indicators it's used when
replacing orders it's used when we're
trying to organize our data so one of
the first things we have to have built
into this is we've got to have some type
of mechanism for getting price
information once we have that price
information we can manipulate it and do
whatever we want with it but we have to
have some type of mechanism for getting
that information now right now the way
I've built the library is I am using not
this TD streaming API I'm using the TD
standard API so it's not to say the
streaming API won't come in at some
point but right now just to kind of keep
things a little bit more simple I'm
relying purely on the standard API and I
will show you there's ways we can kind
of mimic that's a loose word but we'll
stick with it mimic the streaming API in
certain regards so the big first thing
we need to have is price information so
we're gonna have to basically have a
robot somehow get price additionally we
need some type of functionality where we
can enter and exit positions right
that's trading you're gonna enter a
position because you got a buy signal
maybe and then maybe you're gonna have
to exit a position because you got a
sell you know a sell signal right so we
have to have some type of functionality
those robots got to be able to hey take
a signal and then you know act on that
signal and the way it acts is it
determines well maybe I need to create a
new
order that will then reverse the
position I just created right so we have
to have some type of functionality like
that additionally we need to have some
type of functionality where it goes in
it can help us manage our account data
right and so we have a lot of account
data out there and very often we will
find that that account data is critical
when it comes to making trades for
example I have some individuals who will
say once I own a position I do not want
to enter another position for that same
ticker symbol so we now have to build in
some logic that says hey the minute that
person enters a position even if I get a
buy signal do not enter a new position
so this is all of the sudden we're being
explicit is very important because
sometimes people don't realize that I
some people won't trade like that and
some people say I don't care if there's
another bias appeal maybe we just add to
the position not saying it's right or
wrong but I'm saying as you have to
define that role beforehand so because
of that and because sometimes the logic
that we build depends on what we already
have in our account activity we need to
have some type of mechanism for getting
that account activity and organizing it
in a fashion where we can then use it in
other decision-making processes of our
robot and probably the big one is we
need to have a mechanism for calculating
technical indicators a lot of
individuals use technical indicators in
order to trade they use it to determine
when to enter or exit a position they
use it to determine when the market is
behaving more in a more active manner
compared to a more you know I don't want
to say it's a sedative is that what a
sedative mean I don't know regardless
they use it in order to make decisions
sometimes it's determined when to start
looking for signals other times it's use
to determine when to enter or exit a
position so we have to have some type of
mechanism for helping us calculate those
indicators so with that we have an
objective
this is ideally at a very high level
this is what we want our robot to do
when we think about our solution we now
have to kind of start going into our
programming world right well a lot of
times we're thinking a very
object-oriented programming so with that
being said we need to start thinking
about our objects what are the objects
that we're gonna be creating and what
are they gonna be doing for us like how
does it fit into the bigger picture of
our robot well the first thing that
we're gonna have to do is we're gonna
have to mimic guess what you write so we
have to mimic you as an individual the
way we mimic you is we define our robot
object our robot object is mimicking how
you interact with your TD Ameritrade
account but what this robots gonna do is
it's gonna interact with the TD
Ameritrade API so the robot is really
designed to mimic you and the way it's
gonna be mimicking you is it's gonna be
making requests to the TD Ameritrade API
right so it's gonna be getting quotes
it's gonna be placing orders it's gonna
be getting account activity so this
robot is gonna be handling all the
talking to the TD Ameritrade API and so
the way I also like to think about this
is this is the highest level of our kind
of hierarchy if we think about our
objects as a hierarchy we can't do
anything unless we have a robot so we
can't do any trading unless we have you
in the picture so even though you're not
necessarily there physically
manipulating the robot the robot is
designed to mimic you so it's like we're
copying you or putting you into a
program and we're saying hey this robot
has to be the main point of entry if I
don't have a robot I can't do anything
else so that's our first object our
second object we're gonna be working
with a ton of price data and we are
going to need to organize that price
data in a very consistent manner and
we're going to have to have easi
mechanisms for adding data appending
data well I guess
adding an appending are the same thing
maybe in some cases deleting data
selecting data and just keeping all of
our information organized in a very easy
fashion so we're gonna create a object
but we're gonna call a stock frame now
maybe a stock frame isn't the best name
and I've actually debated if that's even
remotely correct but for right now we're
gonna keep it like that the stock frame
at the end of the day is gonna be just a
panda's data frame but I don't want to
make it too general right I don't want
to necessarily say oh yeah it's a
panda's data frame so why are you doing
all this extra fluff and I debated about
that I mean initially I said you know as
am I just doing overkill right now like
is it really necessary to just define a
new object that really is just a panda's
data frame and I found it kind of is
sometimes in the only reason why it is
our data is going to be very finance
oriented right and there's a lot of
finance operations that you can do in
pandas that would just be nice or a
little bit easier to do if it was set up
correctly right so things like you know
maybe it makes sense to have a multi
index data frame instead of just a
normal data frame where you know the
index is all right there so that might
necessarily be beneficial
additionally there are some mechanisms
where adding data to a data frame could
be a little bit challenging sometimes
depending on you know how its organized
and so I wanted to kind of take away the
hassle of managing that and just say you
know what as long as we're interacting
with the API consistently all I really
care about is doing common operations so
maybe that's adding new rows right and
then once I've added new rows there
might be certain other things I might
want to do right so for example if I
have indicators in my stock data frame I
might want to refresh those indicators
or in other words recalculate them with
the new data in mind and so what we'll
find is that stock frame is going to
make that process very easy for us very
very easy for us so you don't have to
worry about that now you're just gonna
call a method and guess what it's gonna
do a lot of magic behind the scenes but
that's what it
to do it's supposed to make it easier to
work with so the stock frame is gonna
really be helping us to organize our
data additionally we're gonna have our
next object which is a portfolio our
portfolio is designed to kind of mimic
our account activity
maybe that's the orders that we already
have active right or maybe that's the
positions that we have currently in our
account that are have been filled right
so the portfolio is really designed to
mimic our account activity because a lot
of times we'll be making decisions based
on data that comes from our account
right so say for example I don't want to
enter a position if I already have that
stock already in my portfolio well this
way by having a portfolio object we can
easily ask those questions and then
transfer that information to our
decision making process so with our
portfolio object it will be very useful
when it comes to organizing that
information and asking questions as
we're trading that's really how I think
about is that asking questions component
do I have that stock well let me just go
check my portfolio and then if I do oh
great I'll just go trade I don't okay
well no I won't trade so that's really
important additionally there's some
times where our trading can really
depend on certain metrics about report
folio right so for example maybe I don't
want more than 60% of my portfolio in
equity right so it would be nice if we
had some type of free built
functionality where we could easily
calculate those metrics on the fly and
so ideally with this portfolio object we
would be able to answer those questions
and then calculate those metrics as we
need and then additionally as we may
might need to do more advanced
operations we can now easily add that
functionality but keep it contained to
where it belongs and that really is that
portfolio aspect so that's the portfolio
object next object trading right so
we're gonna be doing a lot of training
so we need to define a trade object
right so our trade is really our order
but we also understand that an order can
be relatively complex depending on how
you're trading it might not just be a
market order it could be a very it could
be no
you order it could be a child order
incorporated into it so all of a sudden
we have to have some type of structure
where we can easily modify our orders or
we can easily add components to it in an
easy fashion and this is normally where
people struggle a lot because
unfortunately the TD Ameritrade API was
really lacking when it came to the
examples of how to place orders and how
to do that and so over the you know many
months of using this API I've kind of
figured out ok well this is how you do
that and I wanted to kind of have that
functionality pre-built for you so that
way if you want to add things like a
stop loss or a stop loss and take profit
just just an order you already placed
well you can just call a method and it
will do all that for you behind the
scenes instead of you having to take
these very nested dictionaries that can
get very messy very quickly and instead
use that trade object to do it and then
additionally what I would like to do is
I'd like to see that trade object help
us answer questions like has it been
filled yet has it was it partially
filled so ideally I'd like this trade
object to help us answer even more
complex questions that might come down
the road that functionality might not be
there right now but I could definitely
envision that object actually containing
it
so that's why I thought it was important
to help encapsulate all that into that
kind of just that single object because
it's very important and it really is
kind of I would say the meat of our kind
of real-time activity we want to be able
to ask those questions on the fly and so
that trade object will help us do that
final object indicators indicators we've
already said this multiple times a lot
of people use technical indicators in
order to make trades now right now we
are purely doing it from a technical
analysis standpoint that is not to say
that down the road we might not include
include a fundamental analysis but right
now it is purely technical analysis and
so this indicator object is going to
help us calculate and define
those indicators for us in an easy
consistent fashion I think the biggest
thing here is the consistent fashion
it's very easy to get overwhelmed when
it comes to calculating indicators and
it's very easy to find yourself in a
position where all the sudden you're
working with this pandas dataframe and
it gets really hard to do it because
what was it grouped was it not grouped
was it organized was it not organized
you know and all of a sudden you will
start pulling your hair out just like I
did because all of the sudden it's not
straight forward and that was like the
thing that drove me crazy so what I
found was let's define an indicator
object where we can easily calculate
those indicators and as long as I know
what you're passing me through hint hint
it's the stock frame but as long as I
know what you're passing through
I can easily calculate all those
indicators for you in fact initially
what I was actually gonna do is I was
gonna use a few libraries to to
calculate those indicators cuz I thought
man this is great it's like that's gonna
be super easy no problem whatsoever and
then what I found out was it was always
assumed that you were giving a very
standard data frame and I said well
that's assuming the columns are named
the same that's assumed that this is
named the same and all this other stuff
and that it's organized and then they're
assuming that when it's going in there
that it's sorted and well I said well
what if it's not sorted are they gonna
sort that for you and so all the sudden
I found man this could actually be a
little bit challenging because I'm gonna
have to do that on my end because I
don't know if they're necessarily doing
that on their end and so it's not to say
maybe down the road I can't integrate
those libraries but right now I had to
actually define some of these indicators
myself because I was finding that I know
they weren't nest they were assuming
certain things when it was being put in
there and so for example that I think
the biggest thing was how do you
calculate it if you have multiple what
is it multiple ticker symbols in the
same data frame a lot of those libraries
can't handle that and so all this I said
man if I pass through groups it's not
going to work I said I'm gonna have to
filter or do XYZ and I said man this
this could get challenging really
and so the indicator client object was
really designed to kind of help make
that interaction consistent but still
give you the flexibility where you can
have all your data in a single data
frame additionally a lot of indicators
can be calculated using different
methodologies I want that flexibility
for the user so I want the user to be
able to say hey I want to calculate the
RSI using this methodology great just
tell me you want to do that and then
once I have that information
I can calculate that for you so that was
really the intent of the indicator
object was make it consistent and make
it ideally easier to calculate those
indicators real time and then probably
the biggest thing was having that stock
frame and those indicator objects talk
to each other so as the stock frame was
adding new data the indicators would
recalculate that is very challenging to
do sometimes in pandas and honestly that
was one of the one things that I think
always surprised me about pandas and
maybe it could just be the fact that I
just maybe I'm seeing the answer right
in front of me and I'm just not seeing
it but something where it's like I'm
just adding rows like how are these
calculated columns not updating and so I
basically created what I'm calling is a
refresh method and basically what I've
done is when you call your indicator
client I've saved all the arguments
you've passed through so things like the
period that you use the methodology that
you specified and I save that in the
indicator client itself and so what
you'll find is when I call the refresh
method I'm literally calculating those
indicators again but I'm using the saved
information you sent me when you
initially initialized those indicators
so it's pretty neat honestly I out I
thought that was kind of you know that's
this is maybe where Python really shines
a little bit but I thought that was kind
of cool so at a high level this is how
we're gonna start thinking about
building our solution so with that being
said though that actually finishes our
presentation only three slides but of
course I was rambling no there's that
too
so for those of you who are interested
in it on the library is currently posted
on github
so you are more than welcome to clone it
and is not on pi PI so you cannot
install it at least not yet it does have
a few dependencies so pandas numpy and
TD Ameritrade big one is pandas I'm
pretty sure once you install pandas you
don't technically need this but I'm just
thinking out there just to be safe but
really if you want to kind of just
high-level like what does it look like
well first thing is you want to go to my
github account so a breed 1 1 9 2 then
you can see this wonderful photo which
is horrible and then you will see some
repos that I currently have available
and one of them is called the Python
trading robot and so this is the one
that I will be recreating in a series
again just to be very front lots of
changes coming so this will change a lot
so don't be surprised if you go in here
ever you're so off you're like wait he
changed it again oh yeah lots coming and
then from here if you want you can
always clone it so if you just go over
here to the green little button clone or
download and then if you copy it you can
just do it's like so I've covered that
in other videos so I will put a link to
one where I've showed how to clone a
repo but again hopefully pretty
straightforward there's some unit
testing kind of built in I'm adding to
it but right now there's some stuff in
there most of it is for the main robot
itself so just you know again asking
some general questions and then there's
some indicators portfolios and you know
stuff like that and then documents well
unfortunately nothing right now but at
least a template and then you can
actually see the main robot file so if
you were running it this stuff again I
do have a config file I get this asked a
lot a lot a lot a lot you need you don't
have to do this part you don't have to
but you need to have your client ID and
you need to have your redirect URI and
you need to have your credentials path I
am NOT you have to provide that
information for you how you choose to
provide it is totally up to you you can
hard-coded in your script I don't
recommend that if you're sharing it with
other people um you really should keep
it secure
but you can't so I have a config file so
I write it every time I create a new
library and then I just import it as I
need it and then you'll see here I
create a robot and then I do things like
add positions just ask certain questions
and stuff like that so ideally this
should be a little bit easy to hopefully
follow I would hope but sometimes not
and then um again you can go through
here I've been trying to document
everything so I've been trying to add
doc strings and then I'm gonna try to
use like usage cases as well so I'm
trying to make sure that's all organized
if I've missed one you're more than
welcome if you want to either bring it
up or just do a pull request and then
just add it for me but yeah so I mean
there's lots of good stuff here
hopefully again I'm trying to be as
clear as possible about how to use it
so hopefully it's it's hopefully
straightforward that's that's the goal
at least but I'll be probably again just
making lots of changes so again please
don't be surprised if you come here when
you're like geez he just changed like
five files but yeah so I mean you can
obviously clone it by all means if you
have suggestions very open to it people
have been contributing to the
Interactive Brokers one the TD
Ameritrade one so again people have been
great with that and so I'm always open
to hearing that might not get back right
away but always hoping to hearing some
suggestions other than that I will say
I'm gonna think that's gonna be it for
this particular video next video I will
be writing everything from scratch so I
will not be cloning it we will just be
basically recreating what we're seeing
here - the setup and a lot of this other
fancy stuff but for the most part we
will be creating everything that we're
kind of seeing right here so that's
what's gonna be coming up in the next
video you got any questions at this
point by all means ask away hopefully I
have an answer if I don't I'm sorry but
yeah that's pretty much it so hopefully
everyone's happy now we're doing a
trading robot
that's the exciting part right and then
hopefully hopefully it's profitable
right
we'll see but yeah all right we'll see
you in the next video
Browse More Related Video
Aula 25 - Introdução à Cadeia de Markov - Python para Finanças Quantitativas
Blanka aktier - Vad innebär det? | Nordnet Academy
OTE Primer - Intro To ICT Optimal Trade Entry
Stock Trading App Tutorial [Part 00] - App Overview
Stock Chart Analysis with GPT4o Omni (Python Tutorial)
Behind the scene of loops in python
5.0 / 5 (0 votes)