liveBook · Manning

ChatGPT

As explained in Build Financial Software with Generative AI (From Scratch)

A conversational generative-AI system that responds to natural-language prompts and can generate text or code.

ChatGPT is a conversational generative-AI tool for exploring questions and requesting code. In a financial-software project, it can help a developer get oriented, try a small Python task, or draft a starting point for payment-file processing. A free version can be accessed through its website without an IDE integration. section 1.4.1 section 1.5.2

A practical workflow is to ask, inspect, and refine:

  • Start with the information you need. A broad request to summarize the Check 21 regulation can be narrowed to its benefits for an average bank customer or to a couple of sentences. section 1.5.2
  • Request a small program, then specify the behavior you want. A balance-printing prompt grows into code that accepts input, formats a dollar amount, uses a function and type hints, and returns a string. section 1.5.2
  • Run and test the result. When a transaction-list function keeps two items instead of the expected three, ChatGPT identifies a faulty removal condition and a parameter name that shadows Python’s built-in max function. section 1.5.3
  • Check version-dependent advice independently. A PostgreSQL example using psycopg2 illustrates how an older model response can miss a requested newer library; a plausible revision is still only a starting point. section 1.5.7

Drafting an ACH parser

A request for a Python ACH-file parser produces different starting points in ChatGPT 3.5 and ChatGPT 4. The 3.5 draft omits record types and mislabels others; the 4 draft includes more records and some field parsing. A follow-up request separates record types into functions so valid and invalid records can be tested individually. Those functions are stubs: generating the structure does not implement or validate the full parser. section 2.3.1

Listing 2.3 Parsing with separate functions
def parse_ach(filename):
    records = []

    parser_functions = {          #1
        '1': parse_file_header,    #1
        '5': parse_batch_header,   #1
        '6': parse_entry_detail,   #1
        '7': parse_addenda,        #1
        '8': parse_batch_control,  #1
        '9': parse_file_control    #1
    }                              #1
 #1
    with open(filename, 'r') as file: #1
        lines = file.readlines()

        for line in lines:
            record_type = line[0]
            parser = parser_functions.get(record_type) #2

            if parser:                       #3
                records.append(parser(line)) 
            else:                            
                print(f"Unknown record type: 
   ➥{record_type} in line: {line}") #4
                continue

    return records
…                               #5
def parse_file_control(line):    #5
    return {                     #5
        'record_type': 'File Control',  #5
        # ... additional fields    #5
    }  #5
…                                #5

The record-type dispatch shows a useful refactoring result, while the stubbed parser functions show what remains to be implemented. section 2.3.1

Responses can differ even when the prompt is repeated. Treat regulatory summaries and generated code as aids to investigation, not as verified requirements or finished software. section 1.5.2 section 2.3.1

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Works through prompt refinement and generated-code inspection, but leaves ACH parsing details to implement and verify.
Examples
Uses Check 21 summaries, a formatted account balance, a faulty transaction list, and competing ACH parser drafts.
What it assumes
Assumes general software-development familiarity while beginning the Python balance example without requiring prior Python experience.
What you can do after
Apply it via ChatGPT to draft and refine code, then test behavior and verify version-sensitive suggestions.
How it connects
Connects prompt refinement to Python functions, unit testing, ACH parsing, and version-dependent PostgreSQL library choices.

Also explained in

Compare how 20 books explain ChatGPT →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.