How to add a new stop to the color ramp?
import bpy
from bpy import data as D

# Get a reference to the colorRamp node
cr=D.materials['Material'].node_tree.nodes['ColorRamp'].color_ramp

# enumarate the elements to the console
for e in cr.elements:
    print(e.position)

# set the left most color to green
cr.elements[0].color=(0,1,0,1)

# add a new ramp in the middle, position = 0.5
cr.elements.new(position = 0.5)

# set the middle color to red
cr.elements[1].color=(1,0,0,1)

# set the right color to blue
cr.elements[2].color=(0,0,1,1)