<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Joanne</title>
    <description>The latest articles on Forem by Joanne (@snelj).</description>
    <link>https://forem.com/snelj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F753817%2Febb408a3-c727-4797-ab11-6bd310030b23.jpeg</url>
      <title>Forem: Joanne</title>
      <link>https://forem.com/snelj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/snelj"/>
    <language>en</language>
    <item>
      <title>Exploring the lemon.markets instruments endpoint</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Fri, 21 Jan 2022 14:35:20 +0000</pubDate>
      <link>https://forem.com/lemon-markets/exploring-the-lemonmarkets-instruments-endpoint-2h3n</link>
      <guid>https://forem.com/lemon-markets/exploring-the-lemonmarkets-instruments-endpoint-2h3n</guid>
      <description>&lt;p&gt;At &lt;a href="https://lemon.markets"&gt;lemon.markets&lt;/a&gt;, we’re empowering developers to take brokerage into their own hands by building Europe’s first trading API. In today’s article, we want to showcase one of the useful endpoints we provide: &lt;code&gt;/instruments&lt;/code&gt;. It can be used to identify the various financial instruments that can be traded on lemon.markets, such as stocks and ETFs.&lt;/p&gt;




&lt;p&gt;The lemon.markets API currently offers 8250+ popular stocks and ETFs — we’ve got (most 😉) big-name instruments. Not sure if we carry a particular listing? You can easily use the '/instruments' endpoint to search for specific financial instruments. Want to see how it’s done? Let’s jump right in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why search for my financial instrument? 🔎
&lt;/h2&gt;

&lt;p&gt;If you already know the name of the financial instrument you wish to trade, why should you use the &lt;code&gt;/instruments&lt;/code&gt; endpoint? Our API identifies financial instruments through an ISIN (International Securities Identification Number). If you know the ISIN of the instrument you wish to trade, you’re ready to place your order! But, if you don’t, you can use this endpoint to find the ISIN associated with that instrument.&lt;/p&gt;

&lt;p&gt;Besides the ISIN, the &lt;code&gt;/instruments&lt;/code&gt; endpoint also provides information about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the exchange the instrument is listed on,&lt;/li&gt;
&lt;li&gt;the symbol, WKN and title associated with the instrument,&lt;/li&gt;
&lt;li&gt;the type of instrument you’re dealing with (stock/ETF/etc.),&lt;/li&gt;
&lt;li&gt;in which currency the instrument is traded and&lt;/li&gt;
&lt;li&gt;whether it’s currently tradable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This information allows you to double-check that you’re referring to the correct instrument, on the correct exchange, in the correct currency. Additionally, only placing orders if the instrument is currently tradable (and the exchange on which it’s traded is open), will ensure that you have no surprise unexecuted orders.&lt;/p&gt;

&lt;h2&gt;
  
  
  The /instruments endpoint 🎺
&lt;/h2&gt;

&lt;p&gt;To access the /instruments endpoint, you’ll need to use the following URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;markets&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;instruments&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Python, a &lt;code&gt;GET&lt;/code&gt; request using this URL looks as follows (note: we have sample code snippets in JavaScript in our &lt;a href="https://docs.lemon.markets/market-data/instruments-tradingvenues#get-instruments"&gt;docs&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://data.lemon.markets/v1/instruments/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
If you’d like to use this code snippet, you’ll have to insert your own API key.






&lt;p&gt;Without any search specifications, this endpoint will return all of the instruments that can be traded with the lemon.markets API (only a very short portion of the response is listed). Perhaps this is useful if you’re simply browsing what we have on offer. But, what if you’re looking for something specific?&lt;/p&gt;

&lt;h2&gt;
  
  
  Specifying your search ➡️
&lt;/h2&gt;

&lt;p&gt;Imagine you’re looking for the ISIN that belongs to Coinbase. How do we alter the search? There’s a number of query parameters that can be added to the end of the URL. These are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;search&lt;/code&gt;, search query for a name, title, ISIN, WKN or symbol (note: your query must be longer than 4 characters),&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isin&lt;/code&gt;, if you know the ISIN of the instrument you’re looking for (you can specify up to 10 different ISINs if you’re looking for more than one),&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mic&lt;/code&gt;, the Market Identifier Code of the exchange you wish to trade on,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;currency&lt;/code&gt;, ISO currency code for the currency in which you’d like to trade and&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tradable&lt;/code&gt;, a boolean value to filter for tradable and non-tradable instruments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Besides that, if your API result contains several entries, you can paginate through the response using the pagination parameters &lt;code&gt;limit&lt;/code&gt; and &lt;code&gt;page&lt;/code&gt;. If you’d like to learn more, you can find the details &lt;a href="https://docs.lemon.markets/market-data/overview#pagination-in-the-market-data-api"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In our case, we’re interested in specifying &lt;code&gt;search&lt;/code&gt; because we know the title of the instrument we’re looking for. And let’s specify &lt;code&gt;tradable&lt;/code&gt; because we only wish to return instruments that can be traded. This means the URL against which we place the request turns into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://data.lemon.markets/v1/instruments/?search=coinbase&amp;amp;tradable=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request is placed in the same way as in the above code sample. The API outputs the following response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"US19260Q1076"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"wkn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"A2QP7J"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COINBASE GLB.CL.A -,00001"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COINBASE GLOBAL INC."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"symbol"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1QZ"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"stock"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"venues"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Börse München - Gettex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Gettex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"mic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"XMUN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"is_open"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"tradable"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                    &lt;/span&gt;&lt;span class="nl"&gt;"currency"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"EUR"&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"previous"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the &lt;code&gt;results&lt;/code&gt; list now only contains one instrument because we specified our query with enough detail to narrow down the search. We can now use this ISIN to &lt;a href="https://medium.com/lemon-markets/placing-your-first-order-with-the-lemon-markets-trading-api-bcada2472b6e"&gt;place trades with the Trading API&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;That’s all there is to know about the &lt;code&gt;/instruments&lt;/code&gt; endpoint! We hope it was helpful in exploring what can be done with lemon.markets. If you’re not yet signed-up, &lt;a href="https://dashboard.lemon.markets/signup"&gt;join us&lt;/a&gt; today!&lt;/p&gt;

&lt;p&gt;Joanne from 🍋.markets&lt;/p&gt;

</description>
      <category>api</category>
      <category>programming</category>
      <category>trading</category>
      <category>algotrading</category>
    </item>
    <item>
      <title>Manage your trading portfolio with the lemon.markets brokerage API</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 18:55:21 +0000</pubDate>
      <link>https://forem.com/lemon-markets/manage-your-trading-portfolio-with-the-lemonmarkets-brokerage-api-3dnl</link>
      <guid>https://forem.com/lemon-markets/manage-your-trading-portfolio-with-the-lemonmarkets-brokerage-api-3dnl</guid>
      <description>&lt;p&gt;An important part of a functional brokerage service is the possibility to conveniently monitor everything related to your portfolio. Therefore, in this blog post, I want to dive deeper into how to keep an overview of your portfolio items with the &lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt; brokerage API.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt; was born out of the wish/need to have more flexibility in the way you manage your trading activities. The result of months of iteration with our beta users is an API that allows you to build your own brokerage experience at the stock market, customised to your individual use case. Check out our &lt;a href="https://docs.lemon.markets/"&gt;documentation&lt;/a&gt; to learn more about the structure of our API and what you can build with it.&lt;/p&gt;

&lt;p&gt;We offer different endpoints to, for instance, buy or sell stocks, retrieve historical market data or manage your account. However, in this blog post we we want to specifically deal with the &lt;code&gt;/portfolio&lt;/code&gt; endpoint which allows you to conveniently monitor your (who would’ve guessed?) portfolio.&lt;/p&gt;

&lt;p&gt;In general, your portfolio consists of different portfolio items that are the result of executed orders. This means that if your portfolio is empty and you place an order for 10 Tesla shares, once that order is executed (i.e. placed &lt;em&gt;and&lt;/em&gt; filled at the stock market) your portfolio consists of 10 shares of Tesla stock.&lt;/p&gt;

&lt;p&gt;Let’s take a look at how you get that information through the lemon.markets API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the /portfolio endpoint
&lt;/h2&gt;

&lt;p&gt;To access your portfolio, use the following URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/portfolio/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below, find an example code snippet in Python. Check out our &lt;a href="https://docs.lemon.markets/trading/working-with-portfolio-transactions"&gt;documentation&lt;/a&gt; for additional code snippets in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/portfolio/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Making the request stated above will result in a response similar to this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"2021-11-21T19:34:45.071+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"space_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sp_pyPFYssNNJyV4m8rxtK7LnfGwKLMk2njSv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"US19260Q1076"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"isin_title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"COINBASE GLOBAL INC."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"sell_quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_price_avg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2965000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_price_min"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2965000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_price_max"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2965000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_price_avg_historical"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2965000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"sell_price_min"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"sell_price_max"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"sell_price_avg_historical"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"orders_total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"sell_orders_total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"buy_orders_total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"space_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sp_pyPFYssNNJyV4m8rxtK7LnfGwKLMk2njSv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The results part of the response is an array of objects. Each object represents a different portfolio item and you can retrieve a lot of interesting information from it. For instance, the &lt;code&gt;space_id&lt;/code&gt; tells you which Space the portfolio item belongs to, &lt;code&gt;isin&lt;/code&gt; is the International Security Identification Number through which an instrument can uniquely be identified. Additionally, you receive information on the current quantity of the instrument in your portfolio, how many shares you bought, how many you sold and at what price.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with query parameters
&lt;/h2&gt;

&lt;p&gt;While a general overview of all portfolio items is nice, you might want to narrow your search. That’s what query parameters are for. In the &lt;code&gt;/portfolio&lt;/code&gt; endpoint, you can query for the &lt;code&gt;space_id&lt;/code&gt; and the &lt;code&gt;isin&lt;/code&gt;, which allows you to either only see portfolio items from a specific Space or only portfolio items for a specific instrument. Or both.&lt;/p&gt;

&lt;p&gt;Using the query parameters is really easy, you simply add them to your request URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/portfolio/?isin=US88160R1014"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will result in only Tesla portfolio items being displayed. If you have multiple Spaces with which you traded Tesla stock, you will still retrieve multiple objects, e.g. Space 1 with 17 Tesla shares, Space 2 with 9 Tesla shares, and Space 3 with 2 Tesla shares. However, if you only hold the respective portfolio item in one of your Spaces, the API will only return a results array of length one.&lt;/p&gt;

&lt;p&gt;Additionally, you can also enforce to only get one result by also specifying a &lt;code&gt;space_id&lt;/code&gt; next to the &lt;code&gt;isin&lt;/code&gt;. Simply add &lt;code&gt;&amp;amp;space_id={YOUR_SPACE_ID}&lt;/code&gt; to the request URL displayed above. With that request, you will get the portfolio information of a specific instrument in a specific Space.&lt;/p&gt;

&lt;h2&gt;
  
  
  And now: what to do with it?
&lt;/h2&gt;

&lt;p&gt;The possibilities from here on are (almost) endless. You could build your own dashboard to display your portfolio using some cool charts, you could integrate the information in your own custom trading app or build an analysis tool that automatically buys or sells stock to rebalance your portfolio. Get creative!&lt;/p&gt;




&lt;p&gt;We are really excited for you to try out our API and help shape a product that developers enjoy using. Make sure to sign up on our &lt;a href="https://www.lemon.markets/"&gt;website&lt;/a&gt; and join our growing &lt;a href="https://lemonmarketscommunity.slack.com/join/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA#/shared-invite/email"&gt;Slack community&lt;/a&gt; where we discuss all things lemon.markets with more than 400 developers.&lt;/p&gt;

&lt;p&gt;See you there,&lt;/p&gt;

&lt;p&gt;the 🍋.markets team&lt;/p&gt;

</description>
      <category>api</category>
      <category>programming</category>
      <category>trading</category>
      <category>algotrading</category>
    </item>
    <item>
      <title>Placing your first order with the lemon.markets Trading API</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 18:47:22 +0000</pubDate>
      <link>https://forem.com/lemon-markets/placing-your-first-order-with-the-lemonmarkets-trading-api-5cjc</link>
      <guid>https://forem.com/lemon-markets/placing-your-first-order-with-the-lemonmarkets-trading-api-5cjc</guid>
      <description>&lt;p&gt;&lt;a href="https://lemon.markets"&gt;lemon.markets&lt;/a&gt; offers a simple API that allows you to create your own &lt;strong&gt;brokerage experience&lt;/strong&gt; at the stock market. An important part of that is the possibility to &lt;strong&gt;place orders with one simple API call&lt;/strong&gt;. In this blog post, I will walk you through the steps you need to take to &lt;strong&gt;place and activate an order&lt;/strong&gt; with the &lt;strong&gt;lemon.markets Trading API&lt;/strong&gt;. Ready, set, go 🏃👩‍💻&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting access
&lt;/h2&gt;

&lt;p&gt;Start by signing up on our &lt;a href="https://dashboard.lemon.markets/"&gt;dashboard&lt;/a&gt;. After you verified your account, you can log in and use the first API Key and &lt;a href="https://medium.com/lemon-markets/introducing-lemon-markets-spaces-890d3c1ea6e"&gt;Space&lt;/a&gt; that we already created for you by default. After that, you are ready to place your first order.&lt;/p&gt;

&lt;h2&gt;
  
  
  Place your first order
&lt;/h2&gt;

&lt;p&gt;To place an order with lemon.markets, you need to address the trading API by making a POST request against the base URL and add /orders/ to it:&lt;/p&gt;

&lt;p&gt;To place an order with lemon.markets, you need to address the trading API by making a POST request against the base URL and add /orders/ to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/orders/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to specify your order through your request body. &lt;/p&gt;

&lt;p&gt;Some of the parameters in there are required (&lt;code&gt;isin&lt;/code&gt; to specify the instrument you want to buy, &lt;code&gt;expires_at&lt;/code&gt; to define when the order expires, &lt;code&gt;side&lt;/code&gt; to either buy or sell, &lt;code&gt;quantity&lt;/code&gt; to specify how many shares you wish to buy, &lt;code&gt;venue&lt;/code&gt; to address a specific trading venue, and &lt;code&gt;space_id&lt;/code&gt; to place the order for a specific space). &lt;/p&gt;

&lt;p&gt;Others are optional (&lt;code&gt;stop_price&lt;/code&gt; to place a stop market order, &lt;code&gt;limit_price&lt;/code&gt; for a limit order, or both for a stop limit order, or &lt;code&gt;notes&lt;/code&gt; if you want to add some notes with your order so you later know why you placed it in the first place). &lt;/p&gt;

&lt;p&gt;See an example request in Python below. You can check out our &lt;a href="https://docs.lemon.markets/"&gt;documentation&lt;/a&gt; for additional code snippets in JavaScript and more detailed explanations on different request parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="s"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"US19260Q1076"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"2021-11-25"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"side"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"buy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"stop_price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"limit_price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5300000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"venue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"XMUN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"space_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"123456789"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"notes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"I want to attach a note to this order"&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
Place your order





&lt;h2&gt;
  
  
  Dealing with the API Response
&lt;/h2&gt;

&lt;p&gt;When you successfully placed your order, the API responds with a&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;200 
"status": "ok"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and outputs some additional response elements. For instance, you learn about the &lt;code&gt;estimated_price&lt;/code&gt; or the regulatory information associated to your order. And you receive the &lt;code&gt;order_id&lt;/code&gt;, which is crucial for the next (and final) step before your order can get executed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Activating an Order
&lt;/h2&gt;

&lt;p&gt;Before we route your order to a trading venue, you first need to activate it. You can do this through the following endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/orders/{order_id}/activate/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See now why it is crucial that the POST request against the /orders/ endpoint returns the &lt;code&gt;order_id&lt;/code&gt;? Using the ID, we can activate the order through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/{order_id}/activate/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
Activate an order through its order_id






&lt;p&gt;On success, the order is activated and routed to the specified trading venue. You can now sit back and relax — your work here is done (for now).&lt;/p&gt;

&lt;h2&gt;
  
  
  Retrieving your Orders
&lt;/h2&gt;

&lt;p&gt;You can retrieve all your orders by posting a GET request against the &lt;code&gt;/orders&lt;/code&gt; endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/orders/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To specify your request, you can add &lt;strong&gt;query parameters&lt;/strong&gt; to your request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;space_id&lt;/code&gt;: filter for orders from a specific space&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;from&lt;/code&gt; &amp;amp; &lt;code&gt;to&lt;/code&gt;: you can define a time range from which you want to retrieve orders&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isin&lt;/code&gt;: add this query parameter to only see orders related to a specific isin&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;side&lt;/code&gt;: query parameter to see only buy or sell orders&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;status&lt;/code&gt;: filter for order status, e.g. inactive or executed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt;: filter for different types of orders: market, stop, limit, stop_limit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the example request below to learn how to use the query parameters in your request. In the example, we only want to see Tesla buy orders, therefore using the &lt;code&gt;isin&lt;/code&gt; and &lt;code&gt;side&lt;/code&gt; query parameters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/?isin=US88160R1014&amp;amp;&amp;amp;side=buy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Ideas for Inspiration
&lt;/h2&gt;

&lt;p&gt;You now know how to place an order with the lemon.markets Trading API. Now: what to do with it? There are plenty of use cases. Think of the order placement as the final step in your awesome trading project. You have an automated trading strategies that buys stocks based on predefined criteria? Great, the order endpoint is triggered when a certain threshold in your algo is crossed. You built your own trading app to buy and sell stocks? Great, whenever you click the buy/sell button in your application, you will need the POST /orders/ endpoint. What are your additional ideas for how to use the &lt;code&gt;/orders&lt;/code&gt; endpoint? Let us know 🙂&lt;/p&gt;

&lt;p&gt;I hope you got a good understanding of one of our most crucial API endpoints. If you have any questions or want to get in touch with other liked-minded developers: join our growing &lt;a href="https://lemonmarketscommunity.slack.com/join/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA#/shared-invite/email"&gt;Slack community&lt;/a&gt; and discuss your newest trading project idea. And for more inspiration: check out our &lt;a href="https://medium.com/lemon-markets"&gt;other blog articles&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Excited to see what you are building with us 😍&lt;/p&gt;

</description>
      <category>trading</category>
      <category>programming</category>
      <category>api</category>
      <category>algotrading</category>
    </item>
    <item>
      <title>Working with lemon.markets Spaces👩‍🚀</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 18:24:40 +0000</pubDate>
      <link>https://forem.com/lemon-markets/working-with-lemonmarkets-spaces-36a8</link>
      <guid>https://forem.com/lemon-markets/working-with-lemonmarkets-spaces-36a8</guid>
      <description>&lt;p&gt;Hey there, it’s Joanne from &lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt;. We are building a &lt;strong&gt;brokerage API&lt;/strong&gt; to enable developers to build their own brokerage experience at the stock market. In this blog post, we’re not just hopping on the trendy #ToTheMoon hashtag, but instead introduce a real &lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt; concept: &lt;a href="https://docs.lemon.markets/spaces"&gt;&lt;strong&gt;the Space&lt;/strong&gt;&lt;/a&gt; 🚀. Spaces are a crucial component for using lemon.markets. We’ve already written a &lt;a href="https://medium.com/lemon-markets/introducing-lemon-markets-spaces-890d3c1ea6e"&gt;whole article&lt;/a&gt; about the concept and why you should use them, but if you’d like the TL;DR: a Space is an &lt;strong&gt;isolated workspace&lt;/strong&gt; for you to run your trading algorithm/product in such that you can segment your different projects.&lt;/p&gt;

&lt;p&gt;In this article, I’ll walk you through how to work with the &lt;code&gt;/spaces&lt;/code&gt; endpoint (note that all examples will be in Python). Strap in, we’re blasting off in 3.. 2.. 1.. 👾&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting your Space(s) 🌌
&lt;/h2&gt;

&lt;p&gt;When you sign-up to lemon.markets, we’ll automatically create a ‘Default’ Space for you — meaning you can start trading right away. Let’s look at that Space, shall we? To retrieve a list of your Spaces, send the following request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/spaces/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
We are using the Paper Trading URL in these examples, but you can apply the same concepts to the Real Money environment by changing the URL to https://trading.lemon.markets/v1/spaces/





&lt;p&gt;This will output something along the lines of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-12-09T14:14:27"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"manual"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"risk_limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"linked"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"created_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-11-11T19:04:03.984+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sp_example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"buying_power"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"earnings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"backfire"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"previous"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
Each Space has an associated ID. We’ve changed the “id” to “sp_example” in this response for the sake of the article, but you’ll get a longer string.





&lt;p&gt;At this point, we only have a single Space, which is why this list only contains a single element (can also be seen from the total parameter in the response). Each Space can be identified by its Space ID (id in the response). If you want to retrieve the details for a single Space, you can specify the Space ID as a path parameter. This means the URL in the above request changes to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/spaces/{space_id}/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;space_id&lt;/code&gt; is the ID of the desired Space.&lt;/p&gt;

&lt;p&gt;It’s also possible to filter the retrieved list of Spaces by type (automatic or manual) by including the query parameter &lt;code&gt;type&lt;/code&gt; in the URL. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/spaces/?type=manual
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, what does this response tell you? You can access the name of the Space and it’s description (which is null in this case, but I’ll show you how to add a description to a new Space shortly). You can also see whether it’s a ‘manual’ or ‘automatic’ Space, namely whether your Space is configured with order execution that requires manual approval or not. You can see the risk limit, the amount of funds that you have allocated to that Space (note: monetary amounts are represented with &lt;a href="https://docs.lemon.markets/trading/overview#working-with-numbers-in-the-trading-api"&gt;4 trailing zeroes&lt;/a&gt;, i.e. €100 is represented as 1000000). You’ll see whether it is linked to a Real Money/Paper Space, when it was created and its ID. And lastly, you’ll be able to retrieve the buying power, which is the amount of money you have left to invest, your earnings, which is the profit of that Space and your backfire, which are your aggregated earnings and losses.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Space 🛸
&lt;/h2&gt;

&lt;p&gt;To create a new Space, send the following POST request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/spaces/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"My Space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"manual"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"risk_limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"I want to buy ETFs with this Space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
Remember, we use 4 trailing zeroes, this means this Space has a risk limit of €1,000.






&lt;p&gt;In this example, we create a Space with the name ‘My Space’ and description ‘I want to buy ETFs with this Space’.&lt;/p&gt;

&lt;h2&gt;
  
  
  Altering your Space 🛰️
&lt;/h2&gt;

&lt;p&gt;If you’ve made a mistake in naming your Space, you can always alter its details, specifically the name, description and risk limit. You can do that with a PUT request as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/spaces/{space_id}/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"I've added more money to My Space"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"risk_limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
You’ll need to replace {space_id} with your own Space ID.






&lt;p&gt;Now, My Space has a new description and a higher risk limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deleting your Space 👽
&lt;/h2&gt;

&lt;p&gt;If you don’t need your Space anymore, you can delete it with the following DELETE request (proceed with caution because this action is not reversible):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/spaces/{space_id}/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                          &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s important to note that you can only delete Spaces that do not hold any open positions or pending orders. You must close out of all your positions before deleting a Space.&lt;/p&gt;




&lt;p&gt;That’s all there is to know about Space creation, deletion, updates and retrieval. Do you have any additional questions? Feel free to leave them below or reach out to us via &lt;a href="https://join.slack.com/t/lemonmarketscommunity/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA"&gt;Slack&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you’re not yet signed-up to lemon.markets, you can do that &lt;a href="https://www.lemon.markets/"&gt;here&lt;/a&gt;. We’d love to have you on board! 🚀&lt;/p&gt;

&lt;p&gt;See you soon,&lt;/p&gt;

&lt;p&gt;Joanne 🍋&lt;/p&gt;

</description>
      <category>trading</category>
      <category>api</category>
      <category>programming</category>
      <category>algotrading</category>
    </item>
    <item>
      <title>How to access your lemon.markets Trading API Account with one API call</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 16:45:18 +0000</pubDate>
      <link>https://forem.com/lemon-markets/how-to-access-your-lemonmarkets-trading-api-account-with-one-api-call-4h5g</link>
      <guid>https://forem.com/lemon-markets/how-to-access-your-lemonmarkets-trading-api-account-with-one-api-call-4h5g</guid>
      <description>&lt;p&gt;We at &lt;a href="https://www.lemon.markets/?utm_source=medium&amp;amp;utm_medium=medium&amp;amp;utm_campaign=account-blog-post"&gt;lemon.markets&lt;/a&gt; provide the infrastructure so everyone can build their own brokerage experience at the stock market. In this blog post, we show you how to easily access your trading account information with one simple API call. Additionally, we dive a little deeper into our /account endpoint. Let us begin!&lt;/p&gt;

&lt;h2&gt;
  
  
  Signing up
&lt;/h2&gt;

&lt;p&gt;The first step to accessing your account is to make sure that you actually have one. So, sign up on our &lt;a href="https://dashboard.lemon.markets/"&gt;dashboard&lt;/a&gt; and verify your account through the email that we send you after registration. You can then sign into the dashboard, where we already provide you with your first API Key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding your way around our API
&lt;/h2&gt;

&lt;p&gt;Using that API Key, you can go ahead and start testing our API. You can find everything you need to know in our &lt;a href="https://docs.lemon.markets/"&gt;documentation&lt;/a&gt;. We created several endpoints concerned with everything related to your account. Using these endpoints, you can find information about your name (in case you forgot), your current balance, how much cash you have left to invest, the IBAN of your brokerage account and many many more things.&lt;/p&gt;

&lt;p&gt;To retrieve information about your account, place a GET request against the following request URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/account/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can do so by grabbing the API Key from your dashboard and placing it into the following Python code snippet (find a JavaScript example in our &lt;a href="https://docs.lemon.markets/trading/account"&gt;documentation&lt;/a&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/account/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Placing this request will result in a response similar to this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-11-22T15:37:56.520+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"created_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-10-12T10:29:49.769+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"account_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"acc_pyNQNll99hQbXMCS0dRzHyKQCRKYHpy3zg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"firstname"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Michael"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lastname"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Burry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"m_burry@tradingapi.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"phone"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"+491637876521"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Ritterstraße 2A 10969 Berlin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"billing_address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Ritterstraße 2A 10969 Berlin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"billing_email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"m_burry@tradingapi.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"billing_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Michael Burry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"billing_vat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DE999999999"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"money"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deposit_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"K2057263187"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2057263"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"account_number"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2057263187"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"iban_brokerage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DE12345678902057263"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"iban_origin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DE123456789012345"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bank_name_origin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Test Bank"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"balance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"cash_to_invest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"cash_to_withdraw"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;20000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"trading_plan"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"basic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"data_plan"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"basic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tax_allowance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8010000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tax_allowance_start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-01-01"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tax_allowance_end"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-01-01"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, you get a lot of information on everything related to your account, like when it was created, what your current balance is, on which trading &amp;amp; data plan you are on and the IBAN of your brokerage account. Make sure to check out our &lt;a href="https://docs.lemon.markets/trading/account"&gt;documentation&lt;/a&gt; for in-depth information on all endpoint response parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Withdrawing money
&lt;/h2&gt;

&lt;p&gt;As you can see in the endpoint response above, you also have a response element called &lt;code&gt;cash_to_withdraw&lt;/code&gt;. This is your current balance minus the current sum of your buy orders. Based on that number, you can very easily withdraw money into your reference account via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/account/withdrawals/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Note that we are currently still working on releasing the real money feature, so it might take some more time until you can use this endpoint 🙂)&lt;br&gt;
Use the following code snippet (with your own API Key, of course) to withdraw money into your reference account.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/account/withdrawals/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
               &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="n"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1234&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define the amount you want to withdraw in your request body, along with your individual 4-digit PIN that you set during your onboarding process. After a successful API request, the specified amount is automatically withdrawn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retrieving your Bank statements
&lt;/h2&gt;

&lt;p&gt;Obviously, as a user you are interested in staying up to date regarding all activity that is happening on your account. That is what the &lt;code&gt;/bankstatements&lt;/code&gt; endpoint is there for. The endpoint returns a list of objects containing all activities from your last “active day” (in the paper money environment) and all activities from the last working day (in the real money environment), where, by default, an end of day balance is created for you. You can access your bank statements using the following request URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/account/bankstatements/?type=order_buy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return a response similar to the following one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-12-20T12:48:06.199+00:00"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"paper"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bst_pyHLSwwFFd6r9fJsNbFhxrB3sl43xCP1GK"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"account_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"acc_pyNQNll11hQbXMCS0dRzHyNKLZTYHpy3zg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eod_balance"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-12-16"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;987033450&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"isin_title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bst_pyQWCwwFFrBm9NhMYJ1yYDnhnMtMs64DNT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"account_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"acc_pyNQNll11nQbXMCS0dRzHyKQCRKYHpy3zg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"order_buy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-12-16"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8829000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"US88160R1014"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"isin_title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"TESLA INC."&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"previous"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"pages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the last thing I did was I placed a buy order in the paper environment and an end of day balance was created for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing some documents
&lt;/h2&gt;

&lt;p&gt;Lastly, you have the chance to very easily access all important documents related to your account via the following URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/account/documents/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the following code snippet, extended by your own API Key, to retrieve a list of documents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/account/documents/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bearer YOUR-API-KEY"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will provide you with a list similar to this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-11-22T15:41:04.028+00:00"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"doc_pyNjNcc77ht3T3lH8dJa5fD8jhj2JHJ1xX"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"account_opening.pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"created_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-10-19T14:58:52.813Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"category"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"kyc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"public_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://testpublicurl.de/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"'https://trading.lemon.markets/v1/account/documents/doc_pyNjNcc77ht3T3lH8dJa5fD8jhj2JHJ1xX"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"viewed_first_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-10-19T14:58:52.813Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"viewed_last_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-10-19T14:58:52.813Z"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In there, you find all documents, along with a download link. By clicking the link, you are redirected to a .pdf version of the file.&lt;/p&gt;




&lt;p&gt;Alright, that was all there is to say about the &lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt; account endpoints and what you can do with them. Make sure to &lt;a href="https://login.lemon.markets/u/login/identifier?state=hKFo2SBaVjJ4WDBGOTRfb1dmYmF4RHFMcjlOMkhqTEoySERTeqFur3VuaXZlcnNhbC1sb2dpbqN0aWTZIDdSLVNLd1pqcThRMEo5TXlINEppRTN3Q2lZRnpqb29lo2NpZNkgY0swQlhzc1V2U3lybUtVSVo3YTJLdmVvZ1F6eVNWSWo"&gt;sign up&lt;/a&gt; to our trading API to build your own brokerage experience at the stock market. Also, join our &lt;a href="https://lemonmarketscommunity.slack.com/join/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA#/shared-invite/email"&gt;Slack community&lt;/a&gt;, where we discuss all things trading and lemon.markets with more than 400 developers.&lt;/p&gt;

&lt;p&gt;Looking forward to seeing you there 🍋 🚀&lt;/p&gt;

</description>
      <category>trading</category>
      <category>api</category>
      <category>algotrading</category>
      <category>programming</category>
    </item>
    <item>
      <title>Using the lemon.markets Postman workspace 📮</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 14:20:20 +0000</pubDate>
      <link>https://forem.com/lemon-markets/using-the-lemonmarkets-postman-workspace-57eb</link>
      <guid>https://forem.com/lemon-markets/using-the-lemonmarkets-postman-workspace-57eb</guid>
      <description>&lt;p&gt;An easy way to test out the &lt;a href="https://www.lemon.markets/"&gt;lemon.markets&lt;/a&gt; API is by using Postman, a platform that allows you to make API calls right within your browser or desktop app. This way, before you get to building your brokerage product, you’ll know exactly what’s possible. We’ve set up a &lt;strong&gt;&lt;a href="https://www.postman.com/lemonmarkets/"&gt;lemon.markets Postman workspace&lt;/a&gt;&lt;/strong&gt; that can be used to familiarise yourself with the endpoints that we offer in our Market Data and Trading APIs. You’ll see just how simple it is to, for example, place a trade with lemon.markets (hint: it’s just one API call).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Postman? 📯
&lt;/h2&gt;

&lt;p&gt;Postman is an easy-to-use application that allows you to test out an API without having to manually set up a testing environment. It’s as simple as filling in a request URL, providing the proper authorisation and inputting the relevant query/request body parameters. Luckily for you, we’ve already set up a lemon.markets Postman workspace with all requests included, all you need to do is &lt;strong&gt;fork it&lt;/strong&gt;, &lt;strong&gt;fill in your API key&lt;/strong&gt; and &lt;strong&gt;start sending requests&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Postman 👨
&lt;/h2&gt;

&lt;p&gt;The lemon.markets Postman workspace can be found &lt;a href="https://www.postman.com/lemonmarkets/workspace/lemon-markets/overview"&gt;here&lt;/a&gt;. For personal use, you need to import the workspace into your own Postman account. Let’s see how that’s done!&lt;/p&gt;

&lt;h3&gt;
  
  
  Forking the workspace 🍴
&lt;/h3&gt;

&lt;p&gt;We’re assuming you already have a Postman account, but if you don’t, you can easily set one up, &lt;a href="https://identity.getpostman.com/signup"&gt;here&lt;/a&gt;. Because the workspace is public, you need to fork it into your own workspace to be able to send requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nQdwe-ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16mypxtggsifkjuhyylt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nQdwe-ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16mypxtggsifkjuhyylt.png" alt="_Forking the workspace_" width="758" height="806"&gt;&lt;/a&gt;&lt;/p&gt;
To fork our workspace, click the ‘…’ next to the collection of your choice and select ‘Create a fork’.




&lt;p&gt;You’ll be prompted to give the fork a name and select a workspace to copy it into. You can choose to create a separate lemon.markets workspace, or simply copy it into the default ‘My Workspace’.&lt;/p&gt;

&lt;p&gt;To make requests, you’ll need to set up several environment variables — we’ve also set up a &lt;strong&gt;template&lt;/strong&gt; for this (which you can also fork in the same way).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6IexejNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llb2dqeae9bkg7zqp695.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6IexejNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llb2dqeae9bkg7zqp695.png" alt="Image description" width="758" height="668"&gt;&lt;/a&gt;&lt;/p&gt;
The environment templates can be found under the conveniently named ‘Environments’ tab on the left hand side.



&lt;h3&gt;
  
  
  Configuring the environment 🌳
&lt;/h3&gt;

&lt;p&gt;To set-up your environment, you’ll want to &lt;strong&gt;fill in your lemon.markets API key&lt;/strong&gt; (this can be found on your dashboard). Because your workspace is only accessible to you, it doesn’t matter whether you fill it in under ‘Initial Value’ or ‘Current Value’, but as a best practice, you should always fill in sensitive information under ‘&lt;strong&gt;Current Value&lt;/strong&gt;’. This prevents the information from being synced with the Postman workspace (especially important if you’re working in a (semi-)public workspace).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ivLvGmyv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r3agv3alxhs1z9p2pp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ivLvGmyv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r3agv3alxhs1z9p2pp9.png" alt="Image description" width="880" height="244"&gt;&lt;/a&gt;&lt;/p&gt;
You’ll know you’re in your forked workspace due to the Ψ next to the environment name — notice I’ve called my fork ‘lemon_tutorial’.



&lt;p&gt;If you already know which Space you’d like to operate in, you can also fill in the ID here. But, if you still need to create a &lt;a href="https://medium.com/lemon-markets/introducing-lemon-markets-spaces-890d3c1ea6e"&gt;Space&lt;/a&gt; or don’t know its ID, we’ll show you how you can use the Trading API workspace to access this information.&lt;/p&gt;

&lt;p&gt;Make sure you &lt;strong&gt;save any changes&lt;/strong&gt; (upper right-hand corner) and &lt;strong&gt;set the environment active&lt;/strong&gt;, you can do this by hovering over its name and clicking the check-mark, which should become grey upon success.&lt;/p&gt;

&lt;p&gt;If you’ve properly set up your API key and environment, the environment should appear in the upper right-hand corner (as can be seen in the screenshot below). Additionally, if you navigate to the authorisation tab for either Collection, hovering over &lt;code&gt;{{API-KEY}}&lt;/code&gt; should display the key you’ve filled in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3iWFGsBf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrq8afqy4ki2shopmxet.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3iWFGsBf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrq8afqy4ki2shopmxet.png" alt="Image description" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
If you can’t see your API key upon hovering, ensure that your environment has been saved and set active (you might need to manually select it in the upper right-hand corner if you have more than one environment).




&lt;h3&gt;
  
  
  Making your first request ❓
&lt;/h3&gt;

&lt;p&gt;Let’s begin by getting a list of our Spaces. Navigate to the ‘Space’ folder in the Trading API collection. Here, you have the option to retrieve a list of Spaces or a single Space, but also to create, delete and alter a Space (these are all the functionalities that our /spaces/ endpoint offers). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RRYl-Zl3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8zi0otlrt9kvcw4d13e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RRYl-Zl3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8zi0otlrt9kvcw4d13e.png" alt="Image description" width="880" height="456"&gt;&lt;/a&gt;&lt;/p&gt;
If you haven’t filled in a Space ID yet, you can copy one from the desired Space after placing this request and paste it into your environment (remember to save!). You’ll need to place other requests. You can also create a new Space using the POST request that can be found under the same Space header.



&lt;p&gt;The API response can be found in the console below after clicking the blue ‘Send’ button. In the screenshot, my Space ‘Postman Space’ created on 24 November 2021 can be seen (scrolling shows my other Spaces).&lt;/p&gt;

&lt;p&gt;You can also specify &lt;strong&gt;query parameters&lt;/strong&gt; in your request. In this case, you can choose to filter by Paper Money and Real Money Spaces, all you need to do is toggle the ‘type’ key, fill in a value and run the request again. More on that in the next section. 👇&lt;/p&gt;

&lt;h3&gt;
  
  
  Other important considerations 🤔
&lt;/h3&gt;

&lt;p&gt;To get the most of the lemon.markets workspace, we recommend you read the following tips:&lt;/p&gt;

&lt;p&gt;Some endpoints, for example the /ohlc/ endpoint in our Historical Market Data API, have &lt;strong&gt;mandatory query parameters&lt;/strong&gt;. For all query parameters that are &lt;strong&gt;required&lt;/strong&gt;, we’ve configured the workspace to automatically toggle that parameter (indicated by the checked box). But, whether it is optional or required can also be found in the key-value description. In addition, some requests also require &lt;strong&gt;path variables&lt;/strong&gt; as input — these are listed below any query parameters (they can also be recognised in the request URL by a ‘:’). If specified, these are &lt;strong&gt;always required&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_3pE8rcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08dhpwzwpj2y56inv7wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_3pE8rcw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08dhpwzwpj2y56inv7wg.png" alt="Image description" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;
Note that ‘isin’ is the only required query parameter for this endpoint, we also need to specify the path variable ‘x1’ in order to send this request.



&lt;p&gt;Other endpoints require a &lt;strong&gt;request body&lt;/strong&gt;, you’ll recognise this by the green dots next to the headers underneath the request URL. For example, for the /orders/ endpoint in our Trading API, you’ll notice the green dot next to ‘Body’, this means that we need to fill in information here. Notice that there’s a lot of required variables here! I’ve filled in some example values below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h3fKJNnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dakzjykrhjd94asqj3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h3fKJNnV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dakzjykrhjd94asqj3x.png" alt="Image description" width="880" height="456"&gt;&lt;/a&gt;&lt;/p&gt;
In the above screenshot, you’ll see I placed a buy order for 2 shares of Tesla.




&lt;p&gt;All other requests follow a similar format — some require you to fill in both ‘Params’ and ‘Body’ variables. Keep an eye out for those green dots!&lt;/p&gt;




&lt;p&gt;You’re ready to explore on your own! How about you try placing and activating a trade? And then having a look at your portfolio? Have a look at our &lt;a href="https://docs.lemon.markets/"&gt;documentation&lt;/a&gt; to see what’s possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Over to you! 🤝
&lt;/h2&gt;

&lt;p&gt;We want to know how we can make this collection better! If there’s any improvements that come to mind, do not hesitate to reach out to us through &lt;a href="https://twitter.com/lemon_markets"&gt;Twitter&lt;/a&gt;, &lt;a href="https://www.instagram.com/lemon.markets/"&gt;Instagram&lt;/a&gt; or &lt;a href="https://join.slack.com/t/lemonmarketscommunity/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA"&gt;Slack&lt;/a&gt;. And remember, if you haven’t signed up to lemon.markets yet, do that &lt;a href="https://dashboard.lemon.markets/"&gt;now&lt;/a&gt; to kickstart your automated trading journey.&lt;/p&gt;

&lt;p&gt;Joanne from lemon.markets🍋&lt;/p&gt;

</description>
      <category>postman</category>
      <category>api</category>
      <category>trading</category>
      <category>algotrading</category>
    </item>
    <item>
      <title>Understanding the lemon.markets Trading API</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 14:00:51 +0000</pubDate>
      <link>https://forem.com/lemon-markets/understanding-the-lemonmarkets-trading-api-3ioc</link>
      <guid>https://forem.com/lemon-markets/understanding-the-lemonmarkets-trading-api-3ioc</guid>
      <description>&lt;p&gt;Offering our users the possibility to conveniently trade via an API is what we at &lt;a href="https://www.lemon.markets/?utm_source=medium&amp;amp;utm_medium=medium&amp;amp;utm_campaign=understanding-the-trading-api" rel="noopener noreferrer"&gt;lemon.markets&lt;/a&gt; have been working on on a daily basis over the past year. As we just started our public beta a few weeks ago, this goal now slowly becomes reality. In this blog post, I want to introduce you to the structure and functionalities of our Trading API so you can easily get started building your own brokerage experience at the stock market. Let’s get going.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why trade via an API?
&lt;/h3&gt;

&lt;p&gt;The starting point for lemon.markets was in early 2020 when we painfully realised that there’s no brokerage service in Europe that allows its users to build a trading product in a flexible way, just as they imagine it. What initially started as an interface to automate your trades, lemon.markets evolved into an infrastructure that gives you the freedom to build (basically) any kind of product. Some people may be unsatisfied with the current offering of trading apps and want to create their own application. Others may be interested in setting up an automated trading strategy that does all the work for them. Some people might even be interested in placing a trade in their favourite messaging app (what a coincidence, see an example for a Telegram Trading bot &lt;a href="https://medium.com/lemon-markets/setting-up-your-own-telegram-bot-to-trade-with-the-lemon-markets-api-part-1-of-2-98d7153bd5f6" rel="noopener noreferrer"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, we set out on bringing this infrastructure to life and (tada 🎉) have now arrived at a point where we want to share what we created with all of you.&lt;/p&gt;

&lt;p&gt;You can see the structure of our Trading API below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbfocalimm578w3e1m6na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbfocalimm578w3e1m6na.png" alt="lemon.markets Trading API Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s dive into the endpoints
&lt;/h2&gt;

&lt;p&gt;As you can see, there are two base URLs for our Trading API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://paper-trading.lemon.markets/v1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://trading.lemon.markets/v1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have separate URLs for Paper and for Real Money Trading. The APIs follow a near-identical structure (with some real-money specifics). This means that before exposing your product to your hard earned money, you can safely deploy it to a simulated paper-money environment. All without making any changes to your implementation. And once you’re happy with it, you can simply exchange the base URL and your project will be running as before, only this time with real money.&lt;/p&gt;

&lt;p&gt;For the rest of the article, we will use the Paper Money base URL for demonstration purposes. We will take a look at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to retrieve your account information,&lt;/li&gt;
&lt;li&gt;how to see your spaces and create a new one,&lt;/li&gt;
&lt;li&gt;how to create a new order and see previous orders,&lt;/li&gt;
&lt;li&gt;how to see all your transactions and&lt;/li&gt;
&lt;li&gt;how to monitor your portfolio.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are interested in diving deeper into our API: check out our &lt;a href="https://docs.lemon.markets/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;. There, you will also find information about how to get access to the API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interacting with your account
&lt;/h3&gt;

&lt;p&gt;To retrieve information about your account such as name, email address, the IBAN of your brokerage account or how much cash you have left to invest, make a request against the /account endpoint. See below how to address this endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/account/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Spaces
&lt;/h3&gt;

&lt;p&gt;Spaces are an important concept for using the lemon.markets API. It allows you to split your account into different trading projects and thereby limit the overall risk. Find out more about the concept &lt;a href="https://medium.com/lemon-markets/introducing-lemon-markets-spaces-890d3c1ea6e" rel="noopener noreferrer"&gt;here&lt;/a&gt;. To create a new Space, use the following code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/spaces/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;MyNewSpace&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;type&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;manual&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;risk_limit&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;description&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I am trying out my new strategy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to post the request body in JSON format. You have the option to set a name, type of Space (manual or auto), risk limit (the overall limit you can spend on orders with that trade) as well as a description. To learn more about Spaces, e.g. what the difference between a manual and an automated space is, check out our &lt;a href="https://docs.lemon.markets/spaces" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Afterwards, you can see all your Spaces. You can also use the query parameter &lt;strong&gt;type&lt;/strong&gt; to only see manual or auto Spaces. Use the following code snippet for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/spaces/?type=manual&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your response will look something like this. As you can see, you can, among others, retrieve your Space ID, which you can use to perform requests for your space, e.g. placing an order or retrieving your portfolio. You also get information on how much money you have left to spend within that space and what your risk limit is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2021-12-20T12:54:09.192+00:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"paper"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"result"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; 
  &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MyPersonalSpace"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"In this Space, I only trade stocks"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"manual"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"risk_limit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"linked"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"sp_pyJHBffGGDyV4m8rxtJ7BnfGwKLNk3bnBy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"buying_power"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;97035000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"earnings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"backfire"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2965000&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Orders
&lt;/h3&gt;

&lt;p&gt;Placing orders is one of the core features of the Trading API. You can do that with one simple request. In there, you specify all things relevant for your order placement. Using the “isin” request parameter, we buy one share of Coinbase in the example below. Additionally, you can specify when you want the order to expire (“expires_at”) or the Space you want to place the order within (“space_id”).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/orders/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;isin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;US19260Q1076&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;expires_at&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;2021-11-10T22:59:00.000+00:00&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;side&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;buy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;quantity&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;venue&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;XMUN&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;space_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;123456789&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;notes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This is an informative note attached to my order&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
            &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterwards, you may want to check the orders you already placed. You can filter the orders returned by the API by different query parameters. For example, you could be interested in only seeing buy orders for a specific ISIN. To retrieve these orders, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/orders/?side=buy&amp;amp;&amp;amp;isin=US88160R1014&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Portfolio
&lt;/h3&gt;

&lt;p&gt;Finally, using our Trading API you can also retrieve all of your portfolio items by calling the /portfolio endpoint. To make the request more specific, you can query by space and/or ISIN:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://paper-trading.lemon.markets/v1/portfolio/?space_id=123456789&amp;amp;&amp;amp;isin=US88160R1014/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Authorization&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bearer YOUR-API-KEY-HERE&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Alright, that was our little deep dive into the lemon.markets Trading API. We hope you learned something and are now more than hyped to start building. We can’t wait to have you on board. Side note: the Trading API is only one of the two APIs that we offer, the other one is our Market Data API, which you can learn more about &lt;a href="https://medium.com/lemon-markets/understanding-the-lemon-markets-market-data-api-b50084ea0982" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We are looking forward to seeing what you are building with us. Make sure to sign up on &lt;a href="https://www.lemon.markets/?utm_source=medium&amp;amp;utm_medium=medium&amp;amp;utm_campaign=understanding-the-trading-api" rel="noopener noreferrer"&gt;lemon.markets&lt;/a&gt; and build your own brokerage experience at the stock market 🍋&lt;/p&gt;

</description>
      <category>api</category>
      <category>trading</category>
      <category>algotrading</category>
      <category>programming</category>
    </item>
    <item>
      <title>10+ online resources for high-quality stock market news</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Tue, 21 Dec 2021 01:13:38 +0000</pubDate>
      <link>https://forem.com/lemon-markets/10-online-resources-for-high-quality-stock-market-news-41ca</link>
      <guid>https://forem.com/lemon-markets/10-online-resources-for-high-quality-stock-market-news-41ca</guid>
      <description>&lt;p&gt;When &lt;strong&gt;trading stocks&lt;/strong&gt;, you want to make sure that you are well-informed so you stay &lt;strong&gt;ahead of the curve&lt;/strong&gt; with your investments. Therefore, I want to introduce you to a number of &lt;strong&gt;online resources&lt;/strong&gt; that can help you make &lt;strong&gt;better investment decisions&lt;/strong&gt; by providing you with &lt;strong&gt;high-quality news&lt;/strong&gt; about developments on the &lt;strong&gt;stock market&lt;/strong&gt;. I am part of &lt;a href="https://lemon.markets"&gt;lemon.markets&lt;/a&gt; 🍋, an early stage startup from &lt;strong&gt;Berlin, Germany&lt;/strong&gt; that is working on building a &lt;strong&gt;trading API&lt;/strong&gt; so everyone can create their &lt;strong&gt;own brokerage experience at the stock market&lt;/strong&gt;. Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Being informed is 🔑
&lt;/h2&gt;

&lt;p&gt;While this may be true for a lot of areas in life, it is especially important for making investment-decisions. You don’t want to be the guy/gal that buys stocks based on vague assumptions or even is purely uninformed. Instead, you want to do thorough research and then make decisions based on the results of that research.&lt;/p&gt;

&lt;p&gt;While there are a lot of ways to achieve a good basis for decision making, in this article we want to focus on online resources that provide you with information about trends and developments in the stock market. This list is nowhere near complete, as there are (tens of?) thousands of available stock market news websites/podcasts/YouTube channels/newsletters. But we still think that they may be a good starting point if you are just starting out in the investment world (and, of course also, when you are already a bit more experienced, more knowledge never hurt anyone 💁‍♂️).&lt;/p&gt;

&lt;h2&gt;
  
  
  News Websites
&lt;/h2&gt;

&lt;p&gt;Let’s start with a few websites that focus on providing you with a good overview of current developments in the market and up-to-date stock price data. Essentially, they all go into a similar direction so we don’t want to bore you with an endless list of providers that do (almost) the same thing. Instead, we are going to introduce three (in our humble opinion) cool options. Check them out and decide for yourself — maybe they are a great option to scrape data from and build an awesome trading strategy out of it?&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://finance.yahoo.com/topic/stock-market-news/"&gt;Yahoo Finance&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://finance.yahoo.com/"&gt;Yahoo Finance&lt;/a&gt; is one of the household names when it comes to access to stock market news (and data). The website comes with a few powerful tools that offer you a holistic “stock market experience”. For example, they have a news section with the most recent developments in the (investing) world, intuitive charts and key figures for important/trending stocks/indices or different Watchlists informing you about top performers Additionally, you have the option to customise your Yahoo experience by linking your brokerage account(s) to conveniently monitor your portfolio(s) in one place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q1wniJvf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yubzlwn8mt1h0cezcq1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q1wniJvf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yubzlwn8mt1h0cezcq1q.png" alt="Yahoo Finance homepage" width="880" height="673"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.marketwatch.com/"&gt;Market Watch&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.marketwatch.com/investing"&gt;Market Watch&lt;/a&gt; is another interesting alternative in the stock market news section. What we especially like about it is the investing subpage of the website where you can get the most recent headlines, conveniently subdivided by different industries. In fact, we liked it so much that we decided to use it for one of our projects, where we implemented a trading strategy that automatically makes investment decisions based on sentiment scores of news headlines — read the article &lt;a href="https://medium.com/lemon-markets/automated-news-following-trading-strategy-using-sentiment-analysis-5940e86e4333"&gt;here&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;The great thing about Market Watch is the simple UI that displays tickers and price movements along with their articles, which makes it very easy to follow the news presented on the website (or create an automated trading strategy out of it 😏).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rSbbFA5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr43ypm0e0vuqgrjki9k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rSbbFA5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr43ypm0e0vuqgrjki9k.png" alt="MarketWatch homepage" width="880" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.investopedia.com/"&gt;Investopedia&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you ever wanted to know more about a specific investment term, chances are high that you stumbled across &lt;a href="https://www.investopedia.com/"&gt;Investopedia&lt;/a&gt; at some point. The website can be described as the Wikipedia for investing, but the offer does not end there. Actually, Investopedia also offers a lot of additional services like current market news and a whole section on trending stocks/topics. You can also use a &lt;a href="https://www.investopedia.com/simulator/"&gt;simulator&lt;/a&gt; to “learn stock trading” with paper money. Investopedia is therefore a great starting point to get familiar with the most important terms/concepts and become more confident over time.&lt;/p&gt;




&lt;p&gt;As mentioned above, the list of stock market news website goes on and on, which is why we’ll make a hard limit (yup, it’s possible to make API jokes) here and head over to some alternative formats. However, feel free to also check out some of the other popular websites like &lt;a href="https://www.bloomberg.com/europe"&gt;Bloomberg Europe&lt;/a&gt;, &lt;a href="https://www.ft.com/"&gt;Financial Times&lt;/a&gt;, &lt;a href="https://seekingalpha.com/"&gt;Seeking Alpha&lt;/a&gt;, &lt;a href="https://www.benzinga.com/"&gt;Benzinga&lt;/a&gt; or &lt;a href="https://www.google.com/finance/"&gt;Google Finance&lt;/a&gt; to find the one that suits you best 🙂&lt;/p&gt;

&lt;h2&gt;
  
  
  Some cool providers that go beyond offering news
&lt;/h2&gt;

&lt;p&gt;While news are great, you sometimes might be looking for something else that allows you to address a different need. Don’t worry, we’ve got you covered.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://stocknewsapi.com/"&gt;Stock News API&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;We don’t think there ever was a more literal company name — and what you see is what you get. &lt;a href="https://stocknewsapi.com/"&gt;The Stock News API&lt;/a&gt; offers a very simple interface that allows you to extract news on different stocks/equities via their tickers. You can specify your requests by focusing on different topics, extracting video news or determining a corresponding sentiment score. The API is sleek and elegant and allows you to easily integrate stock market news into your trading projects. And who knows, maybe you even have an idea for combining the Stock News API with the &lt;a href="https://www.lemon.markets"&gt;lemon.markets API&lt;/a&gt;? 😏&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.finimize.com/"&gt;Finimize&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.finimize.com/"&gt;Finimize&lt;/a&gt; has been in the news in recent weeks because of its acquisition through the Scottish investment company abrdn. Finimize grew rapidly over the last few years and now has ~1 million subscribers to its newsletter. However, what may be even more interesting is the Finimize community that actively discusses all things investing and regularly meets up for specific events. Along with a sleek mobile app that conveniently displays current news in written or audio form (depending on what you prefer), Finimize is the go-to place for many amateur and professional investors. Maybe it’s also exactly the right place for you?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6FunP0WW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4j1cjlaouzc76mgvn50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6FunP0WW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4j1cjlaouzc76mgvn50.png" alt="Finimize homepage" width="880" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Newsletters to stay up-to-date via your inbox
&lt;/h2&gt;

&lt;p&gt;For some of you, it may be too much of a time effort to go looking for relevant information all by yourself. It can be hard to distinguish between news that are actually meaningful and such that are basically not worth talking about. A solution might be to sign up for a newsletter that conveniently sends relevant information directly to your inbox. Luckily, there a number of great options out there that make sure that you are always up-to-date.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://mailchi.mp/sifted/newsletter-fintech"&gt;Sifted Newsletter&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sifted.eu/"&gt;Sifted&lt;/a&gt; is one of the most important names in the European start-up scene. The media site that is backed by the Financial Times offers valuable insights on all things happening within the (European) entrepreneurial landscape. While their focus is on breaking news on innovative start-up companies, one of their focus areas is FinTech, with important stories and reports on developments being published regularly. Thus, it comes with no surprise that Sifted also offers a convenient &lt;a href="https://mailchi.mp/sifted/newsletter-fintech"&gt;newsletter&lt;/a&gt; that informs you about the FinTech scene once a week. Even though this is not stock news per se, it can still be a great tool to stay up-to-date with all things FinTech and spot future trends that will help you make better investment decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://snacks.robinhood.com/"&gt;Robinhood Snacks&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Say what you will about Robinhood, but they brought investing at the stock market to the masses with their easy-to-use and modern mobile application. Although the public opinion about the company has massively decreased in the course of the r/wallstreetbets affair (if you need a reminder, read &lt;a href="https://www.nytimes.com/2021/01/30/business/robinhood-wall-street-gamestop.html"&gt;here&lt;/a&gt;) and their different ways of making money has sparked criticism from different sides, it is still the #1 option for many (American) people. Besides their main product, the mobile app, Robinhood also offers a number of additional services. One of them is &lt;a href="https://snacks.robinhood.com/"&gt;Robinhood Snacks&lt;/a&gt;, a daily newsletter that, if we believe Robinhood, takes only 3 minutes to read. Sounds like a minimum effort for staying ahead of the curve, doesn’t it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D3oWiPO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v71tf4nj7q3w8bw0em1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D3oWiPO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v71tf4nj7q3w8bw0em1w.png" alt="Robinhood Snacks webpage" width="880" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Podcasts
&lt;/h2&gt;

&lt;p&gt;It seems almost illegal to create a list of online resources without including a number of podcasts. Therefore, we won’t even try. In recent years, podcasts have rapidly found their way into mass consumption. And for a reason: you can listen to them while you take the subway to work, wash your dishes at night or drink your morning coffee. We identified three examples which we think will bring value to you.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://ohneaktienwirdschwer.podigee.io/"&gt;Ohne Aktien wird schwer&lt;/a&gt; from &lt;a href="https://omr.com/de/"&gt;OMR&lt;/a&gt; and &lt;a href="https://traderepublic.com/de-de"&gt;TradeRepublic&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is a podcast for the German-speaking users. OMR, a leading platform for online marketing hosts a daily (well, Mon-Fri) podcast concerned with delivering up-to-date stock news. The podcast is supported by Trade Republic, a neo-broker from Berlin that recently closed a large financing round valuating the company at around $5 billion dollars. The ~10 minute long episodes give you a condensed overview each morning, which is why it is a perfect way to start your day.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.bloomberg.com/oddlots"&gt;Odd Lots&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Odd Lots, the in-house podcast by media company Bloomberg, is run by Joe Weisenthal, a news director covering all topics concerned with the stock market and Tracy Alloway, an executive editor for Bloomberg Markets who, prior to her work at Bloomberg, used to work as a financial correspondent for the Financial Times. The podcast, which is released twice a week, covers all financial topics and newest developments at the stock market.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://link.investopedia.com/join/53o/podcast-alert"&gt;The Investopedia Express&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;There is a reason why Investopedia makes our list twice. While the website itself already offers great value the Investopedia service is extended by a great podcast: &lt;a href="https://link.investopedia.com/join/53o/podcast-alert"&gt;The Investopedia Express&lt;/a&gt;. Hosted by Caleb Silver, editor-in-chief of Investopedia, sheds a weekly light on all important stories in finance and global economics. A great thing about this podcast are the frequent guests, with which Silver sits down to analyse developments or share insights. Highly recommended.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This concludes our list of online resources for high-quality stock market news. We hope you could find an option that suits your needs. In the end, there are different preferences regarding consumption of content, which is why it is important (and great) that there are so many different alternatives out there.&lt;/p&gt;

&lt;p&gt;Do you think there is something missing on our list? Let us know in the comments. Otherwise we are looking forward to welcoming you to &lt;a href="https://lemon.markets"&gt;lemon.markets&lt;/a&gt;, where you can put all your newly-gained knowledge into action and create your own brokerage experience at the stock market. We are really excited to see what you are building with us.&lt;/p&gt;

&lt;p&gt;See you there 🍋&lt;/p&gt;

</description>
      <category>podcast</category>
      <category>newsletter</category>
      <category>api</category>
      <category>stocks</category>
    </item>
    <item>
      <title>Automated news-following trading strategy using sentiment analysis</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Mon, 22 Nov 2021 13:16:57 +0000</pubDate>
      <link>https://forem.com/lemon-markets/automated-news-following-trading-strategy-using-sentiment-analysis-3ejo</link>
      <guid>https://forem.com/lemon-markets/automated-news-following-trading-strategy-using-sentiment-analysis-3ejo</guid>
      <description>&lt;p&gt;In this project we’ll build a sentiment analysis strategy that autonomously trades based on news headlines. We show you how to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;scrape headlines from a financial website using the Python requests library and BeautifulSoup,&lt;/li&gt;
&lt;li&gt;determine sentiment using VADER,&lt;/li&gt;
&lt;li&gt;arrive at trade decisions and&lt;/li&gt;
&lt;li&gt;place trades using the lemon.markets trading API. 🍋&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’re excited to show you how lemon.markets is the perfect tool for a project like this.&lt;/p&gt;




&lt;p&gt;If you want to get started developing straight away, you can check out our GitHub repository for this project &lt;a href="https://github.com/lemon-markets/content-financial-news-trader"&gt;here&lt;/a&gt;. Otherwise, keep reading to learn more about the strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Collecting your data 📊
&lt;/h2&gt;

&lt;p&gt;For this project, our goal is to place trade automatically based on the news. The first step is to decide how we want to gather our data, and especially from which source. We went for &lt;a href="https://www.marketwatch.com/investing"&gt;MarketWatch&lt;/a&gt; because the data is presented in an easily digestible format — for each headline, we are given its date and the ticker(s) corresponding to the headline, see the example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nQ_DZ2Ib--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xllrn1wnoode38fl0bmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nQ_DZ2Ib--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xllrn1wnoode38fl0bmp.png" alt="MarketWatch screenshot" width="625" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To collect these headlines, we use a simple GET request against the desired URL. Using the requests package, this looks as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://marketwatch.com/investing/technology"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to parse this data, we use &lt;a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/"&gt;BeautifulSoup&lt;/a&gt;, which is a Python package that can extract data from HTML documents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"html.parser"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;article_contents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"div"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;class_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"article__content"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;article_contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;headline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;class_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;ticker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;article&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"span"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;class_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ticker__symbol"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;headline_ticker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;headline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ticker&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;headlines&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;headline_ticker&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"headline"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"US_ticker"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;headlines_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;headlines&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind, this code won’t work for just any website, see &lt;a href="https://realpython.com/beautiful-soup-web-scraper-python/"&gt;this article&lt;/a&gt; for help with web scraping. You’ll notice that we access the article content in something called “div” and “article__content”. You’ll need to adjust this on a website-by-website basis, and this requires some inspection of the page you are on. In Chrome, you can do this by right-clicking on any website and selecting ‘Inspect’ (if you use another browser, use &lt;a href="https://www.alphr.com/how-to-use-inspect-element/"&gt;these steps&lt;/a&gt; instead). You’ll be met with a jumble of HTML. The easiest way to figure out where the headlines are ‘hiding’, is to Ctrl-F (or Command-F on iOS) a particular headline. You can also click the ‘Select an element in the page to inspect it’ button on the top-left of the Developer console to pinpoint where to find your desired data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uodsr4RN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agltbaq4t4vmtz7xpli1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uodsr4RN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/agltbaq4t4vmtz7xpli1.png" alt="Chrome devtools" width="700" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you’ve found the tags corresponding to the right element(s), you can paste the names into the code snippet above to retrieve its contents. We suggest frequently printing your output to determine whether you are collecting the desired information and whether it needs to be pre-processed. For example, in line 8, we remove the whitespace surrounding the headline to clean up our data. When you’re happy with your output, you can collect all relevant information in a Pandas DataFrame.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-processing your data 👩‍🏭
&lt;/h2&gt;

&lt;p&gt;At this stage, it’s likely your data needs some (additional) pre-processing before it’s ready for sentiment analysis and trading.&lt;/p&gt;

&lt;p&gt;In the GitHub repository, you’ll notice that we removed any headlines without tickers and headlines with tickers that we know are not tradable on lemon.markets (to make the dataset smaller). Additionally, to trade on lemon.markets, we need to obtain the instrument’s ISIN. Because we trade on a German exchange, querying for a US ticker will not (always) result in the correct instrument. Therefore, to ensure that there are no compatibility issues, we suggest mapping a ticker to its ISIN before trading. We’ve published an &lt;a href="https://medium.com/lemon-markets/mapping-a-ticker-symbol-to-isin-using-openfigi-lemon-markets-9c60a8892ee5"&gt;article&lt;/a&gt; that’ll help you do just that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performing the sentiment analysis 😃😢
&lt;/h2&gt;

&lt;p&gt;Once we’ve collected our headlines and tickers (or ISINs), we need to be able to decide whether the headlines report positive or negative news. This is where our sentiment analysis tool, VADER, comes in. It’s a model for lexical scoring based on polarity (positive/negative) and intensity of emotion. The compound score indicates whether a text is positive (&amp;gt;0), neutral (0), or negative (&amp;lt;0). In the above headlines, it can determine that ‘“Squid Game” is worth nearly $900 million to Netflix’ has a somewhat positive sentiment as the word ‘worth’ is likely part of the positive sentiment lexicon. If you’d like to read more about how VADER works, check out &lt;a href="https://medium.com/analytics-vidhya/simplifying-social-media-sentiment-analysis-using-vader-in-python-f9e6ec6fc52f"&gt;this article&lt;/a&gt;. There’s also alternatives out there, like &lt;a href="https://textblob.readthedocs.io/en/dev/"&gt;TextBlob&lt;/a&gt; or &lt;a href="https://github.com/flairNLP/flair"&gt;Flair&lt;/a&gt;. You might want to try out all three to determine which one works best on your dataset.&lt;/p&gt;

&lt;p&gt;For our use-case (determining sentiment scores of online newspaper headlines), the implementation is really simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;nltk.sentiment.vader&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SentimentIntensityAnalyzer&lt;/span&gt;

&lt;span class="n"&gt;vader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SentimentIntensityAnalyzer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;headline&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;headlines_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt;&lt;span class="s"&gt;"headline"&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;polarity_scores&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;headline&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"compound"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;headlines_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt;&lt;span class="s"&gt;"score"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we have more than one headline (and scores) for a particular ticker, we have to aggregate them into a single score:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headlines_df = headlines_df.groupby("ticker").mean()
headlines_df.reset_index(level=0, inplace=True)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ve chosen to combine scores by taking the simple average, but there are several measures that you might opt to use. For example, a &lt;a href="https://www.investopedia.com/terms/w/weightedaverage.asp"&gt;time-weighted average&lt;/a&gt; to penalise older deadlines as they probably are less representative of current (or future) market movements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Placing your trades 📈
&lt;/h2&gt;

&lt;p&gt;Once you’ve obtained the compound scores for the tickers, it’s time to place trades. However, you first need to decide on a trading strategy — what kind of score justifies a buy order? What about a sell order? And how much are you trading? There are several components to keep in mind here, such as your total balance, your current portfolio, the ‘trust’ you have in your strategy and others.&lt;/p&gt;

&lt;p&gt;Our base project works with a very simple trade rule: buy any instrument with a score above 0.5 and sell any instrument with a score below -0.5 (see if you can come up with something a bit more complex 😉):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;buy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="n"&gt;sell&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;headlines_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterrows&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isin'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s"&gt;'No ISIN found'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;buy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isin'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'score'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isin'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s"&gt;'No ISIN found'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;sell&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isin'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can then feed this list of ISINs to the lemon.markets API (if you’re not signed up yet, do that &lt;a href="https://lemon.markets/waitlist?utm_source=medium&amp;amp;utm_medium=social&amp;amp;utm_campaign=blog-post-sentiment-analysis"&gt;here&lt;/a&gt;) to place and activate our trades:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# place buy orders
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;isin&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;buy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;side&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'buy'&lt;/span&gt;
    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p0d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"side"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;side&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"venue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"XMUN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="s"&gt;"space_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SPACE&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# place sell orders
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;isin&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sell&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;side&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;'sell'&lt;/span&gt;
    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"p0d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"side"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;side&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"quantity"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s"&gt;"venue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"XMUN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
              &lt;span class="s"&gt;"space_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SPACE&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# activate orders
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;order_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'results'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"https://paper-trading.lemon.markets/v1/orders/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/activate/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Bearer &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;'Activated &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"results"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"isin"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For demonstration purposes, our trades are all of size 1, but depending on your capital, you might want to increase this parameter (or even make it dynamic depending on the sentiment score). Besides this, there are lots of other ways you can make this project even more extensive!&lt;/p&gt;

&lt;h2&gt;
  
  
  Further extensions 🤓
&lt;/h2&gt;

&lt;p&gt;This project is only a start to your own sentiment trading strategy. You can make your trade decisions more robust by collecting news from several sources. Or you can conduct more extensive sentiment analysis by, for example, applying VADER on the whole article rather than just the headline (#clickbait 🎣). Perhaps you want to use a different sentiment analysis tool, like TextBlob. Or maybe you even want to create your own sentiment score library based on investment-specific jargon.&lt;/p&gt;

&lt;p&gt;We suggest you begin by collecting data from a news source you trust and tweaking the trading decision rule. Let your imagination go wild!&lt;/p&gt;




&lt;p&gt;You’re now set up to use BeautifulSoup, VADER and lemon.markets in your sentiment analysis project. See our &lt;a href="https://github.com/lemon-markets/content-financial-news-trader"&gt;GitHub repository&lt;/a&gt; for the entire script. And, if you come up with an interesting extension, feel free to make a PR! We look forward to seeing your ideas.&lt;/p&gt;

&lt;p&gt;Joanne from &lt;a href="https://lemon.markets"&gt;lemon.markets&lt;/a&gt; 🍋&lt;/p&gt;

</description>
      <category>nlp</category>
      <category>python</category>
      <category>trading</category>
      <category>programming</category>
    </item>
    <item>
      <title>10 useful Python libraries &amp; packages for automated trading</title>
      <dc:creator>Joanne</dc:creator>
      <pubDate>Mon, 22 Nov 2021 13:07:36 +0000</pubDate>
      <link>https://forem.com/lemon-markets/10-useful-python-libraries-packages-for-automated-trading-4fbm</link>
      <guid>https://forem.com/lemon-markets/10-useful-python-libraries-packages-for-automated-trading-4fbm</guid>
      <description>&lt;p&gt;Hey! I’m Joanne, an intern at &lt;a href="https://lemon.markets" rel="noopener noreferrer"&gt;&lt;strong&gt;lemon.markets&lt;/strong&gt;&lt;/a&gt;, and I’m here to share some invaluable Python libraries &amp;amp; packages to use when you’re working with financial data and automated trading. At lemon.markets, we provide the infrastructure for developers to build their own &lt;strong&gt;brokerage experience at the stock market&lt;/strong&gt;. Whatever your product might look like, there’s usually one or more Python libraries that can do the legwork for you. So, instead of re-inventing the wheel, let’s have a look at which packages can facilitate your automated trading.&lt;/p&gt;

&lt;p&gt;The focus here is on Python, but many of the featured libraries have either wrappers that allow them to be used in other languages, or have comparable alternatives. If you have additional suggestions, feel free to leave a comment below. 💭&lt;/p&gt;




&lt;p&gt;I’ve split the trading process into three general steps: &lt;strong&gt;manipulating (raw) data&lt;/strong&gt;, &lt;strong&gt;performing technical analysis&lt;/strong&gt; and finally &lt;strong&gt;assessing your portfolio&lt;/strong&gt;. There’s probably 100+ steps that can be inserted into this process, but as a starting point, we think this is a solid place to begin. It covers the ‘before’, the ‘during’ and the ‘after’ when it comes to implementing your strategy. If you’re struggling to find more steps, perhaps consider: data collection, data visualisation, paper trading, backtesting, machine learning, portfolio management…must I go on?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj09q759yyej2adiw4gpq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj09q759yyej2adiw4gpq.png" alt="The (automated) trading process"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Manipulation
&lt;/h2&gt;

&lt;p&gt;We make the assumption here that you’re collecting data before writing your trading strategy. Live market data, historical data, trading sentiment: it all falls within this category. And before you can perform any kind of manipulation, you need data to do it on. Naturally, the lemon.markets market data API can be used to retrieve historical market data. We’ll also be providing real-time market data in the near future (stay tuned!). But you’re not restricted to only market data, you can also, for example, scrape headlines from financial news sites to perform sentiment analysis. Regardless of where you obtain your data, you’ll notice that often your source won’t present the data in exactly the format you need: cue data manipulation tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  🐼 Pandas
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import pandas as pd


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;No list of Python libraries for financial analysis (or really any kind of data-driven work) would be complete without the mention of &lt;a href="https://pandas.pydata.org/" rel="noopener noreferrer"&gt;Pandas&lt;/a&gt;. It’s a powerful data manipulation tool that works with data structures called Series (one-dimensional) and DataFrames (two-dimensional). It can be used to intelligently index data, merge and join different data sets and even perform computations. The documentation includes a &lt;a href="https://pandas.pydata.org/docs/user_guide/10min.html" rel="noopener noreferrer"&gt;10-minute guide to Pandas&lt;/a&gt; and DataCamp has a tutorial on using &lt;a href="https://www.datacamp.com/community/tutorials/finance-python-trading" rel="noopener noreferrer"&gt;Python for Finance&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔢 NumPy
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import numpy as np


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://numpy.org/doc/stable/index.html" rel="noopener noreferrer"&gt;NumPy&lt;/a&gt;, or the Numerical Python library, is the package when it comes to scientific computing in Python. Specifically, NumPy provides functions for linear algebra, Fourier transforms and random number generation. It’s widely used because it utilises vectorisation, which means it can turn a computation which might take 1000 cycles into one that takes 250 cycles. As developers, we’re always looking to reduce computational power where ever possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  👩‍🔬 SciPy
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import scipy as sp


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://docs.scipy.org/doc/scipy/reference/" rel="noopener noreferrer"&gt;SciPy&lt;/a&gt; is the scientific library that builds on NumPy — it includes modules for statistics, optimisation, integration, linear algebra and more. Similar to NumPy, but with more functionality (which comes at a price: slower computation speed). Check out the documentation to see if it meets your requirements!&lt;/p&gt;

&lt;h3&gt;
  
  
  📊 Matplotlib
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import matplotlib.pyplot as plt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;a href="https://matplotlib.org/" rel="noopener noreferrer"&gt;Matplotlib&lt;/a&gt; library can be used to create static, animated and interactive visualisations in Python. There are a million reasons why you might like to visualise data in financial analysis. For example, you might want to measure the performance of a single stock (or basket of stocks) against an index like the S&amp;amp;P500. Or, you might want to construct a simple histogram of daily stock returns to determine (visually) whether they follow a normal distribution. Of course, this would need to be backed up by a statistical test, which can be done with the statsmodels library (coming up soon).&lt;/p&gt;




&lt;p&gt;You’ll notice that the above four libraries are often used simultaneously in projects, and likely, in your use-case it’ll be the same situation. They integrate seamlessly. Many additional niche packages are built on top of these four packages, for example: &lt;a href="https://github.com/GriffinAustin/pynance" rel="noopener noreferrer"&gt;PyNance&lt;/a&gt;. There’s lots of resources available regarding these libraries: to get started, here’s an &lt;a href="https://analyzingalpha.com/python-for-finance" rel="noopener noreferrer"&gt;introduction to NumPy and Pandas&lt;/a&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 python
import requests
import pandas as pd
import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt


def get_ohlc():
    response = requests.get(
        'https://data.lemon.markets/v1/ohlc/d1/?isin=US0378331005 \
               &amp;amp;from=2021-06-25T00:00:00&amp;amp;to=2021-11-14T00:00:00',
        headers={"Authorization": "Bearer YOUR-API-KEY"})

    results = response.json()['results']
    return results


def calculate_returns():
    df = pd.DataFrame(get_ohlc())
    # calculate returns based on closing price
    df['r'] = df['c'].pct_change().fillna(method='bfill')
    df.tail()
    return df


def plot_returns():
    returns = calculate_returns()['r']

    # plot returns
    plt.hist(returns, bins=25, density=True, alpha=0.6, color='darkorange')

    # plot normal distribution fitted to returns
    mu, std = norm.fit(returns)
    xmin, xmax = plt.xlim()
    x = np.linspace(xmin, xmax, 100)
    p = norm.pdf(x, mu, std)
    plt.plot(x, p, 'k', linewidth=2)
    plt.xlabel('Daily Tesla Returns')
    plt.ylabel('Probability Density Function')

    plt.show()


plot_returns()


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This script will return the following histogram:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq3t25ij814lfbjv9830.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnq3t25ij814lfbjv9830.png" alt="Daily Tesla Returns"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Obviously, we do not have enough data points to conclude whether Tesla daily returns follow a normal distribution. We hope that this little example shows you what can be done with these data manipulation packages and our OHLC endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Analysis
&lt;/h2&gt;

&lt;p&gt;Your strategy may or may not employ technical analysis. If you’re somehow using historical price data to predict future price movement, then this falls under technical analysis. If you’re not, don’t worry, it’s not necessary in order to implement an automated trading strategy (but might be helpful nonetheless, so feel free to dive in).&lt;/p&gt;

&lt;h3&gt;
  
  
  📈 TA-Lib
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import talib as ta


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://mrjbq7.github.io/ta-lib/" rel="noopener noreferrer"&gt;TA-Lib&lt;/a&gt;, or Technical Analysis Library, can be used to perform technical analysis on financial data by calculating well-known technical indicators, such the Weighted Moving Average (WMA) or Relative Strength Index (RSI). It can also recognise candlestick patterns, such as the inverted hammer or homing pigeon, to name a few. These indicators might serve as buy or sell signals for your trading strategy.&lt;/p&gt;

&lt;h3&gt;
  
  
  📉 Statsmodels
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import statsmodels.api as sm


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Python already includes a built-in statistics module, but the &lt;a href="https://www.statsmodels.org/stable/stats.html" rel="noopener noreferrer"&gt;statsmodels&lt;/a&gt; package can be used for more in-depth statistical analysis. Say you want to construct an ARIMA model for historical price data in order to predict price movement in the future, then this library would be the tool to use. Or, your use-case might be more simple, such as conducting a Jarque-Bera test for normality of residuals after a regression.&lt;/p&gt;

&lt;h3&gt;
  
  
  🙋 PyStan
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import stan


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Bayesian inference is used in financial modelling to assess return predictability and strategy risk (among other things). &lt;a href="https://github.com/stan-dev/pystan" rel="noopener noreferrer"&gt;PyStan&lt;/a&gt; is the Python-adapted package to perform Bayesian inference. Note that you need to use a domain specific language based on C++ (called Stan), which makes this package a bit more difficult to use. However, it is very powerful in that it allows you to perform high-level statistical modelling, analysis and prediction.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➗ f.fn()
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import ffn


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://pmorissette.github.io/ffn/" rel="noopener noreferrer"&gt;ffn&lt;/a&gt; is a library that extends Pandas, NumPy and SciPy and contains functions often used within the quantitative finance framework. For example, you can use it to calculate the risk parity weights given a DataFrame (🐼) of returns. If you’re not familiar with risk parity, it’s an investment management technique that determines how to allocate risk within a portfolio. (Have we mentioned that reading the documentation of financial-related libraries is a great way to get familiarised with new metrics?)&lt;/p&gt;




&lt;p&gt;The above four libraries can be used to determine when, what and how much to buy or sell. Once these decisions are made, the lemon.markets trading API can be used to place your orders on the stock market. An order can be placed as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 python
import requests
import json

def place_order(isin: str, side: str, quantity: int):
    if trading_signal:
        request = requests.post("https://paper-trading.lemon.markets/v1/orders/",
                                data=json.dumps({
                                    "isin": isin,
                                    "expires_at": "p7d",
                                    "side": side,
                                    "quantity": quantity,
                                    "space_id": YOUR-SPACE-ID,
                                    "venue": "XMUN"}),
                                headers={"Authorization": "BEARER YOUR-API-KEY"})
        print("Your trade was placed")
    else:
        print("Your trade was not placed")

place_order("US0378331005", "buy", 1)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The boolean &lt;code&gt;trading_signal&lt;/code&gt; indicates whether the trade should be placed or not (this is where the aforementioned libraries come in handy). However, in this script we have not defined it yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Portfolio Assessment
&lt;/h2&gt;

&lt;p&gt;Once your strategy is finished and implemented, it’s important to measure its performance, not only by returns, but also by calculating e.g. the risk associated with it. Portfolio analysis is not a one-and-done event: a good investor assesses their portfolio (or automates the process) regularly and implements necessary changes, such as a rebalancing or purchasing additional stocks to diversify appropriately. Note: your lemon.markets portfolio can be accessed via the Portfolio endpoint:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 python
import requests

request = requests.get("https://paper-trading.lemon.markets/v1/portfolio/",
                       headers={"Authorization": "BEARER YOUR-API-KEY"})

print(request.json())


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Which would return each instrument in your portfolio in the following fashion:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

ISIN : {YOUR-SPACE-ID: {
   'buy_orders_total': '',
   'buy_price_avg': '',
   'buy_price_avg_historical': '',
   'buy_price_max': '',
   'buy_price_min': '',
   'buy_quantity': ''
   'orders_total': '',
   'quantity': '',
   'sell_orders_total': '',
   'sell_price_avg_historical': '',
   'sell_price_max': '',
   'sell_price_min': '',
   'sell_quantity': ''}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  ✋ Empyrical
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import empyrical as em


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/quantopian/empyrical" rel="noopener noreferrer"&gt;Empyrical&lt;/a&gt; can be used to calculate well-known performance and risk statistics, for example the Sharpe ratio, alpha and beta. These metrics might show how the portfolio performs in relation to the market and indicate whether structural changes should be made. It’s an open-source project initiated by the now-defunct Quantopian, however the GitHub repository remains somewhat active (fingers crossed it stays that way 🙏🏼).&lt;/p&gt;

&lt;h3&gt;
  
  
  💼 PyFolio
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import pyfolio as pf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/quantopian/pyfolio" rel="noopener noreferrer"&gt;PyFolio&lt;/a&gt; is quite similar to Empyrical in that it can create an image that reflects performance and risk analysis. It does this through a so-called tear sheet, which includes metrics such as the stability, maximum drawdown and kurtosis of your portfolio’s returns.&lt;/p&gt;




&lt;p&gt;These ten Python libraries and packages should provide a good starting point for your automated trading journey. Integration with the lemon.markets API is possible at every step: market data can be retrieved for data manipulation, orders can be placed according to technical indicators and the portfolio can be accessed to do risk and performance assessments. We strive to make the API as transparent as possible, to give you, the developer, full control over your brokerage experience.&lt;/p&gt;

&lt;p&gt;If you’re not already signed-up to lemon.markets, join our waitlist &lt;a href="https://www.lemon.markets/waitlist?utm_source=medium&amp;amp;utm_medium=social&amp;amp;utm_campaign=blog-post-10-useful-python-libraries" rel="noopener noreferrer"&gt;here&lt;/a&gt;, we’d love to have you! Connect with us by leaving behind a comment, &lt;a href="//mailto:lemon.markets@support"&gt;sending us an email&lt;/a&gt; and joining our vibrant &lt;a href="https://app.slack.com/client/T01AQGVEWM9" rel="noopener noreferrer"&gt;Slack community&lt;/a&gt;. You’re bound to pick up some additional tools and inspiration along the way.&lt;/p&gt;

&lt;p&gt;See you soon,&lt;/p&gt;

&lt;p&gt;Joanne 🍋&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>trading</category>
      <category>resources</category>
    </item>
  </channel>
</rss>
