# ARM64 Version of MarketData Feeds designed to run on Raspbian system on a PI 5 16G RAM, 256Gig U30 SD Card.

TO-DO
1) MariaDb online
2) MarketDataServer 
  dotnet add package Microsoft.AspNet.WebApi.SelfHost --version 5.3.0
  dotnet add package System.ServiceModel.Primitives  --version 4.0.0

Git Delete Remote Branch
git push <remote_name> --delete <branch_name>
git push origin --delete <branch_name>
git branch -r
git branch -l

Please use the Microsoft.AspNet.WebApi.OwinSelfHost package for new projects.
Microsoft.AspNet.WebApi.OwinSelfHost

 dotnet add package Microsoft.AspNet.WebApi.OwinSelfHost

3) IPMonitor
4) Models

MarketDataService
/etc/systemd/system
sudo nano mks.service

Place the following into the file

[Unit]
Description=Market Data Server Service
After=network-online.target
Wants=network-online.target

[Service]
User=pi  # Or the user your executable runs as
WorkingDirectory=/opt/MarketData/MarketDataServer
ExecStart=/opt/MarketData/MarketDataServer/mks
Restart=always
RestartSec=5  # Seconds to wait before restarting (optional)
KillMode=process # Ensures the service is killed gracefully
Environment=DOTNET_ROOT=/opt/dotnet
StandardOutput=null

[Install]
WantedBy=multi-user.target


Enable the service: sudo systemctl enable mks.service. 
Start the service: sudo systemctl start mks.service. 
Check the status: sudo systemctl status mks.service

******************************************************************************************************
Adding notes on MariaDb as I plan to migrate the MySql over to one of the Raspberry PI 4 B's 
https://hevodata.com/learn/mysql-to-mariadb/

Notes on HttpClient
https://josef.codes/you-are-probably-still-using-httpclient-wrong-and-it-is-destabilizing-your-software/


*******************************************************************************************************

ARM version of marketdata libraries.
sudo truncate syslog -- size 0
more on syslog and journal
https://ubuntuforums.org/showthread.php?t=2495218
https://stackoverflow.com/questions/16995425/how-does-cmd-dev-null-21-work

journalctl --disk-usage   # See log file disk use
  sudo journalctl --vacuum-size=200M    # Drop log file size to 200M, if possible.
  sudo journalctl --vacuum-time=10d     # Drop logs, over 10 days old
  
DEV NULL  
ping a.b.c > /dev/null 2>&1 

  
CRON SCHEDULE
sudo crontab -e

** THE LATEST AND GREATEST IS ALWAYS AT THE BOTTOM

Also note that 1>/dev/null is synonymous to, but more explicit than >/dev/null

# sudo service cron reload , sudo service cron restart
# cron helper app here -> https://cron.help/#*/5_9-17_*_*_1-5
# m h  dom mon dow   command
# sudo service cron reload , sudo service cron restart
# cron helper app here -> https://cron.help/#*/5_9-17_*_*_1-5
DOTNET_ROOT=/opt/dotnet
CRON_DIR=/opt/MarketData/MarketData
*/15 6-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADHEADLINESWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
*/5 5-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADPREMARKETDATA > /dev/null 2>&1
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTPRICEOPENPOSITIONS > /dev/null 2>&1
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTPRICEWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
*/30 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTANALYSTRATINGS > /dev/null 2>&1
0 19 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) > /dev/null 2>&1
          
# m h  dom mon dow   command
# sudo service cron reload , sudo service cron restart
# cron helper app here -> https://cron.help/#*/5_9-17_*_*_1-5
DOTNET_ROOT=/opt/dotnet
CRON_DIR=/opt/MarketData/MarketData
*/15 6-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADHEADLINESWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
*/5 5-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADPREMARKETDATA > /dev/null 2>&1
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEINTRADAYPRICING > /dev/null 2>&1
*/30 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTANALYSTRATINGS > /dev/null 2>&1
0 19 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) > /dev/null 2>&1


Here is the latest crontab.  Adding the monthly jobs to run on the 17th

DOTNET_ROOT=/opt/dotnet
CRON_DIR=/opt/MarketData/MarketData
*/15 6-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADHEADLINESWATCHLIST /WATCHLIST:Valuations > /dev/null 2>&1
*/5 5-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk LOADPREMARKETDATA > /dev/null 2>&1
*/5 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEINTRADAYPRICING > /dev/null 2>&1
*/30 9-16 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATELATESTANALYSTRATINGS > /dev/null 2>&1
0 19 * * 1-5 cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEDAILY2 /DATE:$(date -d"-0 days" +\%m-\%d-\%Y) > /dev/null 2>&1
0 0 17 * * cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEFINANCIALSTATEMENTS > /dev/null 2>&1
0 0 17 * * cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEFUNDAMENTALS > /dev/null 2>&1
0 0 17 * * cd $CRON_DIR ; /opt/MarketData/MarketData/mk UPDATEHISTORICAL > /dev/null 2>&1
