I'm no expert, but what I think you have there is the remnants of a contract 1817 Deringer common rifle. It would have started life as as both a long gun and a flintlock.
The 1827 date would have been the date of manufacture and not the model. This was a common practice off and on up until the mid 19th century. Thus these dates sometime get confused with the model designation. The Harper's Ferry pistol reproduction produced by Pedersoli is a good example. It's actually a model 1805, but it was produced over a 3 or 4 year period.with each date stamped on the lock. Pedesoli used 1807 on their reproduction and I hear people all the time incorrectly refer to it as a model 1807.
Your example had been converted at some point to percussion and then some later civilian owner chopped it up into pistol size. The brass piece surrounding the nipple drum are the remnants of the ground down brass flash pan.
This conversion to percussion may have been done while it was still in some state militia arsenal somewhere but the chop job was was probably done by some home bubba type because the barrel or stock was beyond repair. As such, it would not have much value at all other than as a relic curiosity. The stamps are various arsenal proof stamps and although I have seen some of them before on other military arms of the period, I don't have any reference books since this is not my area of interest.
Here's a link to what I'm guessing it probably was originally.
https://jamesdjulia.com/item/2546-358/
Sorry, but I don't think it has much if any value at all, but once again this is not my area of expertise. From my reading about Deringer after I recently obtained a reproduction of one of his later pocket pistols, I learned that he produced contract muskets for the military early in his career, but then started producing the mid and small sized pocket pistols that he would become famous for---right around the late 1820's or early 1830's as percussion ignition became the norm.
However, if anybody is more knowledgeable about such a firearm, feel free to offer a correction.