Skip to content

Commit

Permalink
updates on low code development
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverwang15 committed Aug 23, 2023
1 parent b6c0116 commit 88a1d18
Show file tree
Hide file tree
Showing 7 changed files with 1,140 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fingpt/FinGPT-v1/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FinGPT-V1
## Let's obtain our own FinGPT by finetuning Llama2 and ChatGLM2 with LoRA
## Let's obtain our own FinGPT by finetuning ChatGLM2 with LoRA

### Ⅰ. Data Preparations
#### 1. Download Titles [code](./data_preparations/download_titles.py)
Expand Down
26 changes: 22 additions & 4 deletions fingpt/FinGPT-v2/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
# FinGPT - v2 (American Financial News + LLaMA + LoRA)
## Let's train our own ChatGPT in Finance with pre-trained LLMs and LoRA
# FinGPT-v2
## Let's obtain our own FinGPT by finetuning Llama2 with LoRA

### Ⅰ. Data Preparations
#### 1. [Download Titles](./data_preparations/FMP.ipynb)
#### 1. Download Titles [code](./data_preparations/FMP.ipynb)
* In this file, we downloaded the financial news titles and URLs from [Financial Modeling Prep](https://site.financialmodelingprep.com/)
* You may need to apply for your api key [here](https://site.financialmodelingprep.com/developer/docs/api-keys/)
* You may need to apply for your api key [here](https://site.financialmodelingprep.com/developer/docs/api-keys/)

#### 2. Add labels
* In this file, we add the label for news titles and contents.
* The labels are determined by the change pct between the stock price of today and 5-days later
* change pct >= 0.06 : `very positive`
* 0.02 <= change pct <= 0.06 : `positive`
* -0.02 <= change pct <= 0.02 : `neutral`
* -0.06 <= change pct <= -0.02 : `negative`
* change pct <= -0.06 : `very negative`

### Ⅱ. Making Dataset
* Almost the same as FinGPT-V1

### Ⅲ. Training (Finetuning)
* Almost the same as FinGPT-V1

### Ⅳ. Inferencing
* Almost the same as FinGPT-V1
442 changes: 442 additions & 0 deletions fingpt/chatgpt-low-code-development-v1/main.ipynb

Large diffs are not rendered by default.

91 changes: 90 additions & 1 deletion fingpt/chatgpt-low-code-development-v1/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
Coming Soon
# ChatGPT Low Code Development V1: Factors Development

In financial companies, software development is an indispensable process, particularly the development of factors. Building a factor library has historically been a time-consuming and complex endeavor. We demonstrate that the strong code generation capability of ChatGPT significantly reduces the time and effort required by using prompt engineering

## Round 1
### init prompt:

You are now a senior software development engineer in top financial company. You will help me to build a factor library in Python today.

### ChatGPT's response (More in [this file](./main.ipynb)):

Sure, I'd be happy to help you build a factor library in Python for your financial company. Let's get started!

A factor library is a useful tool for quantitative analysis and modeling, which helps in evaluating and creating investment strategies. It provides a set of reusable functions and classes that can be used to calculate various factors or indicators based on financial data.

To build a factor library in Python, we'll start by creating a new Python module to house our library. Let's call it "factor_library.py". Open a text editor or an integrated development environment (IDE) and create a new file with that name.

Here's a basic outline of the steps we'll take to build the factor library:
...

## Round 2
### prompt 1:
First, please help me design the base class of all factors

### ChatGPT's response (More in [this file](./main.ipynb)):
Certainly! When designing the base class for all factors, it's important to consider the common functionality and attributes that factors will share. Here's an example of how you can design the base class for factors in Python:

```python
import pandas as pd

class Factor:
def __init__(self, df):
self.df = df

def calculate(self):
"""
This method should be implemented in each derived factor class.
It should contain the specific logic to calculate the factor value.
"""
raise NotImplementedError("Subclasses must implement calculate method.")
```
...

## Round 3
### prompt 2:
Second, please help me design 5 fundamental factors based on the base class

### ChatGPT's response (More in [this file](./main.ipynb)):
Certainly! Here are five examples of fundamental factors that you can design based on the base `Factor` class:

1. Price-to-Earnings Ratio (P/E Ratio):
```python
class PERatioFactor(Factor):
def calculate(self):
return self.df['close'] / self.df['earnings_per_share']
```
In this example, the `calculate` method divides the closing price of each data point by the corresponding earnings per share to calculate the P/E ratio factor.

2. Price-to-Book Ratio (P/B Ratio):
```python
class PBRatioFactor(Factor):
def calculate(self):
return self.df['close'] / self.df['book_value_per_share']
```
The `calculate` method divides the closing price by the book value per share to calculate the P/B ratio factor.

3. Dividend Yield:
```python
class DividendYieldFactor(Factor):
def calculate(self):
return self.df['dividends'] / self.df['close']
```
The `calculate` method divides the dividends by the closing price to calculate the dividend yield factor.

4. Debt-to-Equity Ratio:
```python
class DebtToEquityRatioFactor(Factor):
def calculate(self):
return self.df['total_debt'] / self.df['total_equity']
```
The `calculate` method divides the total debt by the total equity to calculate the debt-to-equity ratio factor.

5. Return on Equity (ROE):
```python
class ROEFactor(Factor):
def calculate(self):
return self.df['net_income'] / self.df['total_equity']
```
The `calculate` method divides the net income by the total equity to calculate the return on equity factor.
...
Loading

0 comments on commit 88a1d18

Please sign in to comment.