<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thomson Mathews on Medium]]></title>
        <description><![CDATA[Stories by Thomson Mathews on Medium]]></description>
        <link>https://medium.com/@thomsonmathews2001?source=rss-9e7cdca5765f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YSzZVXSOy89U1LB7.jpg</url>
            <title>Stories by Thomson Mathews on Medium</title>
            <link>https://medium.com/@thomsonmathews2001?source=rss-9e7cdca5765f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:25:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thomsonmathews2001/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automated Futures Crypto Trading on Bitunix Exchange, written in Python]]></title>
            <link>https://medium.com/@thomsonmathews2001/automated-crypto-trading-on-bitunix-exchange-written-in-python-6a0a10c6a84c?source=rss-9e7cdca5765f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a0a10c6a84c</guid>
            <dc:creator><![CDATA[Thomson Mathews]]></dc:creator>
            <pubDate>Mon, 10 Mar 2025 17:03:52 GMT</pubDate>
            <atom:updated>2025-03-20T15:01:12.018Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bitunix Futures Auto Trading Platform</h3><p>A real-time cryptocurrency trading platform built with FastAPI and WebSocket technology using Bitunix API and websockets for Futures. The platform provides automated trading capabilities, real-time market data visualization, and portfolio management features.</p><h3>Features</h3><ul><li>Real-time private account/new postion/new order data streaming via WebSocket</li><li>Real-time public depth/kline for bid, ask and last streaming via WebSocket or thru api calls, configurable in the config file</li><li>Automated trading strategies based on technical indicators</li><li>Portfolio management and position tracking</li><li>User interface is not a requirement for automated trading, all parmaeters can be configured in the config file</li><li>login page</li><li>main page:</li><li>Interactive web interface with real-time updates, allows manual trading</li><li>Real-time portfolio value</li><li>Open positions, with signals and strength</li><li>Active orders</li><li>selected signals with strength</li><li>all signals with strength</li><li>position history</li><li>clicking on the ticker symbol will open the chart page</li><li>maintians a list of notification which can be access by clicking on the notification</li><li>Candlestick charts for all timeframes (1m, 5m, 15m, 1h, 1d) on a single page with all indicators</li><li>Chart is activated when you click on the ticker symbol</li><li>Technical analysis including:</li><li>Moving Averages</li><li>MACD</li><li>Bollinger Bands</li><li>RSI</li><li>Brearish or bullish candle based on the close near high or low of the current candle</li><li>strength based on consecutive colored candles count</li><li>control study using the environment variables</li><li>Secure authentication system</li><li>Configurable trading parameters</li><li>Real-time notifications</li><li>Logging system with colored output</li></ul><h3>Configuration</h3><p>The platform can be configured through the config.py file or environment variables. Key configuration parameters include:</p><ul><li>API Keys</li><li>api_key: Bitunix API key</li><li>secret_key: Bitunix secret key</li><li>SECRET: JWT secret for authentication, some string like &quot;7c4c22ef6ad145f922c72f5a18047b6bf6eff983381c975c&quot;</li><li>password: Password for the web interface</li><li>Trading Parameters:</li><li>leverage: Trading leverage (1-100)</li><li>threshold: Ticker selection based close near high or low of the day</li><li>min_volume: Ticker selection based on Minimum trading volume</li><li>order_amount_percentage: Order size as percentage of portfolio</li><li>max_auto_trades: Maximum number of automated trades</li><li>profit_amount: Target profit amount</li><li>loss_amount: Maximum loss amount</li><li>option_moving_average: Moving average period (1h, 1d, 15m, 5m, 1m)</li><li>AutoTrade checkbox: set the trading parameters and initate the auto trade process</li><li>bars: Number of bars to use for study and charting</li><li>Technical Indicators Parameters:</li><li>ma_fast: Fast moving average period</li><li>ma_medium: Medium moving average period</li><li>ma_slow: Slow moving average period</li><li>rsi_fast: Fast RSI period</li><li>rsi_slow: Slow RSI period</li><li>bbm_period: Bollinger Band middle period</li><li>bbm_std: Bollinger Band standard deviation</li><li>macd_period: MACD period</li><li>macd_short: MACD short period</li><li>macd_long: MACD long period</li><li>Study Parameters:</li><li>ema_study: Enable EMA study</li><li>macd_study: Enable MACD study</li><li>bbm_study: Enable Bollinger Band study</li><li>rsi_study: Enable RSI study</li><li>candle_trend_study: Enable candle trend study</li><li>Check on Opening a Position:</li><li>ema_check_on_open: Check EMA on open</li><li>macd_check_on_open: Check MACD on open</li><li>bbm_check_on_open: Check Bollinger Band on open</li><li>rsi_check_on_open: Check RSI on open</li><li>candle_trend_check_on_open: Check candle trend on open</li><li>Check on Close a Position:</li><li>ema_check_on_close: Check EMA on close</li><li>macd_check_on_close: Check MACD on close</li><li>bbm_check_on_close: Check Bollinger Band on close</li><li>rsi_check_on_close: Check RSI on close</li><li>candle_trend_check_on_close: Check candle trend on close</li><li>intervals:</li><li>screen_refresh_interval: Screen refresh interval</li><li>signal_check_interval: Signal check interval</li><li>portfolio_api_interval: Portfolio API interval</li><li>pending_positions_api_interval: Pending positions API interval</li><li>pending_orders_api_interval: Pending orders API interval</li><li>trade_history_api_interval: Trade history API interval</li><li>position_history_api_interval: Position history API interval</li><li>ticker_data_api_interval: Ticker data API interval</li><li>public_websocket_restart_interval: Public WebSocket restart interval</li><li>Currently not using public websocket for depth and ticker data as the data is lagging or missing sometime</li><li>use_public_websocket=False</li><li>Logging Parameters:</li><li>verbose_logging=False</li></ul><h3>User Interface</h3><ul><li>Access the web interface:</li><li>Open your browser and navigate to http://localhost:8000 or <a href="http://your_server_ip:8000/">http://your_server_ip:8000</a></li><li>Log in with your credentials (currenly user is admin and password is your_password in env file)</li><li>Monitor your positions and trades:</li><li>Real-time portfolio value</li><li>Open positions</li><li>Active orders</li><li>Trading signals</li><li>Position history</li><li>Manual trading using buy, sell, add, reduce buttons</li><li>Autotrade using the AutoTrade checkbox</li><li>you can change</li><li>Moving Average period</li><li>Max auto trades</li><li>Take Profit amount</li><li>Accept Loss amount</li><li>You can control the study like Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle using the env file</li><li>You can control the trading strategy using the CalculateStudy function in TickerManager.py and AutoTradeProcess function in BitunixSignal.py</li><li>Changes are activated by unchecking and checking the AutoTrade checkbox</li></ul><h3>Auto Trading</h3><ul><li>Automated Trading Algorithm is customizable:</li><li>It allow you to select the moving average period (1h, 1d, 15m, 5m, 1m)</li><li>It allow to select how many auto trades you want to open at a time</li><li>CalculateStudy Function inside TickerManager.py (Interval class)</li><li>You can setup current_signal (BUY,SELL,HOLD) and signal_strength (numeric value) based on your strategy</li><li>current_signal can be setup based on Moving Average, MACD, Bollinger Band, RSI or close proximity to high or low of the candle</li><li>signal_strength can be setup based on number of consecutive green or red candles or any other strategy</li><li>AutoTradeProcess function inside BitunixSignal.py, you can setup your opening and closing trading strategy</li><li>User interface will list the stocks in the signal window with BUY or SELL signal based on the descending value of signal_strength</li><li>All study can be controlled thru environment variables</li><li>Auto trade process open the trade based on following conditions:</li><li>If the current candle is bullish and moving average is above the medium moving average and MACD_line &gt; Signal_line and RSI is above the long RSI and current close is above bollinger band middle line it will open long position</li><li>If the current candle is bearish and moving average is below the medium moving average and MACD_line &lt; Signal_line and RSI is below the long RSI and current close is belowe bollinger band middle line it will open short position</li><li>Auto trade process closes the trade based on following conditions:</li><li>If the current candle is bearish, it will close the trade</li><li>If the trade is in profit and greater than the profit_amount , it will close the trade</li><li>If the trade is in profit and greater than the profit_amount , it will close the trade</li><li>If the trade is in loss and greater than the loss_amount , it will close the trade</li><li>If the order is open for more than 1 minute, it will close the open orders</li><li>It will close long or short postions:</li><li>If the trade is long and the fast moving average is above the medium moving average, it will close the trade</li><li>If the trade is short and the fast moving average is below the medium moving average, it will close the trade</li><li>If the trade is long and the MACD_line &lt; Signal_line, it will close the trade</li><li>If the trade is short and the MACD_line &gt; Signal_line, it will close the trade</li><li>If the trade is long and the short RSI &lt; long RSI, it will close the trade</li><li>If the trade is short and the short RSI &gt; long RSI, it will close the trade</li><li>if the trade is long and current close is less bollinger band middle line , it will close the trade</li><li>if the trade is short and the current close is above bollinger band middle line , it will close the trade</li></ul><h3>Installation</h3><ul><li>This uses TA-LIb</li><li>sudo apt-get update</li><li>sudo apt-get install build-essential libssl-dev libffi-dev python3.9-dev</li><li>For windows install using precompiled wheel using</li><li>pip install <a href="https://github.com/cgohlke/talib-build/releases/download/v0.6.3/ta_lib-0.6.3-cp313-cp313-win_amd64.whl">https://github.com/cgohlke/talib-build/releases/download/v0.6.3/ta_lib-0.6.3-cp313-cp313-win_amd64.whl</a></li><li>For linux download</li><li>wget <a href="https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb">https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb</a></li><li>sudo dpkg -i ta-lib_0.6.4_amd64.deb</li><li>Change the Ver1.0 to the latest version in the script</li><li>bash -c “<br>apt-get install -y python3.9 python3.9-distutils python3-pip wget unzip dos2unix &amp;&amp;<br>ln -sf /usr/bin/python3.9 /usr/bin/python3 &amp;&amp;<br>python3 -m pip install — upgrade pip &amp;&amp;<br>mkdir bitunix &amp;&amp; cd bitunix &amp;&amp;<br>wget <a href="https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/Ver1.0.tar.gz">https://github.com/tcj2001/bitunix-automated-crypto-trading/archive/refs/tags/Ver1.0.tar.gz</a> -O bitunix.tar.gz &amp;&amp;<br>mkdir code &amp;&amp;<br>tar — strip-components=1 -xvzf bitunix.tar.gz -C code &amp;&amp;<br>cd code &amp;&amp;<br>pip3 install -r requirements.txt &amp;&amp;<br>cp sampleenv.txt .env”</li><li>The package will be installed in the bitunix/code directory</li><li>make sure to update the .env file with your keys</li><li>api_key=your_api_key</li><li>secret_key=your_secret_key</li><li>SECRET=your_jwt_secret</li><li>password=your_password host=0.0.0.0 (for server) or 127.0.0.1 (for local)</li><li>cd bitunix/code</li><li>python3 bitunix.py</li></ul><h3>License</h3><p><a href="https://opensource.org/licenses/MIT">https://opensource.org/licenses/MIT</a></p><h3>Support</h3><p><a href="/service/mailto:thomsonmathews@hotmail.com">thomsonmathews@hotmail.com</a></p><p>If you like this project buy me a lunch or coffee</p><ul><li>35ocu1V25Zw9tgXyrcWudUqpj8rHbT2CdE (bitcoin)</li><li>DEXXvZbTbxeaYCh3EMf7MsdptbAU2kujDc (dogecoin)</li></ul><p><strong>Code</strong></p><p><a href="https://github.com/tcj2001/bitunix-automated-crypto-trading">https://github.com/tcj2001/bitunix-automated-crypto-trading</a></p><p>If you like this project buy me a lunch or coffee</p><ul><li>35ocu1V25Zw9tgXyrcWudUqpj8rHbT2CdE (bitcoin)</li><li>DEXXvZbTbxeaYCh3EMf7MsdptbAU2kujDc (dogecoin)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a0a10c6a84c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Architecture Program Generator (.NET 8.0/ANGULAR)]]></title>
            <link>https://medium.com/@thomsonmathews2001/clean-architecture-program-generator-f4970e110aed?source=rss-9e7cdca5765f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4970e110aed</guid>
            <dc:creator><![CDATA[Thomson Mathews]]></dc:creator>
            <pubDate>Tue, 18 Jun 2024 14:59:55 GMT</pubDate>
            <atom:updated>2024-07-01T13:55:42.605Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a .Net8.0 Clean Architecture style code generator which will generate Domain project containing entities; Application project containing repository interfaces, service interfaces, service implementations; Persistence project containg ApplicationDbcontext, repository implementations; it will also generate controllers for each entity in the WebAPI or WEBMVC project.</p><p><strong>A working WEBAPI and WEBMVC project pointing a database with multiple tables can be generated and smoke tested under 4 minutes.</strong></p><p>Version 8.1.0 and above supports Generating <strong>a FrontEnd in Angular 18</strong> this make use of the WebAPI backend, all of these are generated with this program generator.</p><h3>Getting Started</h3><p>This is a NuGet package that should be installed as a template in dotnet cli.<br>You can browse this package using manage NuGet packages by searching for “Thomson Mathews” or “CleanArchitectureProgramGenerator”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2I0RnpCRkBvKfK7v.png" /></figure><p>This will install four template files in your project.<br><a href="https://www.nuget.org/packages/CleanArchitectureProgramGenerator/#clean-architecture-angular-generatortt">Clean Architecture Angular Generator.tt</a><br><a href="https://www.nuget.org/packages/CleanArchitectureProgramGenerator/#clean-architecture-database-access-generator.tt">Clean Architecture Database Access Generator.tt</a><br><a href="https://www.nuget.org/packages/CleanArchitectureProgramGenerator/#clean-architecture-webapi-generator.tt">Clean Architecture WebAPI Generator.tt</a><br><a href="https://www.nuget.org/packages/CleanArchitectureProgramGenerator/#clean-architecture-webmvc-generator.tt">Clean Architecture WebMVC Generator.tt</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*7yrlSxEwCeXNfgeI.png" /></figure><p>Once these template files are installed.</p><p>Run <strong>Clean Architecture Database Access Generator.tt</strong> template by right clicking on the template and select “Run Custom Tool”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*5BUFO7NOT6Z3R-e8.png" /></figure><p>This will generate the following projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/0*mb8L0JyP9djFIzHK.png" /></figure><p>Now define entities in the Domain Project entities folder using code first approach or database first approach and ApplicationDbContext in Persistence project context folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*7xeUounHCLJ-H1P6.png" /></figure><p>if more entities are added, just run all these three transformation again, that’s it.</p><p><strong>Run Clean Architecture Database Access Generator.tt again</strong> to generate all repositories, services for the each entity that was added in the previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*BJ408HTasdI5rKpvG1XK8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*ul_F2fP07nAyMYVrflhFTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*JFQpDNk9_qTGq72qtwFBPQ.png" /></figure><p><strong>Run Clean Architecture WebAPI Generator.tt</strong> to generate <strong>API</strong> controllers in WebAPI project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*784YNPPSAyL5GyRj4-ZyqA.png" /></figure><p><strong>Run Clean Architecture WebMVC Generator.tt</strong> to generate <strong>MVC</strong> controllers in WebMVC project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*Gm9ESZ0x6XHVyWSR3w3Lmg.png" /></figure><p><strong>Run Clean Architecture Angular Generator.tt</strong> to generate <strong>Angular 18</strong> frontend project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*rHdKH2sE05FdVSzbnJSTeA.png" /></figure><p>set WebAPI or WebMVC or AngularProject1 as a startup project to use it.</p><p><strong>Voila! a working WebAPI or WebMVC or AngularProject1 is ready for you</strong>.</p><p><strong>More details are in the ReadMe</strong> @ <a href="https://www.nuget.org/packages/CleanArchitectureProgramGenerator">https://www.nuget.org/packages/CleanArchitectureProgramGenerator</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4970e110aed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alpaca Dashboard (.NET 6.0 C#)]]></title>
            <link>https://medium.com/@thomsonmathews2001/alpaca-dashboard-net-6-0-c-426afb6dd69a?source=rss-9e7cdca5765f------2</link>
            <guid isPermaLink="false">https://medium.com/p/426afb6dd69a</guid>
            <dc:creator><![CDATA[Thomson Mathews]]></dc:creator>
            <pubDate>Wed, 06 Apr 2022 18:31:29 GMT</pubDate>
            <atom:updated>2022-04-06T18:31:29.769Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KypV7m2QwM_WoxBk" /></figure><p>This is Alpaca Dashboard which will allow you to manage your portfolio in Live and Paper Environment. It will list your open position, open orders, closed orders and watchlist of open positions, these list will show real time updates on the close price, position, market value, profit/loss, bid price and ask price for each assets. Account data like buying power will updated real-time. You will also have the ability to submit new order or close position etc.</p><p>You can build your own Scanner and Bots classes easily by implementing its interfaces. each implemented scanner will be automatically displayed in UI along with its input parameters.</p><p>Portfolio screen showing open position for the selected environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*efdK6TbXuUDfPgT5" /></figure><p>Open Order Screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MKtVu6XtJ1uVBQpn" /></figure><p>Context menu to add a Position symbol to any defined Bot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*If10PscXD5X7Gp08" /></figure><p>List of Closed Order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VY4Zt2YtH2vVVXNM" /></figure><p>Position Watchlist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S2QJj3-aLTGAS8ti" /></figure><p>Context menu to add a symbol to any defined Bot from watchlist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y2EvWL8VzLJl8J4k" /></figure><p>Scanners, this tab will list all the scanners classes implemented based on the IScanner interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Udciz4ij-njlhkIV" /></figure><p>Context menu to add a symbol to any defined Bot from scanner list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6lNQ5_XhGMcmRV8G" /></figure><p>Scanner class should implement this Interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/0*diLNfBNd5DDO7vVo" /></figure><p>Bots, this tab will list all the scanners classes implemented based on the IBots interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aPL2ejBQidl2rj59" /></figure><p>Option to start, end or delete a Bot for a selected sysmbol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3y-n85z_hoOPNCgS" /></figure><p>Bot classes should implement this interface</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*W0UDU2QZfBBvAltC" /></figure><p>Currently 3 scanners are implemented.</p><ol><li>ScannerCrypto is a simple scanner which list the Crypto Asset.</li><li>ScannerAboveVolume make use of Snapshot to filter asset between the given Close price range and above the given Volume.</li><li>ScannerAboveSMA make use of Snapshot to filter asset between the given Close price range and above the given Volume and uses OoplesFinance.StockIndicator to select stock above simple moving average, this scanner also have a logic to run scanner every given intervals.</li></ol><p>These scanner symbols are stored in the Alpaca Account as watchlist, so these scanner will get reloaded with last scanned list next time you start this dashboard.</p><p>Currently 4 Bots are implemented.</p><ol><li>MeanReversion:</li><li>TakeProfitLoss: places a bracket order when the close is above SMA to take profit or loss at the entered percentages.</li><li>Scalper: Places a market order when close is above SMA and sells the asset as soon as you make a certain profit amount.</li><li>DCA (Dollar Cost Averaging): This bot show the concept of implementing DCA to add position when the loss is more than a set percentage</li></ol><p>For every asset added in the dashboard, a Stock object is created which updates itself with Quote, Trades, Positions, and Orders<br>Bots make use of this Stock object to build its logic.</p><p>These Bots and Scanner as sample implementation, it’s up to you to write new one that make sense to you, the dashboard provide a frame work to handle position and orders and implement scanner or bots. You will need some knowlege of C# to write these Scanner or Bots.</p><p>API keys and SecretKey can provided directly in the appsetting.json<br>or store your key using dotnet user-secret as PaperKey:API_SECRET = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” PaperKey:API_KEY = xxxxxxxxxxxxxxxxxxxx LiveKey:API_SECRET = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” LiveKey:API_KEY = xxxxxxxxxxxxxxxxxxxx</p><p>A Log is created for the Dashboard in the Logs folder, also individual logs are created for each bots and asset combination.</p><p>All trades are recorded in a SQLite database for price analysis like profit/loss by Date/Bot/Symbol etc.</p><p>Setting for each Scanners are stored in the database, so next time you load the dashboard those setting will be restored.</p><p>Setting for each Bot at Asset level is also stored in the database, so next time you load the dashboard setting for each Bots at Asset level will be restored.</p><p>This Dashboard should also work for non-subscribed users by changing the subscribed setting to false in the appsetting.json file.</p><p>Provide your feedback to improve the functionality of Alpaca Dashboard, write new scanner and bots and add to project.</p><p>Check This project @ <a href="https://github.com/tcj2001/AlpacaDashboard-DotNet-6.0">https://github.com/tcj2001/AlpacaDashboard-DotNet-6.0</a></p><p>Thanks to cheatcountry who helped me optimize some of the code in this project, check his work of OoplesFinance.StockIndicators @ <a href="https://github.com/ooples/OoplesFinance.StockIndicators">https://github.com/ooples/OoplesFinance.StockIndicators</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=426afb6dd69a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Architecture Style Code Generator]]></title>
            <link>https://medium.com/@thomsonmathews2001/my-first-effort-to-create-a-clean-architecture-based-web-api-project-template-ca-webapi-net6-b4edfd3e9c4?source=rss-9e7cdca5765f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4edfd3e9c4</guid>
            <category><![CDATA[t4template]]></category>
            <category><![CDATA[dot-net-core]]></category>
            <category><![CDATA[webapi]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[project-template]]></category>
            <dc:creator><![CDATA[Thomson Mathews]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 19:28:32 GMT</pubDate>
            <atom:updated>2024-07-01T13:58:39.040Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>New version available for .net 8.0 and Angular 18 front end @ </strong><a href="https://medium.com/@thomsonmathews2001/clean-architecture-program-generator-f4970e110aed"><strong>https://medium.com/@thomsonmathews2001/clean-architecture-program-generator-f4970e110aed</strong></a></p><p>This is a .Net Core Clean Architecture style code generator which will generate Domain project containing entities; Application project containing repository interfaces, service interfaces, service implementations; Persistence project containg ApplicationDbcontext, repository implementations; it will also generate controllers for each entity in the WebAPI or WEBMVC project.</p><h3>Getting Started</h3><p>This is a NuGet package that should be installed as a template in dotnet cli.<br>You can browse this package using manage NuGet packages by searching for “Thomson Mathews” or “Clean_Architecture_Program_Generator_for_CSharp_and_NET6”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DT_IgQmwqx4SUw6Z" /></figure><p>This will install two template files in your project.<br>Clean Architecture Database Access Generator.tt<br>Clean Architecture WebAPI Generator.tt<br>Clean Architecture WebMVC Generator.tt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*jiEwTjqpGVL5xer8" /></figure><p>Once these template files are installed.</p><p>Run Clean Architecture Database Access Generator.tt template by right clicking on the template and select “Run Custom Tool”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*1pdx4eB7Ft-mLTAi" /></figure><p>This will generate the following projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/0*WxqNOed5u885HN-B" /></figure><p>Now define entities in the Domain Project entities folder using code first approach or database first approach and ApplicationDbContext in Persistence project context folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*hLH8lepp8Ak1SoVe" /></figure><p>Run Clean Architecture Database Access Generator.tt again to generate all repositories, services for the each entity.</p><p>Run Clean Architecture WebAPI Generator.tt to generate API controllers in WebAPI project.</p><p>Run Clean Architecture WebMVC Generator.tt to generate MVC controllers in WebMVC project.</p><p>set WebAPI or WebMVC as a startup project.</p><p>Voila! a working WebAPI or WebMVC is ready for you.</p><p>if more entities are added, just run all these three transformation again, that’s it.</p><h3>Clean Architecture Database Access Generator.tt</h3><p>This template will generate 4 projects:<br>Domain, Application, Persistence, Startup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/0*QRIQglpQsB1giUHT" /></figure><p>Domain Project:<br>Define all entities in Entities folder, either using code first approach or database approach, Exceptions folder defines some basic useful exceptions that can be used in global error handling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*z3D6BgCAy4wvTSeO" /></figure><p>Application Project<br>Defines Interface for ServiceManager, Services in the ServiceInterfaces folder, implementation of ServiceManager and Services in Services folder, interfaces for RepositoryManager, GenericRepository, Repositories and UnitOfWork in RepositoryInterface folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*SYIr-2ITyg0b95g8" /></figure><p>Persistence Project:<br>ApplicationDbContext should be defined or generated using Entity Framework in the context folder, Repositories folder contains GenericRepository, Repositories, RepositoryManager and UnitOfWork implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*XkcbC-RunP8YrmYH" /></figure><p>Startup Projects:<br>This is a console application that will create a Generic Host which will help in dependency injection, here ApplicationDbContext is added to the ServiceCollection, this project will help you to run Entity Framework commands to do entity migrations to a database or generate entities and ApplicationDbContext from existing database. It also has a appsettings.json file containing the connection string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/0*b4MBtLts17uKmkSF" /></figure><p>Startup project is only used to run Entity Framework commands with out a WebAPI project and is not required if WebAPI project is generated.</p><p><em>Once you add more entities, you can run this template again to generate repository interfaces for the new Entities in the Domain Project, repository implementation for the new Entities in Persistence Project and Services and its Service interfaces for the new Entities in the Application Project</em>.</p><h3>Clean Architecture WebAPI Generator.tt</h3><p>This template will open a dialog box, select “ASP.NET Core Web API” project template to generate a initial skelton of Web API project which will be modified by the “Clean Architecture WebAPI Generator template”</p><p>This template will generate open a dialog box, select ASP.NET Core WebAPI project and it will create a project named WebAPI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fxD5awsdvXdapwOL" /></figure><p>WebAPI Project:<br>This contains controllers and other required classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*9ZJFAP1estmAy6_q" /></figure><p>Controller Folder:<br>Contains generated controller for each entities defined in Domain project.</p><p>Extensions Folder:<br>Contains extension method to add BasicAuthMiddleware to the HTTP request pipeline.</p><p>MiddleWare Folder:<br>Contains implementation for BasicAuthMiddleware and ExceptionHandlingMiddleware.</p><p>Appsetting.json:<br>Contains configuration for Serilog logging, connection string and basic authentication details.</p><p>Appsetting Folder:<br>Contains classes structures to read from appsettings.json file.</p><p>Program.cs This connect all the wiring between the projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w3OaZT-EkiMJaQUe" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fOKzR03bRw9D4bZT" /></figure><p><em>Once you add more entities, you can run this template again to generate controllers for the new Entities in the WebAPI Project.</em></p><h3>Clean Architecture WebMVC Generator.tt</h3><p>This template will open a dialog box, select “ASP.NET Core Web app (Mode-View-Controller)” project template to generate a initial skelton of MVC project which will be modified by the “Clean Architecture WebMVC Generator template” it will create a project named WebAPI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZki-zD3xhfp2zj7" /></figure><p>WebAPI Project:<br>This contains controllers and other required classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*m_9x9kta4GjJFpvw" /></figure><p>Controller Folder:<br>Contains generated controller for each entities defined in Domain project.</p><p>Extensions Folder:<br>Contains extension method to add BasicAuthMiddleware to the HTTP request pipeline.</p><p>MiddleWare Folder:<br>Contains implementation for BasicAuthMiddleware and ExceptionHandlingMiddleware.</p><p>Appsetting.json:<br>Contains configuration for Serilog logging, connection string and basic authentication details.</p><p>Appsetting Folder:<br>Contains classes structures to read from appsettings.json file.</p><p>Program.cs This connect all the wiring between the projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dgy8YZmAuG9_xb0b" /></figure><p><em>Once you add more entities, you can run this template again to generate controllers for the new Entities in the WebAPI Project.</em></p><h3>T4Helper.ttinclude</h3><p>This file contains function used by the above T4Template files.</p><h3>Github Link</h3><p><a href="https://github.com/tcj2001/Clean_Architecture_Program_Generator_for_CSharp_and_NET6">https://github.com/tcj2001/Clean_Architecture_Program_Generator_for_CSharp_and_NET6</a></p><h3>Installing template from Nuget Package Manager</h3><p>From your package manager console.<br>dotnet new -i Clean_Architecture_Program_Generator_for_CSharp_and_NET6_Solution<br>This will add a new template in your dotnet cli environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2gxQEkLpRfPkyXfN" /></figure><p>dotnet new -l<br>you can use the above command to check if the template was installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*daeEEsi0EqcXjrrW" /></figure><p>CA_PG_C#_NET6_SOL is shortname for the template</p><p>There are two way to use the template.</p><p>First Method.<br>Go to a directory where you want to make use of the template and type command.<br>dotnet new CA_PG_C#_NET6_SOL -o YourProjectFolderName</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Egw4VKAutpctGtzk" /></figure><p>This will create a ClassLibrary project named Clean_Architecture_Program_Generator_for_CSharp_and_NET6 within the solution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/0*s0fgY8nVBdVOYmiH" /></figure><p>Second Method.<br>When you select new project in visual studio you will see a template named Clean_Architecture_Program_Generator_for_CSharp_and_NET6, if you don’t see filter the project type and select Clean Architecture, select this template and create your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ga3v3btAeZJtSBZs" /></figure><p>This will create a ClassLibrary project named Clean_Architecture_Program_Generator_for_CSharp_and_NET6 within YourProjectFolderName.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/0*TOoBujtgB-vF83nj" /></figure><h3>How to check if this really works</h3><p>Once all the Data related projects are generated using the “Clean Architecture Database Access Generator.tt” template.<br>Domain project by default will be provided one entity named Sample and it’s Repository and Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/0*DtetozXhn3nEaJCa" /></figure><p>When you add new entities in the Domain project under Entities folder:<br>The classes highlighted in green will get generated for each entity defined in the Domain project entities folder.<br>The Classes highlighted in red gets re-generated every time with entity details.</p><p>Startup project adds ApplicationDbContext to the service collection for dependency injection and points to a database, change the the connection string as needed, before you proceed to next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HU4Sc4ob0B7cR4DA" /></figure><h3>Code First approach</h3><p>Since we already have a sample entity defined for you by the template, let’s just make use of it.</p><p>In the Startup project modify appsettings.json to edit the connection string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K1e5K9FjPg1pkZVd" /></figure><p>dotnet ef migrations add “Add Sample entity to Database” — project Persistence — startup-project Startup<br>dotnet ef database update — project Persistence — startup-project Startup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T2WMHiJyXtThHo2P" /></figure><p>These commands will add Sample table to the database.</p><p>Note: Here Startup project is used to run Entity Framework commands.</p><p>Now use Clean Architecture WebAPI Generator.tt to generate WebAPI project. This will also create a controller for the Sample entity in the project.</p><p>Update the WebAPI projects appsetting.json to point to the correct database.</p><p>Set WebAPI as a startup project and run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JDxukzWTnGZS_X0u" /></figure><h3>Database First approach</h3><p>Here we will make use of a BookStoresDB database in a Sql Server setup. This database was grabbed from internet, credit goes to the person who made it available for community.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/0*9FZIRaKw1c2eerqh" /></figure><p>In the Startup project modify appsettings.json to edit the connection string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SBhQ9-6zTjoR1xcQ" /></figure><p>Run this command to generate entities in the domain\Entities folder and ApplicationDbContect in Persitence\Context folder.<br>scaffold-DbContext -Connection “Name=SqlServerDB” -Provider Microsoft.EntityFrameworkCore.SqlServer -Project Persistence -StartupProject Startup -OutputDir ..\Domain\Entities -Context ApplicationDbContext -ContextDir ..\Persistence\Context -Namespace Domain.Entities -ContextNamespace Persistence.Context -DataAnnotations -force</p><p>*note: if scaffold-DbContext uses a Named connection string, you won’t be able to add controllers using visual studio in-built scaffolded mechanism, you can avoid that by providing connection string directly in the scaffold-DbContext command.</p><p>This will generate all entities in domain project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*3BahAvevbu3dfWJ5" /></figure><p>Run template:<br>Clean Architecture Database Access Generator.tt<br>To generate repositories and Services for the new entities</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*FqIrzDA_Malrtb-E" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*Ab6eT4knh7SOlyZI" /></figure><p>Run template:<br>Clean Architecture WebAPI Generator.tt<br>To generate controllers for WebAPI project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*i_V4C8OFPhvqiFhO" /></figure><p>Update the WebAPI projects appsetting.json to point to the correct database.</p><p>Set WebAPI as a startup project and run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gUDzqYhcpYEX2HOl" /></figure><p>By default the WebAPI uses BasicAuthentication the userid and password is defined in the appsettings.json file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*c5fGPPN7i7DN1sTa" /></figure><p>Run template:<br>Clean Architecture WebMVC Generator.tt<br>To generate controllers for WebAPI or WebMVC project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*T3sihVeXs8x_fS50" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p5ikd96RzxJYBc6v" /></figure><h3>Some useful commands</h3><p>Code First Migrations<br>dotnet ef migrations add “initialmigration1” — project Persistence — startup-project Startup<br>dotnet ef migrations add “initialmigration2” — project Persistence — startup-project WebAPI</p><p>dotnet ef database update — project Persistence — startup-project Startup<br>dotnet ef database update — project Persistence — startup-project WebAPI</p><p>Database First Migrations<br>scaffold-DbContext -Connection “Server=DESKTOP-GBANT4V; Database=BookStoresDB; Trusted_Connection=True;” -Provider Microsoft.EntityFrameworkCore.SqlServer -Project Persistence -StartupProject Startup -OutputDir ..\Domain\Entities -Context ApplicationDbContext -ContextDir ..\Persistence\Context -Namespace Domain.Entities -ContextNamespace Persistence.Context -DataAnnotations -Force</p><p>If possible do not use connection string directly in the above command.</p><p>if you have an appsettings.json define connection strings as shown<br>“ConnectionStrings”: { “SqlServerDB”: “Server=DESKTOP-GBANT4V; Database=BookStoresDB; Trusted_Connection=True;” }<br>then use “Name=SqlServerDB” in the scaffold-DbContext -Connection parameter</p><p>Remove migration<br>dotnet ef migrations remove</p><p>List migrations<br>dotnet ef migrations list</p><p>Install Entity Framework<br>dotnet tool install — global dotnet-ef<br>dotnet tool update — global dotnet-ef</p><p>Create a solution with the current director name<br>dotnet new solution</p><p>Create a startup project if webapi or mvc not used<br>dotnet new worker -n Startup</p><p>Create class library<br>dotnet new classlib -o projectName</p><p>Add solution file<br>dotnet sln add SomeFolder/SomeProject.csproj AnotherFolder/AnotherProject.csproj</p><p>Add project dependency<br>dotnet add SomeFolder/SomeProject.csproj reference AnotherFolder/AnotherProject.csproj</p><p>Add package dependencies<br>dotnet add SomeFolder/SomeProject.csproj package microsoft.entityframeworkcore</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4edfd3e9c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alpaca Dashboard for Python Lovers]]></title>
            <link>https://medium.com/@thomsonmathews2001/alpaca-dashboard-for-python-lovers-a2026ed512bd?source=rss-9e7cdca5765f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2026ed512bd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[alpacas]]></category>
            <category><![CDATA[pyside2]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[scanner]]></category>
            <dc:creator><![CDATA[Thomson Mathews]]></dc:creator>
            <pubDate>Sun, 03 Nov 2019 01:37:53 GMT</pubDate>
            <atom:updated>2019-11-03T01:37:53.985Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Alpaca Dashboard for Python Lovers</strong></p><p>GUI interface in python for Alpaca Trade API and PySide2 (PyQty5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2kiq5xJkXfiNGkW9v_qEw.png" /></figure><p>This has the following features: Allows you to easily switch between Live and Paper environment, maintain <strong>multiple watch-list</strong>, implement <strong>multiple scanners watch-list</strong>, implement <strong>multiple algorithm</strong> that can run in the background and can be selected independently for each environment and display chart for a selected symbols</p><p><strong>Watch-lists</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*V_YAEh_xZroS1Y_8Vbejzg.png" /></figure><p>Displays real-time bid,last and ask price, right clicking on bid or ask price allows you sell or buy the stock, enter a symbol and press add button to add stock to the selected watch-list, enter &lt;watch-list-name&gt;.&lt;symbol&gt; and press add button to add the symbol to new watch-list-name.</p><p>Currently the watch-list are stored locally using a pickle file, i will make use of the Alpaca watch-list API when its available on the python SDK</p><p><strong>Positions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*hLbBYb8IjszK69G8iVkKRw.png" /></figure><p>Displays a list of your positions in your portfolio, displays current qty, last price, average purchase price, profit and filled-at time, right click to close the position</p><p><strong>Open-orders</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*tqVWI56Yv25iZdAHEg_jjQ.png" /></figure><p>Displays a list of all open orders, right click will allows you to cancel the selected or all open position</p><p><strong>Closed-Orders</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*dVHVwv20hBz4pAuqU7dekw.png" /></figure><p>Displays the last 500 closed orders</p><p><strong>Real-time Candle-Stick chart</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*yIlikEZ42MzQ53OsA0ip7g.png" /></figure><p>Clicking on the any symbol in watch-list, positions, open-orders or closed-order will display real-time candle stick chart, you can select the following time-frames: Minute, 5Minute, 15Minute or Day, cross-hair shows the price and time. Allows to zoom into the chart, Right click on the chart allows you buy or sell the stock at limit or stop price depending on where you click, it also allow you to reset zoom</p><p><strong>Buy and Sell Dialog</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*P7-Z4s4NMYiovOpUFYr-kw.png" /></figure><p>When you select buy or sell from any where on the dashboard you will be presented with this dialog box</p><p><strong>Scanner Watch-list</strong></p><p>Scanner can be easily implemented in the userlogic.py by inheriting the Scanners class, the name of the sub-classed scanner will appear in the scanner drop down, scanner will run periodically based on the assigned seconds</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*QoI99Xk_y6lMhECGW3nQcw.png" /></figure><p><strong>Algorithms</strong></p><p>Algorithm can be easily implement in the userlogic.py by inheriting Algos class, the name of subclass will appear in the Algo drop down</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*QhMUPQm82sbTdZMEfl-IYw.png" /></figure><p><strong>Where to find it</strong></p><p><a href="https://github.com/tcj2001/Alpaca-Dashboard">tcj2001/Alpaca-Dashboard</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2026ed512bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>