I want to ask how TiDB serverless integrates with GitHub and if there are any official articles about it

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 想问一下 tidb的serverless 怎么和github结合的 有没有官方的文章

| username: tidb狂热爱好者

[TiDB Usage Environment] Production Environment / Test / Poc
[TiDB Version]
[Reproduction Path] What operations were performed that caused the issue
[Encountered Issue: Problem Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

For example, if I want to create an application. Is there the simplest way to do it?

As an average-income programmer, I tried stock investment a few years ago. Due to my professional habits, I tried using TiDB to analyze some stock data. Next, I want to share some of my thoughts and analyses with everyone:

My initial idea is to start the analysis from the following aspects:

Additionally, in stock investment, mathematical formulas are needed to understand and manage investment risks. For example, the following data formula, if well understood, can better help us make decisions in investments:

  1. Calculation of profit and cost
  2. Stock return rate
  3. Kelly formula

  • (f*) is the proportion of funds that should be invested.
  • (b) is the profit ratio of each investment.
  • (p) is the probability of winning.
  • (q) is the probability of losing, (q = 1 - p).

How to use mathematical formulas to select stocks with higher annual interest rates, and which mathematical formulas can help me invest better? Is it reliable to buy based on historical returns?

Using historical returns to select stocks with higher annual interest rates is a common method, but it has its limitations. Historical returns can provide information about a stock’s past performance but do not always accurately predict future performance.

Here are some considerations:

Below are some examples I wrote, hoping to give everyone some ideas:

Using Python and yfinance to calculate the return on equity (ROE) of the top 100 Nasdaq companies: pd.concat write

import yfinance as yf
import pandas as pd
import mysql.connector
from sqlalchemy import create_engine

# Define the list of stock codes for the top 100 Nasdaq companies
nasdaq_top_100 = ['AAPL', 'MSFT', 'AMZN']  # Please complete the list

# Create an empty list to store each company's DataFrame
dataframes = []

# Iterate through the list of stock codes
for ticker in nasdaq_top_100:
    # Get stock data
    stock = yf.Ticker(ticker)
    
    # Get financial statement data
    balance_sheet = stock.balance_sheet
    income_statement = stock.financials
    
    # Calculate ROE
    net_income = income_statement.loc['Net Income']
    shareholder_equity = balance_sheet.loc['Stockholders Equity']
    roe = net_income / shareholder_equity
    
    # Create a DataFrame to store the current company's ROE
    df = pd.DataFrame({'Ticker': [ticker], 'ROE': [roe]})
    
    # Add the DataFrame to the list
    dataframes.append(df)

# Use pd.concat to merge all companies' DataFrames
roe_df = pd.concat(dataframes)

# Output the result
print(roe_df)

# url = 'mysql+pymysql://username:password@hostname:port/dbname?charset=utf8'
# engine = sa.create_engine(url, echo=False)
engine = create_engine('mysql+pymysql://a:jmdjsj@127.0.0.1/a')
roe_df.to_sql('df', engine, index=False, method="multi", chunksize=10000, if_exists='replace')

How to use TiDB Serverless for personal investment and financial management

Generally speaking, stocks with high ROE tend to have better investment returns.

mysql> select * from df;
+--------+-----------------------------------------------------------------------------------------------------------+
| Ticker | ROE                                                                                                       |
+--------+-----------------------------------------------------------------------------------------------------------+
| AAPL   | 2023-09-30 1.56076
           2022-09-30 1.969589
           2021-09-30 1.500713
           2020-09-30 0.878664
           dtype: object |
| MSFT   | 2023-06-30 0.350887
           2022-06-30 0.436755
           2021-06-30 0.431522
           2020-06-30 0.374298
           dtype: object |
| AMZN   | 2023-12-31 0.150712
           2022-12-31 -0.018638
           2021-12-31 0.24134
           2020-12-31 0.228374
           dtype: object |

Then we use another piece of code provided by GPT to calculate their historical returns.

import yfinance as yf

# Download Ethereum data for the past 5 years
eth_data = yf.download('AMZN', period='5y')

# Calculate daily returns
daily_returns = eth_data['Adj Close'].pct_change()

# Calculate cumulative returns
cumulative_returns = (1 + daily_returns).cumprod() - 1

# Calculate the total return for 5 years
total_return_5y = cumulative_returns.iloc[-1]

# Annualized return
annualized_return = (1 + total_return_5y)**(1/5) - 1

# Output the result
print(f"5-year total return: {total_return_5y:.2%}")
print(f"Annualized return: {annualized_return:.2%}")

From this data, AMZN’s return is worse than Apple and Microsoft. Let’s use historical returns to see.

jiangming@adminnjiangming ~ % python3 apple.py
[*********************100%***********************] 1 of 1 completed
5-year total return: 272.70%
Annualized return: 30.10%

jiangming@adminnjiangming ~ % python3 AMZN.py
[*********************100%***********************] 1 of 1 completed
5-year total return: 101.90%
Annualized return: 15.09%

I plan to use TiDB’s serverless to develop a financial management website. Calculate the annual ROE of each stock. Use TiDB’s serverless as the database. I mainly focus on the content.

Similar to the following code. Calculate which stock is most worth investing in. This can also be considered an effective application of TiDB.

import yfinance as yf
import pandas as pd
import mysql.connector
from sqlalchemy import create_engine

# Define the list of stock codes for the top 100 Nasdaq companies
nasdaq_top_100 = ['AAPL', 'MSFT', 'AMZN']  # Please complete the list

# Create an empty list to store each company's DataFrame
dataframes = []

# Iterate through the list of stock codes
for ticker in nasdaq_top_100:
    # Get stock data
    stock = yf.Ticker(ticker)
    
    # Get financial statement data
    balance_sheet = stock.balance_sheet
    income_statement = stock.financials
    
    # Calculate ROE
    net_income = income_statement.loc['Net Income']
    shareholder_equity = balance_sheet.loc['Stockholders Equity']
    roe = net_income / shareholder_equity
    
    # Create a DataFrame to store the current company's ROE
    df = pd.DataFrame({'Ticker': [ticker], 'ROE': [roe]})
    
    # Add the DataFrame to the list
    dataframes.append(df)

# Use pd.concat to merge all companies' DataFrames
roe_df = pd.concat(dataframes)

# Output the result
print(roe_df)

# url = 'mysql+pymysql://username:password@hostname:port/dbname?charset=utf8'
# engine = sa.create_engine(url, echo=False)
engine = create_engine('mysql+pymysql://a:jmdjsj@127.0.0.1/a')
roe_df.to_sql('df', engine, index=False, method="multi", chunksize=10000, if_exists='replace')
| username: wd0517 | Original post link

You can integrate TiDB Serverless branching into your GitHub CI/CD pipeline, which lets you automatically test your pull requests with branches without affecting the production database. Integrate TiDB Serverless Branching (Beta) with GitHub | PingCAP Docs

| username: dba-kit | Original post link

If you want to make API calls, you can refer to Get Started with Data Service | PingCAP Docs

| username: tidb狂热爱好者 | Original post link

Thank you, I will look into it.

| username: DBAER | Original post link

The content shared is really good.