Hi All,
I have being trying to have a custom field (I don't know if this is the correct terminology, but I want to concatenation strings in a function)
class savedOptionSymbols(peewee.Model):
equity_symbol = peewee.ForeignKeyField(savedEquitySymbols)
strike_price = peewee.FloatField(default=0)
type = peewee.CharField(max_length=1, default='C') # C-call P-Put
expiration = peewee.DateField()
active = peewee.BooleanField(default=True)
def option_symbol(self): # AMZN_07-16-21_C_3500
return str(self.type + '_' + self.strike_price)
class Meta:
database = db
db_table = 'savedOptionSymbols'
savedOptionSymbols.create_table()
### this is a separate file that i want to do all of my saving, and searching on
from DB_creation import db,savedEquitySymbols,savedOptionSymbols,savedHistoricalEquityPrices,savedHistoricalOptionPrices
from datetime import datetime
#db.connect()
# AMZN_07-16-21_C_3500 #<-- in the end I want something like this
ff = savedOptionSymbols.get_or_create(
equity_symbol = 'AMZN',
strike_price = 3500,
type = 'C', # C-call P-Put
expiration = datetime(2020, 5, 17),
)
for option in savedOptionSymbols.select().where(savedOptionSymbols.active == 1):
print(option.expiration)
print(option.strike_price)
print(option.option_symbol) #<-- this is from the custom field
db.close()
And that file outputs
2020-05-17
3500.0
<bound method savedOptionSymbols.option_symbol of <savedOptionSymbols: 1>>
I don't want a bound method I want the actual string. How do I get that?
-Jeff